Skip to content

Commit f52f63f

Browse files
committed
./miri many-seeds: support MIRI_SEED_END to control the end of the tried seed range
1 parent 456c69e commit f52f63f

File tree

2 files changed

+14
-7
lines changed

2 files changed

+14
-7
lines changed

miri-script/src/commands.rs

+11-5
Original file line numberDiff line numberDiff line change
@@ -356,11 +356,17 @@ impl Command {
356356
.unwrap_or_else(|_| "0".into())
357357
.parse()
358358
.context("failed to parse MIRI_SEED_START")?;
359-
let seed_count: u64 = env::var("MIRI_SEEDS")
360-
.unwrap_or_else(|_| "256".into())
361-
.parse()
362-
.context("failed to parse MIRI_SEEDS")?;
363-
let seed_end = seed_start + seed_count;
359+
let seed_end: u64 = match (env::var("MIRI_SEEDS"), env::var("MIRI_SEED_END")) {
360+
(Ok(_), Ok(_)) => bail!("Only one of MIRI_SEEDS and MIRI_SEED_END may be set"),
361+
(Ok(seeds), Err(_)) =>
362+
seed_start + seeds.parse::<u64>().context("failed to parse MIRI_SEEDS")?,
363+
(Err(_), Ok(seed_end)) => seed_end.parse().context("failed to parse MIRI_SEED_END")?,
364+
(Err(_), Err(_)) => seed_start + 256,
365+
};
366+
if seed_end <= seed_start {
367+
bail!("the end of the seed range must be larger than the start.");
368+
}
369+
364370
let Some((command_name, trailing_args)) = command.split_first() else {
365371
bail!("expected many-seeds command to be non-empty");
366372
};

miri-script/src/main.rs

+3-2
Original file line numberDiff line numberDiff line change
@@ -113,8 +113,9 @@ sysroot, to prevent conflicts with other toolchains.
113113
./miri many-seeds <command>:
114114
Runs <command> over and over again with different seeds for Miri. The MIRIFLAGS
115115
variable is set to its original value appended with ` -Zmiri-seed=$SEED` for
116-
many different seeds. The MIRI_SEEDS variable controls how many seeds are being
117-
tried; MIRI_SEED_START controls the first seed to try.
116+
many different seeds. MIRI_SEED_START controls the first seed to try (default: 0).
117+
MIRI_SEEDS controls how many seeds are being tried (default: 256);
118+
alternatively, MIRI_SEED_END controls the end of the (exclusive) seed range to try.
118119
119120
./miri bench <benches>:
120121
Runs the benchmarks from bench-cargo-miri in hyperfine. hyperfine needs to be installed.

0 commit comments

Comments
 (0)