@@ -27,60 +27,59 @@ export RUSTFLAGS="-D warnings"
27
27
export CARGO_INCREMENTAL=0
28
28
export CARGO_EXTRA_FLAGS=" --locked"
29
29
30
- # Determine configuration for installed build
30
+ # Determine configuration for installed build (used by test-cargo-miri).
31
31
echo " 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
38
33
39
34
# Prepare debug build for direct `./miri` invocations.
40
35
# We enable all features to make sure the Stacked Borrows consistency check runs.
41
36
echo " Building debug version of Miri"
42
37
export 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
44
39
45
40
endgroup
46
41
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
48
49
function run_tests {
49
- if [ -n " ${MIRI_TEST_TARGET: - } " ]; then
50
+ if [ -n " ${MIRI_TEST_TARGET-} " ]; then
50
51
begingroup " Testing foreign architecture $MIRI_TEST_TARGET "
51
52
else
52
53
begingroup " Testing host architecture"
53
54
fi
54
55
55
56
# # 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
59
59
else
60
- ./miri test
60
+ time ./miri test
61
61
fi
62
62
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
68
65
# Tests with optimizations (`-O` is what cargo passes, but crank MIR optimizations up all the
69
66
# way, too).
70
67
# Optimizations change diagnostics (mostly backtraces), so we don't check
71
68
# them. Also error locations change so we don't run the failing tests.
72
69
# We explicitly enable debug-assertions here, they are disabled by -O but we have tests
73
70
# 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
76
74
# Also run some many-seeds tests. 64 seeds means this takes around a minute per test.
77
75
# (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 '"
80
78
done
81
-
79
+ fi
80
+ if [ -n " ${TEST_BENCH-} " ]; then
82
81
# Check that the benchmarks build and run, but without actually benchmarking.
83
- HYPERFINE=" '$BASH ' -c" ./miri bench
82
+ time HYPERFINE=" '$BASH ' -c" ./miri bench
84
83
fi
85
84
86
85
# # test-cargo-miri
@@ -91,16 +90,18 @@ function run_tests {
91
90
PYTHON=python
92
91
fi
93
92
# 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)
98
98
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
99
102
fi
100
- mkdir -p .cargo
101
- echo ' build.rustc-wrapper = "thisdoesnotexist"' > .cargo/config.toml
102
103
# Run the actual test
103
- ${PYTHON} test-cargo-miri/run-test.py
104
+ time ${PYTHON} test-cargo-miri/run-test.py
104
105
# Clean up
105
106
unset RUSTC MIRI
106
107
rm -rf .cargo
@@ -109,7 +110,7 @@ function run_tests {
109
110
}
110
111
111
112
function run_tests_minimal {
112
- if [ -n " ${MIRI_TEST_TARGET: - } " ]; then
113
+ if [ -n " ${MIRI_TEST_TARGET-} " ]; then
113
114
begingroup " Testing MINIMAL foreign architecture $MIRI_TEST_TARGET : only testing $@ "
114
115
else
115
116
echo " run_tests_minimal requires MIRI_TEST_TARGET to be set"
@@ -126,38 +127,49 @@ function run_tests_minimal {
126
127
127
128
# # Main Testing Logic ##
128
129
129
- # Host target.
130
- run_tests
131
-
132
- # Extra targets.
133
130
# In particular, fully cover all tier 1 targets.
134
131
case $HOST_TARGET in
135
132
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
136
136
MIRI_TEST_TARGET=i686-unknown-linux-gnu run_tests
137
137
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
139
139
MIRI_TEST_TARGET=i686-pc-windows-gnu run_tests
140
140
MIRI_TEST_TARGET=x86_64-pc-windows-gnu run_tests
141
+ # Extra tier 2
142
+ MIRI_TEST_TARGET=aarch64-apple-darwin run_tests
141
143
MIRI_TEST_TARGET=arm-unknown-linux-gnueabi run_tests
142
- # Some targets are only partially supported.
144
+ # Partially supported targets (tier 2)
143
145
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
144
146
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
-
146
147
MIRI_TEST_TARGET=aarch64-linux-android run_tests_minimal hello integer vec panic/panic
147
148
MIRI_TEST_TARGET=wasm32-wasi run_tests_minimal no_std integer strings wasm
148
149
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
151
153
;;
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
153
160
MIRI_TEST_TARGET=s390x-unknown-linux-gnu run_tests # big-endian architecture
154
- MIRI_TEST_TARGET=x86_64-pc-windows-msvc run_tests
155
161
;;
156
162
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.
157
169
MIRI_TEST_TARGET=x86_64-unknown-linux-gnu run_tests
158
170
;;
159
171
* )
160
- echo " FATAL: unknown OS "
172
+ echo " FATAL: unknown host target: $HOST_TARGET "
161
173
exit 1
162
174
;;
163
175
esac
0 commit comments