Skip to content

Commit 26af88a

Browse files
committed
add test for concurrent env var access
1 parent d7c89cf commit 26af88a

File tree

1 file changed

+8
-0
lines changed
  • src/tools/miri/tests/pass/shims/env

1 file changed

+8
-0
lines changed

Diff for: src/tools/miri/tests/pass/shims/env/var.rs

+8
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
use std::env;
2+
use std::thread;
23

34
fn main() {
45
// Test that miri environment is isolated when communication is disabled.
@@ -23,4 +24,11 @@ fn main() {
2324
env::remove_var("MIRI_TEST");
2425
assert_eq!(env::var("MIRI_TEST"), Err(env::VarError::NotPresent));
2526
println!("{:#?}", env::vars().collect::<Vec<_>>());
27+
28+
// Do things concurrently, to make sure there's no data race.
29+
let t = thread::spawn(|| {
30+
env::set_var("MIRI_TEST", "42");
31+
});
32+
env::set_var("MIRI_TEST", "42");
33+
t.join().unwrap();
2634
}

0 commit comments

Comments
 (0)