make env/var test deterministic

This commit is contained in:
Ralf Jung 2024-05-30 09:05:03 +02:00
parent a200d38ce9
commit daeb68a579

View File

@ -1,3 +1,4 @@
//@compile-flags: -Zmiri-preemption-rate=0
use std::env; use std::env;
use std::thread; use std::thread;
@ -26,6 +27,8 @@ fn main() {
println!("{:#?}", env::vars().collect::<Vec<_>>()); println!("{:#?}", env::vars().collect::<Vec<_>>());
// Do things concurrently, to make sure there's no data race. // Do things concurrently, to make sure there's no data race.
// We disable preemption to make sure the lock is not contended;
// that means we don't hit e.g. the futex codepath on Android (which we don't support).
let t = thread::spawn(|| { let t = thread::spawn(|| {
env::set_var("MIRI_TEST", "42"); env::set_var("MIRI_TEST", "42");
}); });