@@ -151,6 +151,21 @@ platform. For example `cargo miri test --target s390x-unknown-linux-gnu`
151
151
will run your test suite on a big-endian target, which is useful for testing
152
152
endian-sensitive code.
153
153
154
+ ### Testing multiple different executions
155
+
156
+ Certain parts of the execution are picked randomly by Miri, such as the exact base address
157
+ allocations are stored at and the interleaving of concurrently executing threads. Sometimes, it can
158
+ be useful to explore multiple different execution, e.g. to make sure that your code does not depend
159
+ on incidental "super-alignment" of new allocations and to test different thread interleavings.
160
+ This can be done with the ` --many-seeds ` flag:
161
+
162
+ ```
163
+ cargo miri test --many-seeds # tries the seeds in 0..64
164
+ cargo miri test --many-seeds=0..16
165
+ ```
166
+
167
+ The default of 64 different seeds is quite slow, so you probably want to specify a smaller range.
168
+
154
169
### Running Miri on CI
155
170
156
171
When running Miri on CI, use the following snippet to install a nightly toolchain with the Miri
@@ -183,23 +198,6 @@ Here is an example job for GitHub Actions:
183
198
The explicit ` cargo miri setup` helps to keep the output of the actual test step
184
199
clean.
185
200
186
- # ## Testing for alignment issues
187
-
188
- Miri can sometimes miss misaligned accesses since allocations can "happen to be"
189
- aligned just right. You can use `-Zmiri-symbolic-alignment-check` to definitely
190
- catch all such issues, but that flag will also cause false positives when code
191
- does manual pointer arithmetic to account for alignment. Another alternative is
192
- to call Miri with various values for `-Zmiri-seed`; that will alter the
193
- randomness that is used to determine allocation base addresses. The following
194
- snippet calls Miri in a loop with different values for the seed :
195
-
196
- ` ` `
197
- for SEED in $(seq 0 255); do
198
- echo "Trying seed: $SEED"
199
- MIRIFLAGS=-Zmiri-seed=$SEED cargo miri test || { echo "Failing seed: $SEED"; break; };
200
- done
201
- ` ` `
202
-
203
201
# ## Supported targets
204
202
205
203
Miri does not support all targets supported by Rust. The good news, however, is
0 commit comments