Skip to content

Commit

Permalink
add test for concurrent env var access
Browse files Browse the repository at this point in the history
  • Loading branch information
RalfJung committed Apr 26, 2024
1 parent ec28d38 commit 0c35628
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions tests/pass/shims/env/var.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
use std::env;
use std::thread;

fn main() {
// Test that miri environment is isolated when communication is disabled.
Expand All @@ -23,4 +24,11 @@ fn main() {
env::remove_var("MIRI_TEST");
assert_eq!(env::var("MIRI_TEST"), Err(env::VarError::NotPresent));
println!("{:#?}", env::vars().collect::<Vec<_>>());

// Do things concurrently, to make sure there's no data race.
let t = thread::spawn(|| {
env::set_var("MIRI_TEST", "42");
});
env::set_var("MIRI_TEST", "42");
t.join().unwrap();
}

0 comments on commit 0c35628

Please sign in to comment.