diff --git a/crossbeam-channel/tests/after.rs b/crossbeam-channel/tests/after.rs index 20670dc5a..7756a4486 100644 --- a/crossbeam-channel/tests/after.rs +++ b/crossbeam-channel/tests/after.rs @@ -1,4 +1,5 @@ //! Tests for the after channel flavor. +#![cfg(not(miri))] // todo use std::sync::atomic::AtomicUsize; use std::sync::atomic::Ordering; diff --git a/crossbeam-channel/tests/array.rs b/crossbeam-channel/tests/array.rs index a7ae323d9..4d682a10a 100644 --- a/crossbeam-channel/tests/array.rs +++ b/crossbeam-channel/tests/array.rs @@ -1,4 +1,5 @@ //! Tests for the array channel flavor. +#![cfg(not(miri))] // todo use std::any::Any; use std::sync::atomic::AtomicUsize; diff --git a/crossbeam-channel/tests/golang.rs b/crossbeam-channel/tests/golang.rs index 69a9315a0..daaa241f4 100644 --- a/crossbeam-channel/tests/golang.rs +++ b/crossbeam-channel/tests/golang.rs @@ -9,6 +9,8 @@ //! - https://golang.org/LICENSE //! - https://golang.org/PATENTS +#![cfg(not(miri))] // todo + use std::alloc::{GlobalAlloc, Layout, System}; use std::any::Any; use std::cell::Cell; diff --git a/crossbeam-channel/tests/iter.rs b/crossbeam-channel/tests/iter.rs index 38bcac2f0..7fdbde9da 100644 --- a/crossbeam-channel/tests/iter.rs +++ b/crossbeam-channel/tests/iter.rs @@ -54,6 +54,7 @@ fn recv_iter_break() { .unwrap(); } +#[cfg_attr(miri, ignore)] // todo #[test] fn recv_try_iter() { let (request_s, request_r) = unbounded(); diff --git a/crossbeam-channel/tests/list.rs b/crossbeam-channel/tests/list.rs index 8b8410540..5d9b926b2 100644 --- a/crossbeam-channel/tests/list.rs +++ b/crossbeam-channel/tests/list.rs @@ -239,6 +239,9 @@ fn disconnect_wakes_receiver() { #[test] fn spsc() { + #[cfg(miri)] + const COUNT: usize = 500; + #[cfg(not(miri))] const COUNT: usize = 100_000; let (s, r) = unbounded(); @@ -261,6 +264,9 @@ fn spsc() { #[test] fn mpmc() { + #[cfg(miri)] + const COUNT: usize = 500; + #[cfg(not(miri))] const COUNT: usize = 25_000; const THREADS: usize = 4; @@ -295,6 +301,9 @@ fn mpmc() { #[test] fn stress_oneshot() { + #[cfg(miri)] + const COUNT: usize = 500; + #[cfg(not(miri))] const COUNT: usize = 10_000; for _ in 0..COUNT { @@ -308,6 +317,7 @@ fn stress_oneshot() { } } +#[cfg_attr(miri, ignore)] // todo #[test] fn stress_iter() { const COUNT: usize = 100_000; @@ -371,6 +381,7 @@ fn stress_timeout_two_threads() { .unwrap(); } +#[cfg_attr(miri, ignore)] // todo #[test] fn drops() { static DROPS: AtomicUsize = AtomicUsize::new(0); @@ -421,6 +432,9 @@ fn drops() { #[test] fn linearizable() { + #[cfg(miri)] + const COUNT: usize = 500; + #[cfg(not(miri))] const COUNT: usize = 25_000; const THREADS: usize = 4; @@ -441,6 +455,9 @@ fn linearizable() { #[test] fn fairness() { + #[cfg(miri)] + const COUNT: usize = 500; + #[cfg(not(miri))] const COUNT: usize = 10_000; let (s1, r1) = unbounded::<()>(); @@ -463,6 +480,9 @@ fn fairness() { #[test] fn fairness_duplicates() { + #[cfg(miri)] + const COUNT: usize = 500; + #[cfg(not(miri))] const COUNT: usize = 10_000; let (s, r) = unbounded(); diff --git a/crossbeam-channel/tests/mpsc.rs b/crossbeam-channel/tests/mpsc.rs index 2a0786a71..b07144e58 100644 --- a/crossbeam-channel/tests/mpsc.rs +++ b/crossbeam-channel/tests/mpsc.rs @@ -264,6 +264,7 @@ mod channel_tests { assert!(tx2.send(1).is_err()); } + #[cfg_attr(miri, ignore)] //todo #[test] fn port_gone_concurrent() { let (tx, rx) = channel::(); @@ -274,6 +275,7 @@ mod channel_tests { t.join().unwrap(); } + #[cfg_attr(miri, ignore)] //todo #[test] fn port_gone_concurrent_shared() { let (tx, rx) = channel::(); @@ -314,13 +316,18 @@ mod channel_tests { #[test] fn stress() { + #[cfg(miri)] + const COUNT: usize = 500; + #[cfg(not(miri))] + const COUNT: usize = 10000; + let (tx, rx) = channel::(); let t = thread::spawn(move || { - for _ in 0..10000 { + for _ in 0..COUNT { tx.send(1).unwrap(); } }); - for _ in 0..10000 { + for _ in 0..COUNT { assert_eq!(rx.recv().unwrap(), 1); } t.join().ok().unwrap(); @@ -328,6 +335,9 @@ mod channel_tests { #[test] fn stress_shared() { + #[cfg(miri)] + const AMT: u32 = 500; + #[cfg(not(miri))] const AMT: u32 = 10000; const NTHREADS: u32 = 8; let (tx, rx) = channel::(); @@ -735,12 +745,16 @@ mod channel_tests { #[test] fn recv_a_lot() { + #[cfg(miri)] + const COUNT: usize = 500; + #[cfg(not(miri))] + const COUNT: usize = 10000; // Regression test that we don't run out of stack in scheduler context let (tx, rx) = channel(); - for _ in 0..10000 { + for _ in 0..COUNT { tx.send(()).unwrap(); } - for _ in 0..10000 { + for _ in 0..COUNT { rx.recv().unwrap(); } } @@ -841,6 +855,7 @@ mod channel_tests { t.join().unwrap(); } + #[cfg_attr(miri, ignore)] #[test] fn test_recv_try_iter() { let (request_tx, request_rx) = channel(); @@ -955,6 +970,7 @@ mod channel_tests { } // Source: https://github.com/rust-lang/rust/blob/master/src/libstd/sync/mpsc/mod.rs +#[cfg(not(miri))] // unsupported operation: the main thread terminated without waiting for other threads mod sync_channel_tests { use super::*; @@ -1079,13 +1095,15 @@ mod sync_channel_tests { #[test] fn stress() { + const COUNT: usize = 10000; + let (tx, rx) = sync_channel::(0); let t = thread::spawn(move || { - for _ in 0..10000 { + for _ in 0..COUNT { tx.send(1).unwrap(); } }); - for _ in 0..10000 { + for _ in 0..COUNT { assert_eq!(rx.recv().unwrap(), 1); } t.join().unwrap(); @@ -1093,10 +1111,12 @@ mod sync_channel_tests { #[test] fn stress_recv_timeout_two_threads() { + const COUNT: usize = 10000; + let (tx, rx) = sync_channel::(0); let t = thread::spawn(move || { - for _ in 0..10000 { + for _ in 0..COUNT { tx.send(1).unwrap(); } }); @@ -1113,7 +1133,7 @@ mod sync_channel_tests { } } - assert_eq!(recv_count, 10000); + assert_eq!(recv_count, COUNT); t.join().unwrap(); } @@ -1449,12 +1469,14 @@ mod sync_channel_tests { #[test] fn recv_a_lot() { + const COUNT: usize = 10000; + // Regression test that we don't run out of stack in scheduler context - let (tx, rx) = sync_channel(10000); - for _ in 0..10000 { + let (tx, rx) = sync_channel(COUNT); + for _ in 0..COUNT { tx.send(()).unwrap(); } - for _ in 0..10000 { + for _ in 0..COUNT { rx.recv().unwrap(); } } @@ -1792,6 +1814,9 @@ mod select_tests { #[test] fn stress() { + #[cfg(miri)] + const AMT: i32 = 500; + #[cfg(not(miri))] const AMT: i32 = 10000; let (tx1, rx1) = channel::(); let (tx2, rx2) = channel::(); diff --git a/crossbeam-channel/tests/ready.rs b/crossbeam-channel/tests/ready.rs index 700f487e0..19a1fe31f 100644 --- a/crossbeam-channel/tests/ready.rs +++ b/crossbeam-channel/tests/ready.rs @@ -490,6 +490,9 @@ fn nesting() { #[test] fn stress_recv() { + #[cfg(miri)] + const COUNT: usize = 500; + #[cfg(not(miri))] const COUNT: usize = 10_000; let (s1, r1) = unbounded(); @@ -527,6 +530,9 @@ fn stress_recv() { #[test] fn stress_send() { + #[cfg(miri)] + const COUNT: usize = 500; + #[cfg(not(miri))] const COUNT: usize = 10_000; let (s1, r1) = bounded(0); @@ -561,6 +567,9 @@ fn stress_send() { #[test] fn stress_mixed() { + #[cfg(miri)] + const COUNT: usize = 500; + #[cfg(not(miri))] const COUNT: usize = 10_000; let (s1, r1) = bounded(0); @@ -724,6 +733,9 @@ fn channel_through_channel() { #[test] fn fairness1() { + #[cfg(miri)] + const COUNT: usize = 500; + #[cfg(not(miri))] const COUNT: usize = 10_000; let (s1, r1) = bounded::<()>(COUNT); @@ -769,6 +781,9 @@ fn fairness1() { #[test] fn fairness2() { + #[cfg(miri)] + const COUNT: usize = 500; + #[cfg(not(miri))] const COUNT: usize = 100_000; let (s1, r1) = unbounded::<()>(); diff --git a/crossbeam-channel/tests/select.rs b/crossbeam-channel/tests/select.rs index 4cf08b6a6..51f8ea558 100644 --- a/crossbeam-channel/tests/select.rs +++ b/crossbeam-channel/tests/select.rs @@ -406,6 +406,7 @@ fn both_ready() { .unwrap(); } +#[cfg_attr(miri, ignore)] #[test] fn loop_try() { const RUNS: usize = 20; @@ -690,6 +691,9 @@ fn nesting() { #[test] fn stress_recv() { + #[cfg(miri)] + const COUNT: usize = 500; + #[cfg(not(miri))] const COUNT: usize = 10_000; let (s1, r1) = unbounded(); @@ -728,6 +732,9 @@ fn stress_recv() { #[test] fn stress_send() { + #[cfg(miri)] + const COUNT: usize = 500; + #[cfg(not(miri))] const COUNT: usize = 10_000; let (s1, r1) = bounded(0); @@ -763,6 +770,9 @@ fn stress_send() { #[test] fn stress_mixed() { + #[cfg(miri)] + const COUNT: usize = 500; + #[cfg(not(miri))] const COUNT: usize = 10_000; let (s1, r1) = bounded(0); @@ -1000,6 +1010,9 @@ fn channel_through_channel() { #[test] fn linearizable_try() { + #[cfg(miri)] + const COUNT: usize = 500; + #[cfg(not(miri))] const COUNT: usize = 100_000; for step in 0..2 { @@ -1052,6 +1065,9 @@ fn linearizable_try() { #[test] fn linearizable_timeout() { + #[cfg(miri)] + const COUNT: usize = 500; + #[cfg(not(miri))] const COUNT: usize = 100_000; for step in 0..2 { @@ -1104,6 +1120,9 @@ fn linearizable_timeout() { #[test] fn fairness1() { + #[cfg(miri)] + const COUNT: usize = 500; + #[cfg(not(miri))] const COUNT: usize = 10_000; let (s1, r1) = bounded::<()>(COUNT); @@ -1150,6 +1169,9 @@ fn fairness1() { #[test] fn fairness2() { + #[cfg(miri)] + const COUNT: usize = 500; + #[cfg(not(miri))] const COUNT: usize = 10_000; let (s1, r1) = unbounded::<()>(); @@ -1266,6 +1288,9 @@ fn send_and_clone() { #[test] fn reuse() { + #[cfg(miri)] + const COUNT: usize = 500; + #[cfg(not(miri))] const COUNT: usize = 10_000; let (s1, r1) = bounded(0); diff --git a/crossbeam-channel/tests/select_macro.rs b/crossbeam-channel/tests/select_macro.rs index c05f7a0e6..a9e0604c0 100644 --- a/crossbeam-channel/tests/select_macro.rs +++ b/crossbeam-channel/tests/select_macro.rs @@ -283,6 +283,7 @@ fn both_ready() { .unwrap(); } +#[cfg_attr(miri, ignore)] #[test] fn loop_try() { const RUNS: usize = 20; @@ -485,6 +486,9 @@ fn panic_receiver() { #[test] fn stress_recv() { + #[cfg(miri)] + const COUNT: usize = 500; + #[cfg(not(miri))] const COUNT: usize = 10_000; let (s1, r1) = unbounded(); @@ -518,6 +522,9 @@ fn stress_recv() { #[test] fn stress_send() { + #[cfg(miri)] + const COUNT: usize = 500; + #[cfg(not(miri))] const COUNT: usize = 10_000; let (s1, r1) = bounded(0); @@ -548,6 +555,9 @@ fn stress_send() { #[test] fn stress_mixed() { + #[cfg(miri)] + const COUNT: usize = 500; + #[cfg(not(miri))] const COUNT: usize = 10_000; let (s1, r1) = bounded(0); @@ -726,6 +736,9 @@ fn channel_through_channel() { #[test] fn linearizable_default() { + #[cfg(miri)] + const COUNT: usize = 500; + #[cfg(not(miri))] const COUNT: usize = 100_000; for step in 0..2 { @@ -770,6 +783,9 @@ fn linearizable_default() { #[test] fn linearizable_timeout() { + #[cfg(miri)] + const COUNT: usize = 500; + #[cfg(not(miri))] const COUNT: usize = 100_000; for step in 0..2 { @@ -814,6 +830,9 @@ fn linearizable_timeout() { #[test] fn fairness1() { + #[cfg(miri)] + const COUNT: usize = 500; + #[cfg(not(miri))] const COUNT: usize = 10_000; let (s1, r1) = bounded::<()>(COUNT); @@ -838,6 +857,9 @@ fn fairness1() { #[test] fn fairness2() { + #[cfg(miri)] + const COUNT: usize = 500; + #[cfg(not(miri))] const COUNT: usize = 10_000; let (s1, r1) = unbounded::<()>(); @@ -875,6 +897,9 @@ fn fairness2() { #[test] fn fairness_recv() { + #[cfg(miri)] + const COUNT: usize = 500; + #[cfg(not(miri))] const COUNT: usize = 10_000; let (s1, r1) = bounded::<()>(COUNT); @@ -897,6 +922,9 @@ fn fairness_recv() { #[test] fn fairness_send() { + #[cfg(miri)] + const COUNT: usize = 500; + #[cfg(not(miri))] const COUNT: usize = 10_000; let (s1, _r1) = bounded::<()>(COUNT); diff --git a/crossbeam-channel/tests/tick.rs b/crossbeam-channel/tests/tick.rs index 5dc87306f..3d3eee790 100644 --- a/crossbeam-channel/tests/tick.rs +++ b/crossbeam-channel/tests/tick.rs @@ -1,4 +1,5 @@ //! Tests for the tick channel flavor. +#![cfg(not(miri))] use std::sync::atomic::AtomicUsize; use std::sync::atomic::Ordering; diff --git a/crossbeam-channel/tests/zero.rs b/crossbeam-channel/tests/zero.rs index 66dcc1eeb..baea5e8ed 100644 --- a/crossbeam-channel/tests/zero.rs +++ b/crossbeam-channel/tests/zero.rs @@ -187,6 +187,9 @@ fn send_timeout() { #[test] fn len() { + #[cfg(miri)] + const COUNT: usize = 500; + #[cfg(not(miri))] const COUNT: usize = 25_000; let (s, r) = bounded(0); @@ -249,6 +252,9 @@ fn disconnect_wakes_receiver() { #[test] fn spsc() { + #[cfg(miri)] + const COUNT: usize = 500; + #[cfg(not(miri))] const COUNT: usize = 100_000; let (s, r) = bounded(0); @@ -271,6 +277,9 @@ fn spsc() { #[test] fn mpmc() { + #[cfg(miri)] + const COUNT: usize = 500; + #[cfg(not(miri))] const COUNT: usize = 25_000; const THREADS: usize = 4; @@ -303,6 +312,9 @@ fn mpmc() { #[test] fn stress_oneshot() { + #[cfg(miri)] + const COUNT: usize = 500; + #[cfg(not(miri))] const COUNT: usize = 10_000; for _ in 0..COUNT { @@ -316,6 +328,7 @@ fn stress_oneshot() { } } +#[cfg_attr(miri, ignore)] #[test] fn stress_iter() { const COUNT: usize = 1000; @@ -383,6 +396,7 @@ fn stress_timeout_two_threads() { .unwrap(); } +#[cfg_attr(miri, ignore)] #[test] fn drops() { static DROPS: AtomicUsize = AtomicUsize::new(0); @@ -428,6 +442,9 @@ fn drops() { #[test] fn fairness() { + #[cfg(miri)] + const COUNT: usize = 500; + #[cfg(not(miri))] const COUNT: usize = 10_000; let (s1, r1) = bounded::<()>(0); @@ -459,6 +476,9 @@ fn fairness() { #[test] fn fairness_duplicates() { + #[cfg(miri)] + const COUNT: usize = 500; + #[cfg(not(miri))] const COUNT: usize = 10_000; let (s, r) = bounded::<()>(0);