2018-12-12 12:15:57 -06:00
|
|
|
#!/bin/bash
|
2019-02-08 05:13:07 -06:00
|
|
|
set -euo pipefail
|
2018-12-12 12:15:57 -06:00
|
|
|
|
|
|
|
# Determine configuration
|
2020-05-21 04:23:04 -05:00
|
|
|
export RUSTFLAGS="-D warnings"
|
2020-05-10 16:49:10 -05:00
|
|
|
export CARGO_INCREMENTAL=0
|
|
|
|
export CARGO_EXTRA_FLAGS="--all-features"
|
2018-12-12 12:15:57 -06:00
|
|
|
|
2019-04-21 15:35:47 -05:00
|
|
|
# Prepare
|
2018-12-12 12:52:49 -06:00
|
|
|
echo "Build and install miri"
|
2019-10-14 02:40:11 -05:00
|
|
|
./miri build --all-targets --locked
|
|
|
|
./miri install # implicitly locked
|
2018-12-12 12:52:49 -06:00
|
|
|
echo
|
2018-12-12 12:15:57 -06:00
|
|
|
|
2019-04-21 15:35:47 -05:00
|
|
|
# Test
|
|
|
|
function run_tests {
|
2020-03-21 17:28:10 -05:00
|
|
|
if [ -n "${MIRI_TEST_TARGET+exists}" ]; then
|
|
|
|
echo "Testing foreign architecture $MIRI_TEST_TARGET"
|
2020-03-21 17:17:18 -05:00
|
|
|
else
|
|
|
|
echo "Testing host architecture"
|
|
|
|
fi
|
|
|
|
|
|
|
|
./miri test --locked
|
2020-10-04 10:01:10 -05:00
|
|
|
if [ -z "${MIRI_TEST_TARGET+exists}" ]; then
|
2021-03-02 04:04:35 -06:00
|
|
|
# Only for host architecture: tests with optimizations (`-O` is what cargo passes, but crank MIR
|
|
|
|
# optimizations up all the way).
|
2022-03-17 08:49:10 -05:00
|
|
|
# Optimizations change diagnostics (mostly backtraces), so we don't check them
|
2022-05-29 01:25:36 -05:00
|
|
|
#FIXME(#2155): we want to only run the pass and panic tests here, not the fail tests.
|
2022-06-01 09:53:38 -05:00
|
|
|
MIRIFLAGS="-O -Zmir-opt-level=4" MIRI_SKIP_UI_CHECKS=1 ./miri test --locked -- tests/{pass,panic}
|
2020-06-25 04:34:52 -05:00
|
|
|
fi
|
2020-10-04 10:01:10 -05:00
|
|
|
|
|
|
|
# On Windows, there is always "python", not "python3" or "python2".
|
|
|
|
if command -v python3 > /dev/null; then
|
|
|
|
PYTHON=python3
|
|
|
|
else
|
|
|
|
PYTHON=python
|
|
|
|
fi
|
|
|
|
|
2020-03-21 17:17:18 -05:00
|
|
|
# "miri test" has built the sysroot for us, now this should pass without
|
|
|
|
# any interactive questions.
|
2020-10-04 10:01:10 -05:00
|
|
|
${PYTHON} test-cargo-miri/run-test.py
|
2020-03-21 17:17:18 -05:00
|
|
|
echo
|
2019-04-21 15:35:47 -05:00
|
|
|
}
|
|
|
|
|
2022-06-26 15:20:37 -05:00
|
|
|
function run_tests_minimal {
|
|
|
|
if [ -n "${MIRI_TEST_TARGET+exists}" ]; then
|
|
|
|
echo "Testing MINIMAL foreign architecture $MIRI_TEST_TARGET: only testing $@"
|
|
|
|
else
|
|
|
|
echo "Testing MINIMAL host architecture: only testing $@"
|
|
|
|
fi
|
|
|
|
|
|
|
|
./miri test --locked -- "$@"
|
|
|
|
}
|
|
|
|
|
2020-03-21 17:17:18 -05:00
|
|
|
# host
|
2019-04-21 15:35:47 -05:00
|
|
|
run_tests
|
2020-03-21 17:26:44 -05:00
|
|
|
|
2020-10-04 10:01:10 -05:00
|
|
|
case $HOST_TARGET in
|
|
|
|
x86_64-unknown-linux-gnu)
|
|
|
|
MIRI_TEST_TARGET=i686-unknown-linux-gnu run_tests
|
2021-01-23 09:51:36 -06:00
|
|
|
MIRI_TEST_TARGET=aarch64-apple-darwin run_tests
|
2020-10-04 10:01:10 -05:00
|
|
|
MIRI_TEST_TARGET=i686-pc-windows-msvc run_tests
|
2022-07-01 11:52:32 -05:00
|
|
|
MIRI_TEST_TARGET=x86_64-unknown-freebsd run_tests_minimal hello integer vec current_dir_with_isolation
|
2022-06-30 09:04:23 -05:00
|
|
|
MIRI_TEST_TARGET=thumbv7em-none-eabihf MIRI_NO_STD=1 run_tests_minimal no_std # no_std embedded architecture
|
2020-10-04 10:01:10 -05:00
|
|
|
;;
|
|
|
|
x86_64-apple-darwin)
|
|
|
|
MIRI_TEST_TARGET=mips64-unknown-linux-gnuabi64 run_tests # big-endian architecture
|
|
|
|
MIRI_TEST_TARGET=x86_64-pc-windows-msvc run_tests
|
|
|
|
;;
|
|
|
|
i686-pc-windows-msvc)
|
|
|
|
MIRI_TEST_TARGET=x86_64-unknown-linux-gnu run_tests
|
|
|
|
;;
|
|
|
|
*)
|
|
|
|
echo "FATAL: unknown OS"
|
|
|
|
exit 1
|
|
|
|
;;
|
|
|
|
esac
|