about summary refs log tree commit diff
path: root/src/liballoc/sync
diff options
context:
space:
mode:
authorRalf Jung <post@ralfj.de>2020-05-03 12:34:53 +0200
committerRalf Jung <post@ralfj.de>2020-05-11 16:49:36 +0200
commit7bea58eeac3a5a5280810623f06eadb3a8b891a3 (patch)
treef1d82de1546df9250ff2441903539509628aecdf /src/liballoc/sync
parentc66d02e3ba0d5ace4e42bab88e4df246f03b91d5 (diff)
downloadrust-7bea58eeac3a5a5280810623f06eadb3a8b891a3.tar.gz
rust-7bea58eeac3a5a5280810623f06eadb3a8b891a3.zip
fix test_weak_count_locked for Miri
Diffstat (limited to 'src/liballoc/sync')
-rw-r--r--src/liballoc/sync/tests.rs6
1 files changed, 5 insertions, 1 deletions
diff --git a/src/liballoc/sync/tests.rs b/src/liballoc/sync/tests.rs
index 4a5cc9aa591..a2bb651e2b7 100644
--- a/src/liballoc/sync/tests.rs
+++ b/src/liballoc/sync/tests.rs
@@ -340,7 +340,9 @@ fn test_weak_count_locked() {
     let mut a = Arc::new(atomic::AtomicBool::new(false));
     let a2 = a.clone();
     let t = thread::spawn(move || {
-        for _i in 0..1000000 {
+        // Miri is too slow
+        let count = if cfg!(miri) { 1000 } else { 1000000 };
+        for _i in 0..count {
             Arc::get_mut(&mut a);
         }
         a.store(true, SeqCst);
@@ -349,6 +351,8 @@ fn test_weak_count_locked() {
     while !a2.load(SeqCst) {
         let n = Arc::weak_count(&a2);
         assert!(n < 2, "bad weak count: {}", n);
+        #[cfg(miri)] // Miri's scheduler does not guarantee liveness, and thus needs this hint.
+        atomic::spin_loop_hint();
     }
     t.join().unwrap();
 }