Skip to content

Commit 7d09313

Browse files
committed
add './miri many-seeds', and respect MIRIFLAGS in './miri run'
1 parent a1fabb9 commit 7d09313

File tree

1 file changed

+21
-5
lines changed

1 file changed

+21
-5
lines changed

miri

Lines changed: 21 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ to the final `cargo test` invocation.
2020
2121
./miri run <flags>:
2222
Build miri, set up a sysroot and then run the driver with the given <flags>.
23+
(Also respects MIRIFLAGS environment variable.)
2324
2425
The commands above also exist in a "-debug" variant (e.g. "./miri run-debug
2526
<flags>") which uses debug builds instead of release builds, for faster build
@@ -31,6 +32,11 @@ Format all sources and tests. <flags> are passed to `rustfmt`.
3132
./miri clippy <flags>:
3233
Format all sources and tests. <flags> are passed to `cargo clippy`.
3334
35+
./miri many-seeds <command>:
36+
Runs <command> over and over again with different seeds for Miri. The MIRIFLAGS
37+
variable is set to its original value appended with ` -Zmiri-seed=$SEED` for
38+
many different seeds.
39+
3440
ENVIRONMENT VARIABLES
3541
3642
MIRI_SYSROOT:
@@ -41,6 +47,20 @@ Pass extra flags to all cargo invocations.
4147
EOF
4248
)
4349

50+
# Determine command.
51+
COMMAND="$1"
52+
[ $# -gt 0 ] && shift
53+
54+
## Handle some commands early, since they should *not* alter the environment.
55+
case "$COMMAND" in
56+
many-seeds)
57+
for SEED in $({ echo obase=16; seq 0 255; } | bc); do
58+
MIRIFLAGS="$MIRIFLAGS -Zmiri-seed=$SEED" $@ || { echo "Failing seed: $SEED"; break; }
59+
done
60+
exit 0
61+
;;
62+
esac
63+
4464
## Preparation
4565
# macOS does not have a useful readlink/realpath so we have to use Python instead...
4666
MIRIDIR=$(dirname "$(python3 -c 'import os, sys; print(os.path.realpath(sys.argv[1]))' "$0")")
@@ -99,10 +119,6 @@ find_sysroot() {
99119

100120
## Main
101121

102-
# Determine command.
103-
COMMAND="$1"
104-
[ $# -gt 0 ] && shift
105-
106122
# Determine flags passed to all cargo invocations.
107123
# This is a bit more annoying that one would hope due to
108124
# <https://github.com/rust-lang/cargo/issues/6992>.
@@ -166,7 +182,7 @@ run|run-debug)
166182
$CARGO build $CARGO_BUILD_FLAGS --manifest-path "$MIRIDIR"/Cargo.toml
167183
find_sysroot
168184
# Then run the actual command.
169-
exec $CARGO run $CARGO_BUILD_FLAGS --manifest-path "$MIRIDIR"/Cargo.toml -- --sysroot "$MIRI_SYSROOT" "$@"
185+
exec $CARGO run $CARGO_BUILD_FLAGS --manifest-path "$MIRIDIR"/Cargo.toml -- --sysroot "$MIRI_SYSROOT" $MIRIFLAGS "$@"
170186
;;
171187
fmt)
172188
find "$MIRIDIR" -not \( -name target -prune \) -name '*.rs' \

0 commit comments

Comments
 (0)