about summary refs log tree commit diff
path: root/src/liballoc/sync/tests.rs
diff options
context:
space:
mode:
authorcsmoe <csmoe@msn.com>2020-05-18 08:46:24 +0800
committercsmoe <csmoe@msn.com>2020-05-19 11:02:29 +0800
commit2f311b07c8d95b1192e585e983535de89bcbdfaa (patch)
tree0e12c995dfdd9352eaa61d542c6f604aca23b456 /src/liballoc/sync/tests.rs
parent8841ede3648b5f12284dae850ec065374fd3af46 (diff)
parentd79f1bd31a1401b5d08096fcdf9a9eb23ddf95df (diff)
downloadrust-2f311b07c8d95b1192e585e983535de89bcbdfaa.tar.gz
rust-2f311b07c8d95b1192e585e983535de89bcbdfaa.zip
Merge branch 'master' into issue-69276
Diffstat (limited to 'src/liballoc/sync/tests.rs')
-rw-r--r--src/liballoc/sync/tests.rs8
1 files changed, 5 insertions, 3 deletions
diff --git a/src/liballoc/sync/tests.rs b/src/liballoc/sync/tests.rs
index edc2820ee22..a2bb651e2b7 100644
--- a/src/liballoc/sync/tests.rs
+++ b/src/liballoc/sync/tests.rs
@@ -32,7 +32,6 @@ impl Drop for Canary {
 
 #[test]
 #[cfg_attr(target_os = "emscripten", ignore)]
-#[cfg_attr(miri, ignore)] // Miri does not support threads
 fn manually_share_arc() {
     let v = vec![1, 2, 3, 4, 5, 6, 7, 8, 9, 10];
     let arc_v = Arc::new(v);
@@ -337,12 +336,13 @@ fn test_ptr_eq() {
 
 #[test]
 #[cfg_attr(target_os = "emscripten", ignore)]
-#[cfg_attr(miri, ignore)] // Miri does not support threads
 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);
@@ -351,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();
 }