mirror of
https://github.com/rust-lang/rust.git
synced 2024-10-30 22:12:15 +00:00
Add data race test to std::env::{get, set}
This commit is contained in:
parent
def52ba2b8
commit
f8a2f31ae4
@ -5,6 +5,7 @@ use rand::distributions::{Alphanumeric, DistString};
|
||||
|
||||
mod common;
|
||||
use common::test_rng;
|
||||
use std::thread;
|
||||
|
||||
#[track_caller]
|
||||
fn make_rand_name() -> OsString {
|
||||
@ -140,3 +141,22 @@ fn env_home_dir() {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[test] // miri shouldn't detect any data race in this fn
|
||||
#[cfg_attr(any(not(miri), target_os = "emscripten"), ignore)]
|
||||
fn test_env_get_set_multithreaded() {
|
||||
let getter = thread::spawn(|| {
|
||||
for _ in 0..100 {
|
||||
let _ = var_os("foo");
|
||||
}
|
||||
});
|
||||
|
||||
let setter = thread::spawn(|| {
|
||||
for _ in 0..100 {
|
||||
set_var("foo", "bar");
|
||||
}
|
||||
});
|
||||
|
||||
let _ = getter.join();
|
||||
let _ = setter.join();
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user