@@ -44,7 +44,12 @@ export CARGO_EXTRA_FLAGS="$CARGO_EXTRA_FLAGS --all-features"
4444
4545endgroup
4646
47- # Test
47+ # Run tests. Recognizes these variables:
48+ # - MIRI_TEST_TARGET: the target to test. Empty for host target.
49+ # - GC_STRESS: if non-empty, run the GC stress test for the main test suite.
50+ # - MIR_OPT: if non-empty, re-run test `pass` tests with mir-opt-level=4
51+ # - MANY_SEEDS: if set to N, run the "many-seeds" tests N times
52+ # - TEST_BENCH: if non-empty, check that the benchmarks all build
4853function run_tests {
4954 if [ -n " ${MIRI_TEST_TARGET:- } " ]; then
5055 begingroup " Testing foreign architecture $MIRI_TEST_TARGET "
@@ -53,32 +58,30 @@ function run_tests {
5358 fi
5459
5560 # # ui test suite
56- # On the host, also stress-test the GC.
57- if [ -z " ${MIRI_TEST_TARGET:- } " ]; then
61+ if [ -n " ${GC_STRESS:- } " ]; then
5862 MIRIFLAGS=" ${MIRIFLAGS:- } -Zmiri-provenance-gc=1" ./miri test
5963 else
6064 ./miri test
6165 fi
6266
63- # Host-only tests
64- if [ -z " ${MIRI_TEST_TARGET:- } " ]; then
65- # Running these on all targets is unlikely to catch more problems and would
66- # cost a lot of CI time.
67-
67+ # # advanced tests
68+ if [ -n " ${MIR_OPT:- } " ]; then
6869 # Tests with optimizations (`-O` is what cargo passes, but crank MIR optimizations up all the
6970 # way, too).
7071 # Optimizations change diagnostics (mostly backtraces), so we don't check
7172 # them. Also error locations change so we don't run the failing tests.
7273 # We explicitly enable debug-assertions here, they are disabled by -O but we have tests
7374 # which exist to check that we panic on debug assertion failures.
7475 MIRIFLAGS=" ${MIRIFLAGS:- } -O -Zmir-opt-level=4 -Cdebug-assertions=yes" MIRI_SKIP_UI_CHECKS=1 ./miri test -- tests/{pass,panic}
75-
76+ fi
77+ if [ -n " ${MANY_SEEDS:- } " ]; then
7678 # Also run some many-seeds tests. 64 seeds means this takes around a minute per test.
7779 # (Need to invoke via explicit `bash -c` for Windows.)
7880 for FILE in tests/many-seeds/* .rs; do
79- MIRI_SEEDS=64 ./miri many-seeds " $BASH " -c " ./miri run '$FILE '"
81+ MIRI_SEEDS=$MANY_SEEDS ./miri many-seeds " $BASH " -c " ./miri run '$FILE '"
8082 done
81-
83+ fi
84+ if [ -n " ${TEST_BENCH:- } " ]; then
8285 # Check that the benchmarks build and run, but without actually benchmarking.
8386 HYPERFINE=" '$BASH ' -c" ./miri bench
8487 fi
@@ -126,34 +129,43 @@ function run_tests_minimal {
126129
127130# # Main Testing Logic ##
128131
129- # Host target.
130- run_tests
131-
132- # Extra targets.
133132# In particular, fully cover all tier 1 targets.
134133case $HOST_TARGET in
135134 x86_64-unknown-linux-gnu)
135+ # Host
136+ GC_STRESS=1 MIR_OPT=1 MANY_SEEDS=64 TEST_BENCH=1 run_tests
137+ # Extra tier 1
136138 MIRI_TEST_TARGET=i686-unknown-linux-gnu run_tests
137139 MIRI_TEST_TARGET=aarch64-unknown-linux-gnu run_tests
138- MIRI_TEST_TARGET=aarch64-apple-darwin run_tests
139140 MIRI_TEST_TARGET=i686-pc-windows-gnu run_tests
140141 MIRI_TEST_TARGET=x86_64-pc-windows-gnu run_tests
142+ # Extra tier 2
143+ MIRI_TEST_TARGET=aarch64-apple-darwin run_tests
141144 MIRI_TEST_TARGET=arm-unknown-linux-gnueabi run_tests
142- # Some targets are only partially supported.
145+ # Partially supported targets (tier 2)
143146 MIRI_TEST_TARGET=x86_64-unknown-freebsd run_tests_minimal hello integer vec panic/panic concurrency/simple pthread-threadname libc-getentropy libc-getrandom libc-misc libc-fs atomic env align num_cpus
144147 MIRI_TEST_TARGET=i686-unknown-freebsd run_tests_minimal hello integer vec panic/panic concurrency/simple pthread-threadname libc-getentropy libc-getrandom libc-misc libc-fs atomic env align num_cpus
145-
146148 MIRI_TEST_TARGET=aarch64-linux-android run_tests_minimal hello integer vec panic/panic
147149 MIRI_TEST_TARGET=wasm32-wasi run_tests_minimal no_std integer strings wasm
148150 MIRI_TEST_TARGET=wasm32-unknown-unknown run_tests_minimal no_std integer strings wasm
149- MIRI_TEST_TARGET=thumbv7em-none-eabihf run_tests_minimal no_std # no_std embedded architecture
150- MIRI_TEST_TARGET=tests/avr.json MIRI_NO_STD=1 run_tests_minimal no_std # JSON target file
151+ MIRI_TEST_TARGET=thumbv7em-none-eabihf run_tests_minimal no_std
152+ # Custom target JSON file
153+ MIRI_TEST_TARGET=tests/avr.json MIRI_NO_STD=1 run_tests_minimal no_std
151154 ;;
152155 x86_64-apple-darwin)
153- MIRI_TEST_TARGET=s390x-unknown-linux-gnu run_tests # big-endian architecture
156+ # Host
157+ GC_STRESS=1 MIR_OPT=1 MANY_SEEDS=64 TEST_BENCH=1 run_tests
158+ # Extra tier 1
154159 MIRI_TEST_TARGET=x86_64-pc-windows-msvc run_tests
160+ # Extra tier 2
161+ MIRI_TEST_TARGET=s390x-unknown-linux-gnu run_tests # big-endian architecture
155162 ;;
156163 i686-pc-windows-msvc)
164+ # Host
165+ GC_STRESS=1 MIR_OPT=1 MANY_SEEDS=64 TEST_BENCH=1 run_tests
166+ # Extra tier 1
167+ # We really want to ensure a Linux target works on a Windows host,
168+ # and a 64bit target works on a 32bit host.
157169 MIRI_TEST_TARGET=x86_64-unknown-linux-gnu run_tests
158170 ;;
159171 * )
0 commit comments