@@ -27,60 +27,59 @@ export RUSTFLAGS="-D warnings"
2727export CARGO_INCREMENTAL=0
2828export CARGO_EXTRA_FLAGS=" --locked"
2929
30- # Determine configuration for installed build
30+ # Determine configuration for installed build (used by test-cargo-miri).
3131echo " Installing release version of Miri"
32- ./miri install
33-
34- echo " Checking various feature flag configurations"
35- ./miri check --no-default-features # make sure this can be built
36- ./miri check # and this, too
37- # `--all-features` is used for the build below, so no extra check needed.
32+ time ./miri install
3833
3934# Prepare debug build for direct `./miri` invocations.
4035# We enable all features to make sure the Stacked Borrows consistency check runs.
4136echo " Building debug version of Miri"
4237export CARGO_EXTRA_FLAGS=" $CARGO_EXTRA_FLAGS --all-features"
43- ./miri build --all-targets # the build that all the `./miri test` below will use
38+ time ./miri build --all-targets # the build that all the `./miri test` below will use
4439
4540endgroup
4641
47- # Test
42+ # Run tests. Recognizes these variables:
43+ # - MIRI_TEST_TARGET: the target to test. Empty for host target.
44+ # - GC_STRESS: if non-empty, run the GC stress test for the main test suite.
45+ # - MIR_OPT: if non-empty, re-run test `pass` tests with mir-opt-level=4
46+ # - MANY_SEEDS: if set to N, run the "many-seeds" tests N times
47+ # - TEST_BENCH: if non-empty, check that the benchmarks all build
48+ # - CARGO_MIRI_ENV: if non-empty, set some env vars and config to potentially confuse cargo-miri
4849function run_tests {
49- if [ -n " ${MIRI_TEST_TARGET: - } " ]; then
50+ if [ -n " ${MIRI_TEST_TARGET-} " ]; then
5051 begingroup " Testing foreign architecture $MIRI_TEST_TARGET "
5152 else
5253 begingroup " Testing host architecture"
5354 fi
5455
5556 # # ui test suite
56- # On the host, also stress-test the GC.
57- if [ -z " ${MIRI_TEST_TARGET:- } " ]; then
58- MIRIFLAGS=" ${MIRIFLAGS:- } -Zmiri-provenance-gc=1" ./miri test
57+ if [ -n " ${GC_STRESS-} " ]; then
58+ time MIRIFLAGS=" ${MIRIFLAGS-} -Zmiri-provenance-gc=1" ./miri test
5959 else
60- ./miri test
60+ time ./miri test
6161 fi
6262
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-
63+ # # advanced tests
64+ if [ -n " ${MIR_OPT-} " ]; then
6865 # Tests with optimizations (`-O` is what cargo passes, but crank MIR optimizations up all the
6966 # way, too).
7067 # Optimizations change diagnostics (mostly backtraces), so we don't check
7168 # them. Also error locations change so we don't run the failing tests.
7269 # We explicitly enable debug-assertions here, they are disabled by -O but we have tests
7370 # which exist to check that we panic on debug assertion failures.
74- MIRIFLAGS=" ${MIRIFLAGS:- } -O -Zmir-opt-level=4 -Cdebug-assertions=yes" MIRI_SKIP_UI_CHECKS=1 ./miri test -- tests/{pass,panic}
75-
71+ time MIRIFLAGS=" ${MIRIFLAGS-} -O -Zmir-opt-level=4 -Cdebug-assertions=yes" MIRI_SKIP_UI_CHECKS=1 ./miri test -- tests/{pass,panic}
72+ fi
73+ if [ -n " ${MANY_SEEDS-} " ]; then
7674 # Also run some many-seeds tests. 64 seeds means this takes around a minute per test.
7775 # (Need to invoke via explicit `bash -c` for Windows.)
78- for FILE in tests/many-seeds/* .rs; do
79- MIRI_SEEDS=64 ./miri many-seeds " $BASH " -c " ./miri run '$FILE '"
76+ time for FILE in tests/many-seeds/* .rs; do
77+ MIRI_SEEDS=$MANY_SEEDS ./miri many-seeds " $BASH " -c " ./miri run '$FILE '"
8078 done
81-
79+ fi
80+ if [ -n " ${TEST_BENCH-} " ]; then
8281 # Check that the benchmarks build and run, but without actually benchmarking.
83- HYPERFINE=" '$BASH ' -c" ./miri bench
82+ time HYPERFINE=" '$BASH ' -c" ./miri bench
8483 fi
8584
8685 # # test-cargo-miri
@@ -91,16 +90,18 @@ function run_tests {
9190 PYTHON=python
9291 fi
9392 # Some environment setup that attempts to confuse the heck out of cargo-miri.
94- if [ " $HOST_TARGET " = x86_64-unknown-linux-gnu ]; then
95- # These act up on Windows (`which miri` produces a filename that does not exist?!?),
96- # so let's do this only on Linux. Also makes sure things work without these set.
97- export RUSTC=$( which rustc) # Produces a warning unless we also set MIRI
93+ if [ -n " ${CARGO_MIRI_ENV-} " ]; then
94+ # These act up on Windows (`which miri` produces a filename that does not exist?!?).
95+ # RUSTC is the main thing to set (it changes the first argument our wrapper will see).
96+ # Unless MIRI is also set, that produces a warning.
97+ export RUSTC=$( which rustc)
9898 export MIRI=$( rustc +miri --print sysroot) /bin/miri
99+ # We entirely ignore other wrappers.
100+ mkdir -p .cargo
101+ echo ' build.rustc-wrapper = "thisdoesnotexist"' > .cargo/config.toml
99102 fi
100- mkdir -p .cargo
101- echo ' build.rustc-wrapper = "thisdoesnotexist"' > .cargo/config.toml
102103 # Run the actual test
103- ${PYTHON} test-cargo-miri/run-test.py
104+ time ${PYTHON} test-cargo-miri/run-test.py
104105 # Clean up
105106 unset RUSTC MIRI
106107 rm -rf .cargo
@@ -109,7 +110,7 @@ function run_tests {
109110}
110111
111112function run_tests_minimal {
112- if [ -n " ${MIRI_TEST_TARGET: - } " ]; then
113+ if [ -n " ${MIRI_TEST_TARGET-} " ]; then
113114 begingroup " Testing MINIMAL foreign architecture $MIRI_TEST_TARGET : only testing $@ "
114115 else
115116 echo " run_tests_minimal requires MIRI_TEST_TARGET to be set"
@@ -126,38 +127,49 @@ function run_tests_minimal {
126127
127128# # Main Testing Logic ##
128129
129- # Host target.
130- run_tests
131-
132- # Extra targets.
133130# In particular, fully cover all tier 1 targets.
134131case $HOST_TARGET in
135132 x86_64-unknown-linux-gnu)
133+ # Host
134+ GC_STRESS=1 MIR_OPT=1 MANY_SEEDS=64 TEST_BENCH=1 CARGO_MIRI_ENV=1 run_tests
135+ # Extra tier 1
136136 MIRI_TEST_TARGET=i686-unknown-linux-gnu run_tests
137137 MIRI_TEST_TARGET=aarch64-unknown-linux-gnu run_tests
138- MIRI_TEST_TARGET=aarch64 -apple-darwin run_tests
138+ MIRI_TEST_TARGET=x86_64 -apple-darwin run_tests
139139 MIRI_TEST_TARGET=i686-pc-windows-gnu run_tests
140140 MIRI_TEST_TARGET=x86_64-pc-windows-gnu run_tests
141+ # Extra tier 2
142+ MIRI_TEST_TARGET=aarch64-apple-darwin run_tests
141143 MIRI_TEST_TARGET=arm-unknown-linux-gnueabi run_tests
142- # Some targets are only partially supported.
144+ # Partially supported targets (tier 2)
143145 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
144146 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-
146147 MIRI_TEST_TARGET=aarch64-linux-android run_tests_minimal hello integer vec panic/panic
147148 MIRI_TEST_TARGET=wasm32-wasi run_tests_minimal no_std integer strings wasm
148149 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
150+ MIRI_TEST_TARGET=thumbv7em-none-eabihf run_tests_minimal no_std
151+ # Custom target JSON file
152+ MIRI_TEST_TARGET=tests/avr.json MIRI_NO_STD=1 run_tests_minimal no_std
151153 ;;
152- x86_64-apple-darwin)
154+ aarch64-apple-darwin)
155+ # Host (tier 2)
156+ GC_STRESS=1 MIR_OPT=1 MANY_SEEDS=64 TEST_BENCH=1 CARGO_MIRI_ENV=1 run_tests
157+ # Extra tier 1
158+ MIRI_TEST_TARGET=x86_64-pc-windows-msvc CARGO_MIRI_ENV=1 run_tests
159+ # Extra tier 2
153160 MIRI_TEST_TARGET=s390x-unknown-linux-gnu run_tests # big-endian architecture
154- MIRI_TEST_TARGET=x86_64-pc-windows-msvc run_tests
155161 ;;
156162 i686-pc-windows-msvc)
163+ # Host
164+ # Only smoke-test `many-seeds`; 64 runs take 15min here!
165+ GC_STRESS=1 MIR_OPT=1 MANY_SEEDS=1 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 * )
160- echo " FATAL: unknown OS "
172+ echo " FATAL: unknown host target: $HOST_TARGET "
161173 exit 1
162174 ;;
163175esac
0 commit comments