#!/usr/bin/env sh
set -eux
target="$1"
export RUST_BACKTRACE="${RUST_BACKTRACE:-1}"
export RUSTFLAGS="${EXTRA_RUSTFLAGS:-} ${RUSTFLAGS:-}"
echo "RUSTFLAGS: '$RUSTFLAGS'"
uname -a
cmd="cargo test --target $target ${LIBC_CI_ZBUILD_STD+"-Zbuild-std"}"
test_flags="--skip check_style"
case "$target" in
*android*) cmd="$cmd --manifest-path libc-test/Cargo.toml" ;;
*s390x*) cmd="$cmd --manifest-path libc-test/Cargo.toml" ;;
*) cmd="$cmd --workspace" ;;
esac
env="$(rustc --print cfg --target "$target" | sed -n 's/target_env="\(.*\)"/\1/p')"
bits="$(rustc --print cfg --target "$target" | sed -n 's/target_pointer_width="\(.*\)"/\1/p')"
$cmd --no-default-features -- $test_flags
$cmd -- $test_flags
$cmd --features extra_traits -- $test_flags
if [ "$env" = "gnu" ] && [ "$bits" = "32" ]; then
RUST_LIBC_UNSTABLE_GNU_FILE_OFFSET_BITS=64 $cmd -- $test_flags
RUST_LIBC_UNSTABLE_GNU_TIME_BITS=64 $cmd -- $test_flags
fi