From 434e8e9b2d7006747d2e96a586ed4792ab0c0582 Mon Sep 17 00:00:00 2001 From: Taiki Endo Date: Fri, 22 Jul 2022 00:27:01 +0900 Subject: [PATCH] Run more tests with Miri --- tests/bounded.rs | 22 ++++++++-------------- tests/single.rs | 17 ++++++----------- tests/unbounded.rs | 14 +++++++------- 3 files changed, 21 insertions(+), 32 deletions(-) diff --git a/tests/bounded.rs b/tests/bounded.rs index 7311bce..78697e3 100644 --- a/tests/bounded.rs +++ b/tests/bounded.rs @@ -58,11 +58,10 @@ fn len_empty_full() { assert_eq!(q.is_full(), false); } -#[cfg_attr(miri, ignore)] // Miri is too slow #[test] fn len() { - const COUNT: usize = 25_000; - const CAP: usize = 1000; + const COUNT: usize = if cfg!(miri) { 50 } else { 25_000 }; + const CAP: usize = if cfg!(miri) { 50 } else { 1000 }; let q = ConcurrentQueue::bounded(CAP); assert_eq!(q.len(), 0); @@ -131,10 +130,9 @@ fn close() { assert_eq!(q.pop(), Err(PopError::Closed)); } -#[cfg_attr(miri, ignore)] // Miri is too slow #[test] fn spsc() { - const COUNT: usize = 100_000; + const COUNT: usize = if cfg!(miri) { 100 } else { 100_000 }; let q = ConcurrentQueue::bounded(3); @@ -158,10 +156,9 @@ fn spsc() { .run(); } -#[cfg_attr(miri, ignore)] // Miri is too slow #[test] fn mpmc() { - const COUNT: usize = 25_000; + const COUNT: usize = if cfg!(miri) { 100 } else { 25_000 }; const THREADS: usize = 4; let q = ConcurrentQueue::::bounded(3); @@ -190,10 +187,10 @@ fn mpmc() { } } -#[cfg_attr(miri, ignore)] // Miri is too slow #[test] fn drops() { - const RUNS: usize = 100; + const RUNS: usize = if cfg!(miri) { 10 } else { 100 }; + const STEPS: usize = if cfg!(miri) { 100 } else { 10_000 }; static DROPS: AtomicUsize = AtomicUsize::new(0); @@ -207,7 +204,7 @@ fn drops() { } for _ in 0..RUNS { - let steps = fastrand::usize(..10_000); + let steps = fastrand::usize(..STEPS); let additional = fastrand::usize(..50); DROPS.store(0, Ordering::SeqCst); @@ -240,10 +237,7 @@ fn drops() { #[test] fn linearizable() { - #[cfg(miri)] - const COUNT: usize = 500; - #[cfg(not(miri))] - const COUNT: usize = 25_000; + const COUNT: usize = if cfg!(miri) { 500 } else { 25_000 }; const THREADS: usize = 4; let q = ConcurrentQueue::bounded(THREADS); diff --git a/tests/single.rs b/tests/single.rs index 261d537..9ebafd9 100644 --- a/tests/single.rs +++ b/tests/single.rs @@ -60,10 +60,9 @@ fn close() { assert_eq!(q.pop(), Err(PopError::Closed)); } -#[cfg_attr(miri, ignore)] // Miri is too slow #[test] fn spsc() { - const COUNT: usize = 100_000; + const COUNT: usize = if cfg!(miri) { 100 } else { 100_000 }; let q = ConcurrentQueue::bounded(1); @@ -87,10 +86,9 @@ fn spsc() { .run(); } -#[cfg_attr(miri, ignore)] // Miri is too slow #[test] fn mpmc() { - const COUNT: usize = 25_000; + const COUNT: usize = if cfg!(miri) { 100 } else { 25_000 }; const THREADS: usize = 1; let q = ConcurrentQueue::::bounded(THREADS); @@ -119,10 +117,10 @@ fn mpmc() { } } -#[cfg_attr(miri, ignore)] // Miri is too slow #[test] fn drops() { - const RUNS: usize = 100; + const RUNS: usize = if cfg!(miri) { 20 } else { 100 }; + const STEPS: usize = if cfg!(miri) { 100 } else { 10_000 }; static DROPS: AtomicUsize = AtomicUsize::new(0); @@ -136,7 +134,7 @@ fn drops() { } for _ in 0..RUNS { - let steps = fastrand::usize(..10_000); + let steps = fastrand::usize(..STEPS); let additional = fastrand::usize(0..=1); DROPS.store(0, Ordering::SeqCst); @@ -169,10 +167,7 @@ fn drops() { #[test] fn linearizable() { - #[cfg(miri)] - const COUNT: usize = 500; - #[cfg(not(miri))] - const COUNT: usize = 25_000; + const COUNT: usize = if cfg!(miri) { 500 } else { 25_000 }; const THREADS: usize = 4; let q = ConcurrentQueue::bounded(1); diff --git a/tests/unbounded.rs b/tests/unbounded.rs index f7efa5a..3ced777 100644 --- a/tests/unbounded.rs +++ b/tests/unbounded.rs @@ -69,10 +69,9 @@ fn close() { assert_eq!(q.pop(), Err(PopError::Closed)); } -#[cfg_attr(miri, ignore)] // Miri is too slow #[test] fn spsc() { - const COUNT: usize = 100_000; + const COUNT: usize = if cfg!(miri) { 100 } else { 100_000 }; let q = ConcurrentQueue::unbounded(); @@ -96,10 +95,9 @@ fn spsc() { .run(); } -#[cfg_attr(miri, ignore)] // Miri is too slow #[test] fn mpmc() { - const COUNT: usize = 25_000; + const COUNT: usize = if cfg!(miri) { 100 } else { 25_000 }; const THREADS: usize = 4; let q = ConcurrentQueue::::unbounded(); @@ -128,9 +126,11 @@ fn mpmc() { } } -#[cfg_attr(miri, ignore)] // Miri is too slow #[test] fn drops() { + const RUNS: usize = if cfg!(miri) { 20 } else { 100 }; + const STEPS: usize = if cfg!(miri) { 100 } else { 10_000 }; + static DROPS: AtomicUsize = AtomicUsize::new(0); #[derive(Debug, PartialEq)] @@ -142,8 +142,8 @@ fn drops() { } } - for _ in 0..100 { - let steps = fastrand::usize(0..10_000); + for _ in 0..RUNS { + let steps = fastrand::usize(0..STEPS); let additional = fastrand::usize(0..1000); DROPS.store(0, Ordering::SeqCst);