@@ -31,24 +31,26 @@ time ./miri build --all-targets # the build that all the `./miri test` below wil
3131endgroup
3232
3333# Run tests. Recognizes these variables:
34- # - MIRI_TEST_TARGET : the target to test. Empty for host target.
34+ # - TEST_TARGET : the target to test. Empty for host target.
3535# - GC_STRESS: if non-empty, run the GC stress test for the main test suite.
3636# - MIR_OPT: if non-empty, re-run test `pass` tests with mir-opt-level=4
3737# - MANY_SEEDS: if set to N, run the "many-seeds" tests N times
3838# - TEST_BENCH: if non-empty, check that the benchmarks all build
3939# - CARGO_MIRI_ENV: if non-empty, set some env vars and config to potentially confuse cargo-miri
4040function run_tests {
41- if [ -n " ${MIRI_TEST_TARGET-} " ]; then
42- begingroup " Testing foreign architecture $MIRI_TEST_TARGET "
41+ if [ -n " ${TEST_TARGET-} " ]; then
42+ begingroup " Testing foreign architecture $TEST_TARGET "
43+ TARGET_FLAG=" --target $TEST_TARGET "
4344 else
4445 begingroup " Testing host architecture"
46+ TARGET_FLAG=" "
4547 fi
4648
4749 # # ui test suite
4850 if [ -n " ${GC_STRESS-} " ]; then
49- time MIRIFLAGS=" ${MIRIFLAGS-} -Zmiri-provenance-gc=1" ./miri test
51+ time MIRIFLAGS=" ${MIRIFLAGS-} -Zmiri-provenance-gc=1" ./miri test $TARGET_FLAG
5052 else
51- time ./miri test
53+ time ./miri test $TARGET_FLAG
5254 fi
5355
5456 # # advanced tests
@@ -59,17 +61,17 @@ function run_tests {
5961 # them. Also error locations change so we don't run the failing tests.
6062 # We explicitly enable debug-assertions here, they are disabled by -O but we have tests
6163 # which exist to check that we panic on debug assertion failures.
62- time MIRIFLAGS=" ${MIRIFLAGS-} -O -Zmir-opt-level=4 -Cdebug-assertions=yes" MIRI_SKIP_UI_CHECKS=1 ./miri test tests/{pass,panic}
64+ time MIRIFLAGS=" ${MIRIFLAGS-} -O -Zmir-opt-level=4 -Cdebug-assertions=yes" MIRI_SKIP_UI_CHECKS=1 ./miri test $TARGET_FLAG tests/{pass,panic}
6365 fi
6466 if [ -n " ${MANY_SEEDS-} " ]; then
6567 # Also run some many-seeds tests.
6668 time for FILE in tests/many-seeds/* .rs; do
67- ./miri run " --many-seeds=0..$MANY_SEEDS " " $FILE "
69+ ./miri run " --many-seeds=0..$MANY_SEEDS " $TARGET_FLAG " $FILE "
6870 done
6971 fi
7072 if [ -n " ${TEST_BENCH-} " ]; then
7173 # Check that the benchmarks build and run, but only once.
72- time HYPERFINE=" hyperfine -w0 -r1" ./miri bench
74+ time HYPERFINE=" hyperfine -w0 -r1" ./miri bench $TARGET_FLAG
7375 fi
7476
7577 # # test-cargo-miri
@@ -91,7 +93,7 @@ function run_tests {
9193 echo ' build.rustc-wrapper = "thisdoesnotexist"' > .cargo/config.toml
9294 fi
9395 # Run the actual test
94- time ${PYTHON} test-cargo-miri/run-test.py
96+ time ${PYTHON} test-cargo-miri/run-test.py $TARGET_FLAG
9597 # Clean up
9698 unset RUSTC MIRI
9799 rm -rf .cargo
@@ -100,17 +102,18 @@ function run_tests {
100102}
101103
102104function run_tests_minimal {
103- if [ -n " ${MIRI_TEST_TARGET-} " ]; then
104- begingroup " Testing MINIMAL foreign architecture $MIRI_TEST_TARGET : only testing $@ "
105+ if [ -n " ${TEST_TARGET-} " ]; then
106+ begingroup " Testing MINIMAL foreign architecture $TEST_TARGET : only testing $@ "
107+ TARGET_FLAG=" --target $TEST_TARGET "
105108 else
106- echo " run_tests_minimal requires MIRI_TEST_TARGET to be set"
109+ echo " run_tests_minimal requires TEST_TARGET to be set"
107110 exit 1
108111 fi
109112
110- time ./miri test " $@ "
113+ time ./miri test $TARGET_FLAG " $@ "
111114
112115 # Ensure that a small smoke test of cargo-miri works.
113- time cargo miri run --manifest-path test-cargo-miri/no-std-smoke/Cargo.toml --target ${MIRI_TEST_TARGET- $HOST_TARGET }
116+ time cargo miri run --manifest-path test-cargo-miri/no-std-smoke/Cargo.toml $TARGET_FLAG
114117
115118 endgroup
116119}
@@ -126,33 +129,33 @@ case $HOST_TARGET in
126129 # Extra tier 1
127130 # With reduced many-seed count to avoid spending too much time on that.
128131 # (All OSes and ABIs are run with 64 seeds at least once though via the macOS runner.)
129- MANY_SEEDS=16 MIRI_TEST_TARGET =i686-unknown-linux-gnu run_tests
130- MANY_SEEDS=16 MIRI_TEST_TARGET =aarch64-unknown-linux-gnu run_tests
131- MANY_SEEDS=16 MIRI_TEST_TARGET =x86_64-apple-darwin run_tests
132- MANY_SEEDS=16 MIRI_TEST_TARGET =x86_64-pc-windows-gnu run_tests
132+ MANY_SEEDS=16 TEST_TARGET =i686-unknown-linux-gnu run_tests
133+ MANY_SEEDS=16 TEST_TARGET =aarch64-unknown-linux-gnu run_tests
134+ MANY_SEEDS=16 TEST_TARGET =x86_64-apple-darwin run_tests
135+ MANY_SEEDS=16 TEST_TARGET =x86_64-pc-windows-gnu run_tests
133136 ;;
134137 aarch64-apple-darwin)
135138 # Host (tier 2)
136139 GC_STRESS=1 MIR_OPT=1 MANY_SEEDS=64 TEST_BENCH=1 CARGO_MIRI_ENV=1 run_tests
137140 # Extra tier 1
138- MANY_SEEDS=64 MIRI_TEST_TARGET =i686-pc-windows-gnu run_tests
139- MANY_SEEDS=64 MIRI_TEST_TARGET =x86_64-pc-windows-msvc CARGO_MIRI_ENV=1 run_tests
141+ MANY_SEEDS=64 TEST_TARGET =i686-pc-windows-gnu run_tests
142+ MANY_SEEDS=64 TEST_TARGET =x86_64-pc-windows-msvc CARGO_MIRI_ENV=1 run_tests
140143 # Extra tier 2
141- MIRI_TEST_TARGET =arm-unknown-linux-gnueabi run_tests
142- MIRI_TEST_TARGET =s390x-unknown-linux-gnu run_tests # big-endian architecture of choice
144+ TEST_TARGET =arm-unknown-linux-gnueabi run_tests
145+ TEST_TARGET =s390x-unknown-linux-gnu run_tests # big-endian architecture of choice
143146 # Partially supported targets (tier 2)
144147 VERY_BASIC=" integer vec string btreemap" # common things we test on all of them (if they have std), requires no target-specific shims
145148 BASIC=" $VERY_BASIC hello hashmap alloc align" # ensures we have the shims for stdout and basic data structures
146- MIRI_TEST_TARGET =x86_64-unknown-freebsd run_tests_minimal $BASIC panic/panic concurrency/simple atomic threadname libc-mem libc-misc libc-random libc-time fs env num_cpus
147- MIRI_TEST_TARGET =i686-unknown-freebsd run_tests_minimal $BASIC panic/panic concurrency/simple atomic threadname libc-mem libc-misc libc-random libc-time fs env num_cpus
148- MIRI_TEST_TARGET =x86_64-unknown-illumos run_tests_minimal $VERY_BASIC hello panic/panic concurrency/simple pthread-sync libc-mem libc-misc libc-random
149- MIRI_TEST_TARGET =x86_64-pc-solaris run_tests_minimal $VERY_BASIC hello panic/panic concurrency/simple pthread-sync libc-mem libc-misc libc-random
150- MIRI_TEST_TARGET =aarch64-linux-android run_tests_minimal $VERY_BASIC hello panic/panic
151- MIRI_TEST_TARGET =wasm32-wasi run_tests_minimal $VERY_BASIC wasm
152- MIRI_TEST_TARGET =wasm32-unknown-unknown run_tests_minimal $VERY_BASIC wasm
153- MIRI_TEST_TARGET =thumbv7em-none-eabihf run_tests_minimal no_std
149+ TEST_TARGET =x86_64-unknown-freebsd run_tests_minimal $BASIC panic/panic concurrency/simple atomic threadname libc-mem libc-misc libc-random libc-time fs env num_cpus
150+ TEST_TARGET =i686-unknown-freebsd run_tests_minimal $BASIC panic/panic concurrency/simple atomic threadname libc-mem libc-misc libc-random libc-time fs env num_cpus
151+ TEST_TARGET =x86_64-unknown-illumos run_tests_minimal $VERY_BASIC hello panic/panic concurrency/simple pthread-sync libc-mem libc-misc libc-random
152+ TEST_TARGET =x86_64-pc-solaris run_tests_minimal $VERY_BASIC hello panic/panic concurrency/simple pthread-sync libc-mem libc-misc libc-random
153+ TEST_TARGET =aarch64-linux-android run_tests_minimal $VERY_BASIC hello panic/panic
154+ TEST_TARGET =wasm32-wasi run_tests_minimal $VERY_BASIC wasm
155+ TEST_TARGET =wasm32-unknown-unknown run_tests_minimal $VERY_BASIC wasm
156+ TEST_TARGET =thumbv7em-none-eabihf run_tests_minimal no_std
154157 # Custom target JSON file
155- MIRI_TEST_TARGET =tests/avr.json MIRI_NO_STD=1 run_tests_minimal no_std
158+ TEST_TARGET =tests/avr.json MIRI_NO_STD=1 run_tests_minimal no_std
156159 ;;
157160 i686-pc-windows-msvc)
158161 # Host
@@ -162,7 +165,7 @@ case $HOST_TARGET in
162165 # Extra tier 1
163166 # We really want to ensure a Linux target works on a Windows host,
164167 # and a 64bit target works on a 32bit host.
165- MIRI_TEST_TARGET =x86_64-unknown-linux-gnu run_tests
168+ TEST_TARGET =x86_64-unknown-linux-gnu run_tests
166169 ;;
167170 * )
168171 echo " FATAL: unknown host target: $HOST_TARGET "
0 commit comments