Run more tests with Miri

This commit is contained in:
Taiki Endo 2022-07-22 00:27:01 +09:00
parent 9de877f9e0
commit 434e8e9b2d
3 changed files with 21 additions and 32 deletions

View File

@ -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::<usize>::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);

View File

@ -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::<usize>::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);

View File

@ -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::<usize>::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);