add some Miri-only tests

This commit is contained in:
Ralf Jung
2022-08-04 09:01:00 -04:00
parent ac66baad1a
commit 27b0444333
2 changed files with 38 additions and 0 deletions

View File

@@ -329,3 +329,22 @@ fn test_scoped_threads_nll() {
let x = 42_u8;
foo(&x);
}
// Regression test for https://github.com/rust-lang/rust/issues/98498.
#[test]
#[cfg(miri)] // relies on Miri's data race detector
fn scope_join_race() {
for _ in 0..100 {
let a_bool = AtomicBool::new(false);
thread::scope(|s| {
for _ in 0..5 {
s.spawn(|| a_bool.load(Ordering::Relaxed));
}
for _ in 0..5 {
s.spawn(|| a_bool.load(Ordering::Relaxed));
}
});
}
}