diff options
| author | Ralf Jung <post@ralfj.de> | 2024-04-26 19:44:38 +0200 |
|---|---|---|
| committer | Ralf Jung <post@ralfj.de> | 2024-04-26 19:47:35 +0200 |
| commit | 26af88acedde5d33b2868cac32b800e269bd38ac (patch) | |
| tree | a5426a89e18181a30b5d60d7cd0016aa05a81796 | |
| parent | d7c89cfbf8b78dde0f2b81e5ca85917eabcd35e8 (diff) | |
| download | rust-26af88acedde5d33b2868cac32b800e269bd38ac.tar.gz rust-26af88acedde5d33b2868cac32b800e269bd38ac.zip | |
add test for concurrent env var access
| -rw-r--r-- | src/tools/miri/tests/pass/shims/env/var.rs | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/src/tools/miri/tests/pass/shims/env/var.rs b/src/tools/miri/tests/pass/shims/env/var.rs index 23a3724ff7f..babaf00578a 100644 --- a/src/tools/miri/tests/pass/shims/env/var.rs +++ b/src/tools/miri/tests/pass/shims/env/var.rs @@ -1,4 +1,5 @@ use std::env; +use std::thread; fn main() { // Test that miri environment is isolated when communication is disabled. @@ -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(); } |
