Skip to content

Commit

Permalink
ci: test on big endian
Browse files Browse the repository at this point in the history
There is a hypothesis that the memchr rewrite from a while back is
getting things wrong on big endian, as shown here:
BurntSushi/ripgrep#1144

As a result, we start testing in CI on a big endian architecture.
  • Loading branch information
BurntSushi committed Jan 4, 2019
1 parent 437a177 commit 059d0c6
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 9 deletions.
5 changes: 5 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
29 changes: 20 additions & 9 deletions ci/script.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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-*)
Expand Down Expand Up @@ -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
Expand All @@ -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 \
Expand Down
12 changes: 12 additions & 0 deletions src/tests/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<MemchrTest> {
let mut tests = Vec::new();
Expand Down

0 comments on commit 059d0c6

Please sign in to comment.