2018-12-12 18:15:57 +00:00
|
|
|
#!/bin/bash
|
2019-02-08 11:13:07 +00:00
|
|
|
set -euo pipefail
|
2022-07-05 00:05:22 +00:00
|
|
|
set -x
|
2018-12-12 18:15:57 +00:00
|
|
|
|
2022-08-16 12:54:20 +00:00
|
|
|
# Determine configuration for installed build
|
|
|
|
echo "Installing release version of Miri"
|
2022-07-14 17:08:09 +00:00
|
|
|
export RUSTFLAGS="-D warnings"
|
2020-05-10 21:49:10 +00:00
|
|
|
export CARGO_INCREMENTAL=0
|
2022-07-14 17:08:09 +00:00
|
|
|
./miri install # implicitly locked
|
2022-08-16 12:54:20 +00:00
|
|
|
|
|
|
|
# Prepare debug build for direct `./miri` invocations
|
|
|
|
echo "Building debug version of Miri"
|
|
|
|
export CARGO_EXTRA_FLAGS="--locked"
|
2022-08-15 23:33:07 +00:00
|
|
|
./miri check --no-default-features # make sure this can be built
|
|
|
|
./miri check --all-features # and this, too
|
2022-08-16 12:54:20 +00:00
|
|
|
./miri build --all-targets # the build that all the `./miri test` below will use
|
2018-12-12 18:52:49 +00:00
|
|
|
echo
|
2018-12-12 18:15:57 +00:00
|
|
|
|
2019-04-21 20:35:47 +00:00
|
|
|
# Test
|
|
|
|
function run_tests {
|
2020-03-21 22:28:10 +00:00
|
|
|
if [ -n "${MIRI_TEST_TARGET+exists}" ]; then
|
|
|
|
echo "Testing foreign architecture $MIRI_TEST_TARGET"
|
2020-03-21 22:17:18 +00:00
|
|
|
else
|
|
|
|
echo "Testing host architecture"
|
|
|
|
fi
|
|
|
|
|
2022-07-23 17:28:44 +00:00
|
|
|
## ui test suite
|
2022-08-16 12:54:20 +00:00
|
|
|
./miri test
|
2020-10-04 15:01:10 +00:00
|
|
|
if [ -z "${MIRI_TEST_TARGET+exists}" ]; then
|
2021-03-02 10:04:35 +00:00
|
|
|
# Only for host architecture: tests with optimizations (`-O` is what cargo passes, but crank MIR
|
|
|
|
# optimizations up all the way).
|
2022-03-17 13:49:10 +00:00
|
|
|
# Optimizations change diagnostics (mostly backtraces), so we don't check them
|
2022-05-29 06:25:36 +00:00
|
|
|
#FIXME(#2155): we want to only run the pass and panic tests here, not the fail tests.
|
2022-09-05 22:39:32 +00:00
|
|
|
MIRIFLAGS="${MIRIFLAGS:-} -O -Zmir-opt-level=4" MIRI_SKIP_UI_CHECKS=1 ./miri test -- tests/{pass,panic}
|
2020-06-25 09:34:52 +00:00
|
|
|
fi
|
2020-10-04 15:01:10 +00:00
|
|
|
|
2022-07-23 17:28:44 +00:00
|
|
|
## test-cargo-miri
|
2020-10-04 15:01:10 +00:00
|
|
|
# On Windows, there is always "python", not "python3" or "python2".
|
|
|
|
if command -v python3 > /dev/null; then
|
|
|
|
PYTHON=python3
|
|
|
|
else
|
|
|
|
PYTHON=python
|
|
|
|
fi
|
2022-07-23 23:30:15 +00:00
|
|
|
# Some environment setup that attempts to confuse the heck out of cargo-miri.
|
|
|
|
if [ "$HOST_TARGET" = x86_64-unknown-linux-gnu ]; then
|
|
|
|
# These act up on Windows (`which miri` produces a filename that does not exist?!?),
|
|
|
|
# so let's do this only on Linux. Also makes sure things work without these set.
|
|
|
|
export RUSTC=$(which rustc)
|
|
|
|
export MIRI=$(which miri)
|
|
|
|
fi
|
|
|
|
mkdir -p .cargo
|
|
|
|
echo 'build.rustc-wrapper = "thisdoesnotexist"' > .cargo/config.toml
|
|
|
|
# Run the actual test
|
2020-10-04 15:01:10 +00:00
|
|
|
${PYTHON} test-cargo-miri/run-test.py
|
2020-03-21 22:17:18 +00:00
|
|
|
echo
|
2022-07-23 23:30:15 +00:00
|
|
|
# Clean up
|
|
|
|
unset RUSTC MIRI
|
|
|
|
rm -rf .cargo
|
2022-07-04 23:40:44 +00:00
|
|
|
|
2022-08-07 02:45:25 +00:00
|
|
|
# Ensure that our benchmarks all work, but only on Linux hosts.
|
|
|
|
if [ -z "${MIRI_TEST_TARGET+exists}" ] && [ "$HOST_TARGET" = x86_64-unknown-linux-gnu ] ; then
|
2022-07-04 23:40:44 +00:00
|
|
|
for BENCH in $(ls "bench-cargo-miri"); do
|
|
|
|
cargo miri run --manifest-path bench-cargo-miri/$BENCH/Cargo.toml
|
|
|
|
done
|
|
|
|
fi
|
2019-04-21 20:35:47 +00:00
|
|
|
}
|
|
|
|
|
2022-06-26 20:20:37 +00: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
|
|
|
|
|
2022-08-16 12:54:20 +00:00
|
|
|
./miri test -- "$@"
|
2022-06-26 20:20:37 +00:00
|
|
|
}
|
|
|
|
|
2020-03-21 22:17:18 +00:00
|
|
|
# host
|
2019-04-21 20:35:47 +00:00
|
|
|
run_tests
|
2020-03-21 22:26:44 +00:00
|
|
|
|
2020-10-04 15:01:10 +00:00
|
|
|
case $HOST_TARGET in
|
|
|
|
x86_64-unknown-linux-gnu)
|
|
|
|
MIRI_TEST_TARGET=i686-unknown-linux-gnu run_tests
|
2021-01-23 15:51:36 +00:00
|
|
|
MIRI_TEST_TARGET=aarch64-apple-darwin run_tests
|
2020-10-04 15:01:10 +00:00
|
|
|
MIRI_TEST_TARGET=i686-pc-windows-msvc run_tests
|
2022-08-18 12:25:28 +00:00
|
|
|
MIRI_TEST_TARGET=x86_64-unknown-freebsd run_tests_minimal hello integer vec panic/panic concurrency/simple atomic data_race env/var
|
2022-08-18 12:39:53 +00:00
|
|
|
MIRI_TEST_TARGET=aarch64-linux-android run_tests_minimal hello integer vec panic/panic
|
2022-06-30 14:04:23 +00:00
|
|
|
MIRI_TEST_TARGET=thumbv7em-none-eabihf MIRI_NO_STD=1 run_tests_minimal no_std # no_std embedded architecture
|
2020-10-04 15:01:10 +00: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
|