From 059d0c63d30a37783b9a98bef7daf780524a3a6e Mon Sep 17 00:00:00 2001 From: Andrew Gallant Date: Fri, 4 Jan 2019 07:19:41 -0500 Subject: [PATCH] ci: test on big endian There is a hypothesis that the memchr rewrite from a while back is getting things wrong on big endian, as shown here: https://github.com/BurntSushi/ripgrep/issues/1144 As a result, we start testing in CI on a big endian architecture. --- .travis.yml | 5 +++++ ci/script.sh | 29 ++++++++++++++++++++--------- src/tests/mod.rs | 12 ++++++++++++ 3 files changed, 37 insertions(+), 9 deletions(-) diff --git a/.travis.yml b/.travis.yml index 8213f46..1a869a0 100644 --- a/.travis.yml +++ b/.travis.yml @@ -28,6 +28,11 @@ matrix: - os: linux rust: 1.13.0 env: TARGET=x86_64-unknown-linux-gnu + # For testing big-endian. + - env: TARGET=mips64-unknown-linux-gnuabi64 CROSS=1 + rust: stable + services: docker + sudo: required script: ci/script.sh branches: only: diff --git a/ci/script.sh b/ci/script.sh index 5d3817b..25118b7 100755 --- a/ci/script.sh +++ b/ci/script.sh @@ -2,6 +2,16 @@ # vim: ft=sh sw=2 ts=2 sts=2 +# Setup some variables for executing cargo commands. +# Things are a little different if we're testing with cross. +if [ -n "$CROSS" ]; then + rustup target add "$TARGET" + cargo install cross --force + export CARGO_CMD="cross" +else + export CARGO_CMD="cargo" +fi + is_x86_64() { case "$TARGET" in x86_64-*) @@ -34,9 +44,9 @@ fi if [[ "$(host)" != "$TARGET" ]]; then rustup target add "$TARGET" fi -cargo build --target "$TARGET" --verbose --no-default-features -cargo build --target "$TARGET" --verbose -cargo doc --target "$TARGET" --verbose +"$CARGO_CMD" build --target "$TARGET" --verbose --no-default-features +"$CARGO_CMD" build --target "$TARGET" --verbose +"$CARGO_CMD" doc --target "$TARGET" --verbose # If we're testing on an older version of Rust, then only check that we # can build the crate. This is because the dev dependencies might be updated @@ -47,27 +57,28 @@ if [ "$TRAVIS_RUST_VERSION" = "1.13.0" ]; then exit fi -cargo test --target "$TARGET" --verbose +"$CARGO_CMD" test --target "$TARGET" --verbose +"$CARGO_CMD" test --target "$TARGET" --verbose byte_order -- --nocapture # If we're testing on x86_64, then test all possible permutations of SIMD # config. if is_x86_64; then preamble="--cfg memchr_disable_auto_simd" # Force use of libc. - RUSTFLAGS="$preamble" cargo test --target "$TARGET" --verbose + RUSTFLAGS="$preamble" "$CARGO_CMD" test --target "$TARGET" --verbose preamble="$preamble --cfg memchr_runtime_simd" # Force use of fallback - RUSTFLAGS="$preamble" cargo test --target "$TARGET" --verbose + RUSTFLAGS="$preamble" "$CARGO_CMD" test --target "$TARGET" --verbose # Force use of sse2 only RUSTFLAGS="$preamble --cfg memchr_runtime_sse2" \ - cargo test --target "$TARGET" --verbose + "$CARGO_CMD" test --target "$TARGET" --verbose # Force use of avx only RUSTFLAGS="$preamble --cfg memchr_runtime_avx" \ - cargo test --target "$TARGET" --verbose + "$CARGO_CMD" test --target "$TARGET" --verbose fi if [[ "$TRAVIS_RUST_VERSION" = "nightly" ]] && is_x86_64 && [[ "$TRAVIS_OS_NAME" = "linux" ]]; then - cargo bench \ + "$CARGO_CMD" bench \ --manifest-path bench/Cargo.toml \ --target "$TARGET" \ --verbose \ diff --git a/src/tests/mod.rs b/src/tests/mod.rs index 73112d3..7033e2e 100644 --- a/src/tests/mod.rs +++ b/src/tests/mod.rs @@ -3,6 +3,18 @@ use std::iter::repeat; mod iter; mod memchr; +#[cfg(target_endian = "little")] +#[test] +fn byte_order() { + eprintln!("LITTLE ENDIAN"); +} + +#[cfg(target_endian = "big")] +#[test] +fn byte_order() { + eprintln!("BIG ENDIAN"); +} + /// Create a sequence of tests that should be run by memchr implementations. fn memchr_tests() -> Vec { let mut tests = Vec::new();