mirror of
https://github.com/openharmony/third_party_rust_libc.git
synced 2026-07-01 21:34:09 -04:00
0e57942c36
Signed-off-by: ljy9810 <longjianyin@h-partners.com>
50 lines
1.5 KiB
Bash
Executable File
50 lines
1.5 KiB
Bash
Executable File
#!/usr/bin/env sh
|
|
|
|
# Builds and runs tests for a particular target passed as an argument to this
|
|
# script.
|
|
|
|
set -eux
|
|
|
|
target="$1"
|
|
|
|
export RUST_BACKTRACE="${RUST_BACKTRACE:-1}"
|
|
# Add target-specific rustflags set in dockerfiles
|
|
export RUSTFLAGS="${EXTRA_RUSTFLAGS:-} ${RUSTFLAGS:-}"
|
|
|
|
echo "RUSTFLAGS: '$RUSTFLAGS'"
|
|
|
|
# For logging
|
|
uname -a
|
|
|
|
cmd="cargo test --target $target ${LIBC_CI_ZBUILD_STD+"-Zbuild-std"}"
|
|
test_flags="--skip check_style"
|
|
|
|
# Run tests in the `libc` crate
|
|
case "$target" in
|
|
# Only run `libc-test`
|
|
# FIXME(android): unit tests fail to start on Android
|
|
*android*) cmd="$cmd --manifest-path libc-test/Cargo.toml" ;;
|
|
*s390x*) cmd="$cmd --manifest-path libc-test/Cargo.toml" ;;
|
|
# For all other platforms, test everything in the workspace
|
|
*) 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')"
|
|
|
|
# shellcheck disable=SC2086
|
|
$cmd --no-default-features -- $test_flags
|
|
# shellcheck disable=SC2086
|
|
$cmd -- $test_flags
|
|
# shellcheck disable=SC2086
|
|
$cmd --features extra_traits -- $test_flags
|
|
|
|
# On relevant platforms, also test with our optional settings
|
|
|
|
if [ "$env" = "gnu" ] && [ "$bits" = "32" ]; then
|
|
# shellcheck disable=SC2086
|
|
RUST_LIBC_UNSTABLE_GNU_FILE_OFFSET_BITS=64 $cmd -- $test_flags
|
|
# shellcheck disable=SC2086
|
|
RUST_LIBC_UNSTABLE_GNU_TIME_BITS=64 $cmd -- $test_flags
|
|
fi
|