Skip to content

Commit

Permalink
reduce some test sizes for Miri
Browse files Browse the repository at this point in the history
  • Loading branch information
RalfJung committed Jun 30, 2022
1 parent 3fe8f27 commit 78bf145
Show file tree
Hide file tree
Showing 6 changed files with 23 additions and 36 deletions.
2 changes: 1 addition & 1 deletion crossbeam-channel/tests/array.rs
Original file line number Diff line number Diff line change
Expand Up @@ -377,7 +377,7 @@ fn spsc() {
#[test]
fn mpmc() {
#[cfg(miri)]
const COUNT: usize = 100;
const COUNT: usize = 50;
#[cfg(not(miri))]
const COUNT: usize = 25_000;
const THREADS: usize = 4;
Expand Down
4 changes: 2 additions & 2 deletions crossbeam-channel/tests/golang.rs
Original file line number Diff line number Diff line change
Expand Up @@ -959,7 +959,7 @@ mod chan_test {
#[test]
fn test_chan() {
#[cfg(miri)]
const N: i32 = 20;
const N: i32 = 12;
#[cfg(not(miri))]
const N: i32 = 200;

Expand Down Expand Up @@ -1489,7 +1489,7 @@ mod chan_test {
fn test_multi_consumer() {
const NWORK: usize = 23;
#[cfg(miri)]
const NITER: usize = 100;
const NITER: usize = 50;
#[cfg(not(miri))]
const NITER: usize = 271828;

Expand Down
15 changes: 6 additions & 9 deletions crossbeam-channel/tests/mpsc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -339,25 +339,22 @@ mod channel_tests {

#[test]
fn stress_shared() {
#[cfg(miri)]
const AMT: u32 = 100;
#[cfg(not(miri))]
const AMT: u32 = 10000;
const NTHREADS: u32 = 8;
let amt: u32 = if cfg!(miri) { 100 } else { 10_000 };
let nthreads: u32 = if cfg!(miri) { 4 } else { 8 };
let (tx, rx) = channel::<i32>();

let t = thread::spawn(move || {
for _ in 0..AMT * NTHREADS {
for _ in 0..amt * nthreads {
assert_eq!(rx.recv().unwrap(), 1);
}
assert!(rx.try_recv().is_err());
});

let mut ts = Vec::with_capacity(NTHREADS as usize);
for _ in 0..NTHREADS {
let mut ts = Vec::with_capacity(nthreads as usize);
for _ in 0..nthreads {
let tx = tx.clone();
let t = thread::spawn(move || {
for _ in 0..AMT {
for _ in 0..amt {
tx.send(1).unwrap();
}
});
Expand Down
2 changes: 1 addition & 1 deletion crossbeam-channel/tests/zero.rs
Original file line number Diff line number Diff line change
Expand Up @@ -403,7 +403,7 @@ fn drops() {
#[cfg(not(miri))]
const RUNS: usize = 100;
#[cfg(miri)]
const STEPS: usize = 500;
const STEPS: usize = 100;
#[cfg(not(miri))]
const STEPS: usize = 10_000;

Expand Down
19 changes: 7 additions & 12 deletions crossbeam-queue/tests/array_queue.rs
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ fn len() {
#[test]
fn spsc() {
#[cfg(miri)]
const COUNT: usize = 100;
const COUNT: usize = 50;
#[cfg(not(miri))]
const COUNT: usize = 100_000;

Expand Down Expand Up @@ -276,14 +276,9 @@ fn mpmc_ring_buffer() {

#[test]
fn drops() {
#[cfg(miri)]
const RUNS: usize = 5;
#[cfg(not(miri))]
const RUNS: usize = 100;
#[cfg(miri)]
const STEPS: usize = 50;
#[cfg(not(miri))]
const STEPS: usize = 10_000;
let runs: usize = if cfg!(miri) { 3 } else { 100 };
let steps: usize = if cfg!(miri) { 50 } else { 10_000 };
let additional: usize = if cfg!(miri) { 10 } else { 50 };

static DROPS: AtomicUsize = AtomicUsize::new(0);

Expand All @@ -298,9 +293,9 @@ fn drops() {

let mut rng = thread_rng();

for _ in 0..RUNS {
let steps = rng.gen_range(0..STEPS);
let additional = rng.gen_range(0..50);
for _ in 0..runs {
let steps = rng.gen_range(0..steps);
let additional = rng.gen_range(0..additional);

DROPS.store(0, Ordering::SeqCst);
let q = ArrayQueue::new(50);
Expand Down
17 changes: 6 additions & 11 deletions crossbeam-queue/tests/seg_queue.rs
Original file line number Diff line number Diff line change
Expand Up @@ -121,14 +121,9 @@ fn mpmc() {

#[test]
fn drops() {
#[cfg(miri)]
const RUNS: usize = 5;
#[cfg(not(miri))]
const RUNS: usize = 100;
#[cfg(miri)]
const STEPS: usize = 50;
#[cfg(not(miri))]
const STEPS: usize = 10_000;
let runs: usize = if cfg!(miri) { 5 } else { 100 };
let steps: usize = if cfg!(miri) { 50 } else { 10_000 };
let additional: usize = if cfg!(miri) { 100 } else { 1_000 };

static DROPS: AtomicUsize = AtomicUsize::new(0);

Expand All @@ -143,9 +138,9 @@ fn drops() {

let mut rng = thread_rng();

for _ in 0..RUNS {
let steps = rng.gen_range(0..STEPS);
let additional = rng.gen_range(0..1000);
for _ in 0..runs {
let steps = rng.gen_range(0..steps);
let additional = rng.gen_range(0..additional);

DROPS.store(0, Ordering::SeqCst);
let q = SegQueue::new();
Expand Down

0 comments on commit 78bf145

Please sign in to comment.