diff --git a/ci/crossbeam-channel.sh b/ci/crossbeam-channel.sh index abe70583a..f9927d15f 100755 --- a/ci/crossbeam-channel.sh +++ b/ci/crossbeam-channel.sh @@ -1,8 +1,10 @@ #!/bin/bash -cd "$(dirname "$0")"/../crossbeam-channel set -ex +script_dir="$(cd "$(dirname "$0")" && pwd)" +cd "$script_dir"/../crossbeam-channel + export RUSTFLAGS="-D warnings" cargo check --bins --examples --tests @@ -11,6 +13,9 @@ cargo test -- --test-threads=1 if [[ "$RUST_VERSION" == "nightly"* ]]; then cd benchmarks cargo check --bins + cd .. RUSTDOCFLAGS=-Dwarnings cargo doc --no-deps --all-features + + "$script_dir"/miri.sh -- -Zmiri-disable-isolation fi diff --git a/ci/crossbeam-deque.sh b/ci/crossbeam-deque.sh index fb53ab88c..4dc2f898b 100755 --- a/ci/crossbeam-deque.sh +++ b/ci/crossbeam-deque.sh @@ -1,8 +1,10 @@ #!/bin/bash -cd "$(dirname "$0")"/../crossbeam-deque set -ex +script_dir="$(cd "$(dirname "$0")" && pwd)" +cd "$script_dir"/../crossbeam-deque + export RUSTFLAGS="-D warnings" cargo check --bins --examples --tests @@ -10,4 +12,7 @@ cargo test if [[ "$RUST_VERSION" == "nightly"* ]]; then RUSTDOCFLAGS=-Dwarnings cargo doc --no-deps --all-features + + # -Zmiri-ignore-leaks is needed for https://github.com/crossbeam-rs/crossbeam/issues/579 + "$script_dir"/miri.sh -- -Zmiri-ignore-leaks fi diff --git a/ci/crossbeam-epoch.sh b/ci/crossbeam-epoch.sh index 995f81c0d..1ca4d18cc 100755 --- a/ci/crossbeam-epoch.sh +++ b/ci/crossbeam-epoch.sh @@ -1,8 +1,10 @@ #!/bin/bash -cd "$(dirname "$0")"/../crossbeam-epoch set -ex +script_dir="$(cd "$(dirname "$0")" && pwd)" +cd "$script_dir"/../crossbeam-epoch + export RUSTFLAGS="-D warnings" cargo check --bins --examples --tests @@ -22,4 +24,8 @@ if [[ "$RUST_VERSION" == "nightly"* ]]; then --features sanitize,nightly \ --example sanitize fi + + # -Zmiri-disable-stacked-borrows is needed for https://github.com/crossbeam-rs/crossbeam/issues/545 + # -Zmiri-ignore-leaks is needed for https://github.com/crossbeam-rs/crossbeam/issues/579 + "$script_dir"/miri.sh -- -Zmiri-disable-stacked-borrows -Zmiri-ignore-leaks fi diff --git a/ci/crossbeam-queue.sh b/ci/crossbeam-queue.sh index b15303b5b..b5ed73ff0 100755 --- a/ci/crossbeam-queue.sh +++ b/ci/crossbeam-queue.sh @@ -1,8 +1,10 @@ #!/bin/bash -cd "$(dirname "$0")"/../crossbeam-queue set -ex +script_dir="$(cd "$(dirname "$0")" && pwd)" +cd "$script_dir"/../crossbeam-queue + export RUSTFLAGS="-D warnings" cargo check --bins --examples --tests @@ -10,4 +12,6 @@ cargo test if [[ "$RUST_VERSION" == "nightly"* ]]; then RUSTDOCFLAGS=-Dwarnings cargo doc --no-deps --all-features + + "$script_dir"/miri.sh fi diff --git a/ci/crossbeam-skiplist.sh b/ci/crossbeam-skiplist.sh index 3928d42e4..e66730dda 100755 --- a/ci/crossbeam-skiplist.sh +++ b/ci/crossbeam-skiplist.sh @@ -1,8 +1,10 @@ #!/bin/bash -cd "$(dirname "$0")"/../crossbeam-skiplist set -ex +script_dir="$(cd "$(dirname "$0")" && pwd)" +cd "$script_dir"/../crossbeam-skiplist + export RUSTFLAGS="-D warnings" cargo check --bins --examples --tests @@ -12,4 +14,8 @@ if [[ "$RUST_VERSION" == "nightly"* ]]; then cargo test --features nightly RUSTDOCFLAGS=-Dwarnings cargo doc --no-deps --all-features + + # -Zmiri-disable-stacked-borrows is needed for https://github.com/crossbeam-rs/crossbeam/issues/545 + # -Zmiri-ignore-leaks is needed for https://github.com/crossbeam-rs/crossbeam/issues/579 + "$script_dir"/miri.sh -- -Zmiri-disable-stacked-borrows -Zmiri-ignore-leaks fi diff --git a/ci/crossbeam-utils.sh b/ci/crossbeam-utils.sh index 4879687de..00d5af481 100755 --- a/ci/crossbeam-utils.sh +++ b/ci/crossbeam-utils.sh @@ -1,8 +1,10 @@ #!/bin/bash -cd "$(dirname "$0")"/../crossbeam-utils set -ex +script_dir="$(cd "$(dirname "$0")" && pwd)" +cd "$script_dir"/../crossbeam-utils + export RUSTFLAGS="-D warnings" cargo check --bins --examples --tests @@ -12,4 +14,6 @@ if [[ "$RUST_VERSION" == "nightly"* ]]; then cargo test --features nightly RUSTDOCFLAGS=-Dwarnings cargo doc --no-deps --all-features + + "$script_dir"/miri.sh -- -Zmiri-disable-isolation fi diff --git a/ci/crossbeam.sh b/ci/crossbeam.sh index 99d4483bd..75a33bfcb 100755 --- a/ci/crossbeam.sh +++ b/ci/crossbeam.sh @@ -1,8 +1,10 @@ #!/bin/bash -cd "$(dirname "$0")"/.. set -ex +script_dir="$(cd "$(dirname "$0")" && pwd)" +cd "$script_dir"/.. + export RUSTFLAGS="-D warnings" cargo check --bins --examples --tests @@ -12,4 +14,7 @@ if [[ "$RUST_VERSION" == "nightly"* ]]; then cargo test --features nightly RUSTDOCFLAGS=-Dwarnings cargo doc --no-deps --all-features + + # -Zmiri-ignore-leaks is needed for https://github.com/crossbeam-rs/crossbeam/issues/579 + "$script_dir"/miri.sh -- -Zmiri-ignore-leaks fi diff --git a/ci/miri.sh b/ci/miri.sh new file mode 100755 index 000000000..2af60de44 --- /dev/null +++ b/ci/miri.sh @@ -0,0 +1,16 @@ +#!/bin/bash + +set -ex + +export RUSTFLAGS="-D warnings" + +if [[ "$OSTYPE" != "linux"* ]]; then + exit 0 +fi + +toolchain=nightly-$(curl -s https://rust-lang.github.io/rustup-components-history/x86_64-unknown-linux-gnu/miri) +rustup set profile minimal +rustup default "$toolchain" +rustup component add miri + +cargo miri test "$@" diff --git a/crossbeam-channel/tests/after.rs b/crossbeam-channel/tests/after.rs index 20670dc5a..b8a4dcdc7 100644 --- a/crossbeam-channel/tests/after.rs +++ b/crossbeam-channel/tests/after.rs @@ -1,5 +1,7 @@ //! Tests for the after channel flavor. +#![cfg(not(miri))] // TODO: many assertions failed due to Miri is slow + use std::sync::atomic::AtomicUsize; use std::sync::atomic::Ordering; use std::thread; diff --git a/crossbeam-channel/tests/array.rs b/crossbeam-channel/tests/array.rs index a7ae323d9..805868f7e 100644 --- a/crossbeam-channel/tests/array.rs +++ b/crossbeam-channel/tests/array.rs @@ -1,5 +1,7 @@ //! Tests for the array channel flavor. +#![cfg(not(miri))] // TODO: many assertions failed due to Miri is slow + use std::any::Any; use std::sync::atomic::AtomicUsize; use std::sync::atomic::Ordering; diff --git a/crossbeam-channel/tests/golang.rs b/crossbeam-channel/tests/golang.rs index 69a9315a0..4d4e5657b 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))] // Miri is too slow + 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..c5815cf6c 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)] // Miri is too slow #[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..955fd017d 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 = 100; + #[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 = 100; + #[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 = 100; + #[cfg(not(miri))] const COUNT: usize = 10_000; for _ in 0..COUNT { @@ -308,6 +317,7 @@ fn stress_oneshot() { } } +#[cfg_attr(miri, ignore)] // Miri is too slow #[test] fn stress_iter() { const COUNT: usize = 100_000; @@ -371,6 +381,7 @@ fn stress_timeout_two_threads() { .unwrap(); } +#[cfg_attr(miri, ignore)] // Miri is too slow #[test] fn drops() { static DROPS: AtomicUsize = AtomicUsize::new(0); @@ -421,6 +432,9 @@ fn drops() { #[test] fn linearizable() { + #[cfg(miri)] + const COUNT: usize = 100; + #[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 = 100; + #[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 = 100; + #[cfg(not(miri))] const COUNT: usize = 10_000; let (s, r) = unbounded(); @@ -496,6 +516,9 @@ fn recv_in_send() { #[test] fn channel_through_channel() { + #[cfg(miri)] + const COUNT: usize = 100; + #[cfg(not(miri))] const COUNT: usize = 1000; type T = Box; diff --git a/crossbeam-channel/tests/mpsc.rs b/crossbeam-channel/tests/mpsc.rs index 2a0786a71..6fcfcf50b 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)] // Miri is too slow #[test] fn port_gone_concurrent() { let (tx, rx) = channel::(); @@ -274,6 +275,7 @@ mod channel_tests { t.join().unwrap(); } + #[cfg_attr(miri, ignore)] // Miri is too slow #[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,17 @@ mod channel_tests { #[test] fn recv_a_lot() { + #[cfg(miri)] + const N: usize = 100; + #[cfg(not(miri))] + const N: 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..N { tx.send(()).unwrap(); } - for _ in 0..10000 { + for _ in 0..N { rx.recv().unwrap(); } } @@ -841,6 +856,7 @@ mod channel_tests { t.join().unwrap(); } + #[cfg_attr(miri, ignore)] // Miri is too slow #[test] fn test_recv_try_iter() { let (request_tx, request_rx) = channel(); @@ -955,6 +971,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 +1096,18 @@ mod sync_channel_tests { #[test] fn stress() { + #[cfg(miri)] + const N: usize = 100; + #[cfg(not(miri))] + const N: usize = 10000; + let (tx, rx) = sync_channel::(0); let t = thread::spawn(move || { - for _ in 0..10000 { + for _ in 0..N { tx.send(1).unwrap(); } }); - for _ in 0..10000 { + for _ in 0..N { assert_eq!(rx.recv().unwrap(), 1); } t.join().unwrap(); @@ -1093,10 +1115,15 @@ mod sync_channel_tests { #[test] fn stress_recv_timeout_two_threads() { + #[cfg(miri)] + const N: usize = 100; + #[cfg(not(miri))] + const N: usize = 10000; + let (tx, rx) = sync_channel::(0); let t = thread::spawn(move || { - for _ in 0..10000 { + for _ in 0..N { tx.send(1).unwrap(); } }); @@ -1113,7 +1140,7 @@ mod sync_channel_tests { } } - assert_eq!(recv_count, 10000); + assert_eq!(recv_count, N); t.join().unwrap(); } @@ -1449,12 +1476,17 @@ mod sync_channel_tests { #[test] fn recv_a_lot() { + #[cfg(miri)] + const N: usize = 100; + #[cfg(not(miri))] + const N: 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(N); + for _ in 0..N { tx.send(()).unwrap(); } - for _ in 0..10000 { + for _ in 0..N { rx.recv().unwrap(); } } @@ -1792,7 +1824,11 @@ mod select_tests { #[test] fn stress() { + #[cfg(miri)] + const AMT: i32 = 100; + #[cfg(not(miri))] const AMT: i32 = 10000; + let (tx1, rx1) = channel::(); let (tx2, rx2) = channel::(); let (tx3, rx3) = channel::<()>(); diff --git a/crossbeam-channel/tests/ready.rs b/crossbeam-channel/tests/ready.rs index 700f487e0..4fd8b6412 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 = 100; + #[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 = 100; + #[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 = 100; + #[cfg(not(miri))] const COUNT: usize = 10_000; let (s1, r1) = bounded(0); @@ -668,6 +677,9 @@ fn send_recv_same_channel() { #[test] fn channel_through_channel() { + #[cfg(miri)] + const COUNT: usize = 100; + #[cfg(not(miri))] const COUNT: usize = 1000; type T = Box; @@ -724,6 +736,9 @@ fn channel_through_channel() { #[test] fn fairness1() { + #[cfg(miri)] + const COUNT: usize = 100; + #[cfg(not(miri))] const COUNT: usize = 10_000; let (s1, r1) = bounded::<()>(COUNT); @@ -769,6 +784,9 @@ fn fairness1() { #[test] fn fairness2() { + #[cfg(miri)] + const COUNT: usize = 100; + #[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..430452ffd 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)] // Miri is too slow #[test] fn loop_try() { const RUNS: usize = 20; @@ -690,6 +691,9 @@ fn nesting() { #[test] fn stress_recv() { + #[cfg(miri)] + const COUNT: usize = 100; + #[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 = 100; + #[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 = 100; + #[cfg(not(miri))] const COUNT: usize = 10_000; let (s1, r1) = bounded(0); @@ -942,6 +952,9 @@ fn matching_with_leftover() { #[test] fn channel_through_channel() { + #[cfg(miri)] + const COUNT: usize = 100; + #[cfg(not(miri))] const COUNT: usize = 1000; type T = Box; @@ -1000,6 +1013,9 @@ fn channel_through_channel() { #[test] fn linearizable_try() { + #[cfg(miri)] + const COUNT: usize = 100; + #[cfg(not(miri))] const COUNT: usize = 100_000; for step in 0..2 { @@ -1052,6 +1068,9 @@ fn linearizable_try() { #[test] fn linearizable_timeout() { + #[cfg(miri)] + const COUNT: usize = 100; + #[cfg(not(miri))] const COUNT: usize = 100_000; for step in 0..2 { @@ -1104,6 +1123,9 @@ fn linearizable_timeout() { #[test] fn fairness1() { + #[cfg(miri)] + const COUNT: usize = 100; + #[cfg(not(miri))] const COUNT: usize = 10_000; let (s1, r1) = bounded::<()>(COUNT); @@ -1150,6 +1172,9 @@ fn fairness1() { #[test] fn fairness2() { + #[cfg(miri)] + const COUNT: usize = 100; + #[cfg(not(miri))] const COUNT: usize = 10_000; let (s1, r1) = unbounded::<()>(); @@ -1266,6 +1291,9 @@ fn send_and_clone() { #[test] fn reuse() { + #[cfg(miri)] + const COUNT: usize = 100; + #[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..571852a61 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)] // Miri is too slow #[test] fn loop_try() { const RUNS: usize = 20; @@ -485,6 +486,9 @@ fn panic_receiver() { #[test] fn stress_recv() { + #[cfg(miri)] + const COUNT: usize = 100; + #[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 = 100; + #[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 = 100; + #[cfg(not(miri))] const COUNT: usize = 10_000; let (s1, r1) = bounded(0); @@ -681,6 +691,9 @@ fn matching_with_leftover() { #[test] fn channel_through_channel() { + #[cfg(miri)] + const COUNT: usize = 100; + #[cfg(not(miri))] const COUNT: usize = 1000; type T = Box; @@ -726,6 +739,9 @@ fn channel_through_channel() { #[test] fn linearizable_default() { + #[cfg(miri)] + const COUNT: usize = 100; + #[cfg(not(miri))] const COUNT: usize = 100_000; for step in 0..2 { @@ -770,6 +786,9 @@ fn linearizable_default() { #[test] fn linearizable_timeout() { + #[cfg(miri)] + const COUNT: usize = 100; + #[cfg(not(miri))] const COUNT: usize = 100_000; for step in 0..2 { @@ -814,6 +833,9 @@ fn linearizable_timeout() { #[test] fn fairness1() { + #[cfg(miri)] + const COUNT: usize = 100; + #[cfg(not(miri))] const COUNT: usize = 10_000; let (s1, r1) = bounded::<()>(COUNT); @@ -838,6 +860,9 @@ fn fairness1() { #[test] fn fairness2() { + #[cfg(miri)] + const COUNT: usize = 100; + #[cfg(not(miri))] const COUNT: usize = 10_000; let (s1, r1) = unbounded::<()>(); @@ -875,6 +900,9 @@ fn fairness2() { #[test] fn fairness_recv() { + #[cfg(miri)] + const COUNT: usize = 100; + #[cfg(not(miri))] const COUNT: usize = 10_000; let (s1, r1) = bounded::<()>(COUNT); @@ -897,6 +925,9 @@ fn fairness_recv() { #[test] fn fairness_send() { + #[cfg(miri)] + const COUNT: usize = 100; + #[cfg(not(miri))] const COUNT: usize = 10_000; let (s1, _r1) = bounded::<()>(COUNT); diff --git a/crossbeam-channel/tests/thread_locals.rs b/crossbeam-channel/tests/thread_locals.rs index 9e27146df..effb6a143 100644 --- a/crossbeam-channel/tests/thread_locals.rs +++ b/crossbeam-channel/tests/thread_locals.rs @@ -1,5 +1,7 @@ //! Tests that make sure accessing thread-locals while exiting the thread doesn't cause panics. +#![cfg(not(miri))] // error: abnormal termination: the evaluated program aborted execution + use std::thread; use std::time::Duration; diff --git a/crossbeam-channel/tests/tick.rs b/crossbeam-channel/tests/tick.rs index 5dc87306f..70bb190a9 100644 --- a/crossbeam-channel/tests/tick.rs +++ b/crossbeam-channel/tests/tick.rs @@ -1,5 +1,7 @@ //! Tests for the tick channel flavor. +#![cfg(not(miri))] // TODO: many assertions failed due to Miri is slow + use std::sync::atomic::AtomicUsize; use std::sync::atomic::Ordering; use std::thread; diff --git a/crossbeam-channel/tests/zero.rs b/crossbeam-channel/tests/zero.rs index 66dcc1eeb..ff2baee84 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 = 100; + #[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 = 100; + #[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 = 100; + #[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 = 100; + #[cfg(not(miri))] const COUNT: usize = 10_000; for _ in 0..COUNT { @@ -316,6 +328,7 @@ fn stress_oneshot() { } } +#[cfg_attr(miri, ignore)] // Miri is too slow #[test] fn stress_iter() { const COUNT: usize = 1000; @@ -383,6 +396,7 @@ fn stress_timeout_two_threads() { .unwrap(); } +#[cfg_attr(miri, ignore)] // Miri is too slow #[test] fn drops() { static DROPS: AtomicUsize = AtomicUsize::new(0); @@ -428,6 +442,9 @@ fn drops() { #[test] fn fairness() { + #[cfg(miri)] + const COUNT: usize = 100; + #[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 = 100; + #[cfg(not(miri))] const COUNT: usize = 10_000; let (s, r) = bounded::<()>(0); @@ -517,6 +537,9 @@ fn recv_in_send() { #[test] fn channel_through_channel() { + #[cfg(miri)] + const COUNT: usize = 100; + #[cfg(not(miri))] const COUNT: usize = 1000; type T = Box; diff --git a/crossbeam-deque/tests/fifo.rs b/crossbeam-deque/tests/fifo.rs index 19a1f5849..f377f918d 100644 --- a/crossbeam-deque/tests/fifo.rs +++ b/crossbeam-deque/tests/fifo.rs @@ -71,6 +71,9 @@ fn is_empty() { #[test] fn spsc() { + #[cfg(miri)] + const STEPS: usize = 500; + #[cfg(not(miri))] const STEPS: usize = 50_000; let w = Worker::new_fifo(); @@ -100,6 +103,9 @@ fn spsc() { #[test] fn stampede() { const THREADS: usize = 8; + #[cfg(miri)] + const COUNT: usize = 500; + #[cfg(not(miri))] const COUNT: usize = 50_000; let w = Worker::new_fifo(); @@ -141,6 +147,9 @@ fn stampede() { #[test] fn stress() { const THREADS: usize = 8; + #[cfg(miri)] + const COUNT: usize = 500; + #[cfg(not(miri))] const COUNT: usize = 50_000; let w = Worker::new_fifo(); @@ -197,6 +206,7 @@ fn stress() { .unwrap(); } +#[cfg_attr(miri, ignore)] // Miri is too slow #[test] fn no_starvation() { const THREADS: usize = 8; @@ -256,6 +266,7 @@ fn no_starvation() { .unwrap(); } +#[cfg_attr(miri, ignore)] // Miri is too slow #[test] fn destructors() { const THREADS: usize = 8; diff --git a/crossbeam-deque/tests/injector.rs b/crossbeam-deque/tests/injector.rs index 0165e1a6b..8c1a250b6 100644 --- a/crossbeam-deque/tests/injector.rs +++ b/crossbeam-deque/tests/injector.rs @@ -46,6 +46,9 @@ fn is_empty() { #[test] fn spsc() { + #[cfg(miri)] + const COUNT: usize = 500; + #[cfg(not(miri))] const COUNT: usize = 100_000; let q = Injector::new(); @@ -73,6 +76,9 @@ fn spsc() { #[test] fn mpmc() { + #[cfg(miri)] + const COUNT: usize = 500; + #[cfg(not(miri))] const COUNT: usize = 25_000; const THREADS: usize = 4; @@ -111,6 +117,9 @@ fn mpmc() { #[test] fn stampede() { const THREADS: usize = 8; + #[cfg(miri)] + const COUNT: usize = 500; + #[cfg(not(miri))] const COUNT: usize = 50_000; let q = Injector::new(); @@ -152,6 +161,9 @@ fn stampede() { #[test] fn stress() { const THREADS: usize = 8; + #[cfg(miri)] + const COUNT: usize = 500; + #[cfg(not(miri))] const COUNT: usize = 50_000; let q = Injector::new(); @@ -208,6 +220,7 @@ fn stress() { .unwrap(); } +#[cfg_attr(miri, ignore)] // Miri is too slow #[test] fn no_starvation() { const THREADS: usize = 8; @@ -267,6 +280,7 @@ fn no_starvation() { .unwrap(); } +#[cfg_attr(miri, ignore)] // Miri is too slow #[test] fn destructors() { const THREADS: usize = 8; diff --git a/crossbeam-deque/tests/lifo.rs b/crossbeam-deque/tests/lifo.rs index d7e498add..32f223ba7 100644 --- a/crossbeam-deque/tests/lifo.rs +++ b/crossbeam-deque/tests/lifo.rs @@ -71,6 +71,9 @@ fn is_empty() { #[test] fn spsc() { + #[cfg(miri)] + const STEPS: usize = 500; + #[cfg(not(miri))] const STEPS: usize = 50_000; let w = Worker::new_lifo(); @@ -100,6 +103,9 @@ fn spsc() { #[test] fn stampede() { const THREADS: usize = 8; + #[cfg(miri)] + const COUNT: usize = 500; + #[cfg(not(miri))] const COUNT: usize = 50_000; let w = Worker::new_lifo(); @@ -141,6 +147,9 @@ fn stampede() { #[test] fn stress() { const THREADS: usize = 8; + #[cfg(miri)] + const COUNT: usize = 500; + #[cfg(not(miri))] const COUNT: usize = 50_000; let w = Worker::new_lifo(); @@ -197,6 +206,7 @@ fn stress() { .unwrap(); } +#[cfg_attr(miri, ignore)] // Miri is too slow #[test] fn no_starvation() { const THREADS: usize = 8; @@ -256,6 +266,7 @@ fn no_starvation() { .unwrap(); } +#[cfg_attr(miri, ignore)] // Miri is too slow #[test] fn destructors() { const THREADS: usize = 8; diff --git a/crossbeam-epoch/src/collector.rs b/crossbeam-epoch/src/collector.rs index 8224e1184..3955b09cb 100644 --- a/crossbeam-epoch/src/collector.rs +++ b/crossbeam-epoch/src/collector.rs @@ -178,13 +178,18 @@ mod tests { #[test] fn pin_holds_advance() { + #[cfg(miri)] + const N: usize = 500; + #[cfg(not(miri))] + const N: usize = 500_000; + let collector = Collector::new(); thread::scope(|scope| { for _ in 0..NUM_THREADS { scope.spawn(|_| { let handle = collector.register(); - for _ in 0..500_000 { + for _ in 0..N { let guard = &handle.pin(); let before = collector.global.epoch.load(Ordering::Relaxed); @@ -201,6 +206,9 @@ mod tests { #[test] fn incremental() { + #[cfg(miri)] + const COUNT: usize = 500; + #[cfg(not(miri))] const COUNT: usize = 100_000; static DESTROYS: AtomicUsize = AtomicUsize::new(0); @@ -229,12 +237,16 @@ mod tests { let guard = &handle.pin(); collector.global.collect(guard); } - assert!(DESTROYS.load(Ordering::Relaxed) == 100_000); + assert!(DESTROYS.load(Ordering::Relaxed) == COUNT); } #[test] fn buffering() { const COUNT: usize = 10; + #[cfg(miri)] + const N: usize = 500; + #[cfg(not(miri))] + const N: usize = 100_000; static DESTROYS: AtomicUsize = AtomicUsize::new(0); let collector = Collector::new(); @@ -251,7 +263,7 @@ mod tests { } } - for _ in 0..100_000 { + for _ in 0..N { collector.global.collect(&handle.pin()); } assert!(DESTROYS.load(Ordering::Relaxed) < COUNT); @@ -267,6 +279,9 @@ mod tests { #[test] fn count_drops() { + #[cfg(miri)] + const COUNT: usize = 500; + #[cfg(not(miri))] const COUNT: usize = 100_000; static DROPS: AtomicUsize = AtomicUsize::new(0); @@ -300,6 +315,9 @@ mod tests { #[test] fn count_destroy() { + #[cfg(miri)] + const COUNT: usize = 500; + #[cfg(not(miri))] const COUNT: usize = 100_000; static DESTROYS: AtomicUsize = AtomicUsize::new(0); @@ -366,6 +384,9 @@ mod tests { #[test] fn destroy_array() { + #[cfg(miri)] + const COUNT: usize = 500; + #[cfg(not(miri))] const COUNT: usize = 100_000; static DESTROYS: AtomicUsize = AtomicUsize::new(0); @@ -401,6 +422,9 @@ mod tests { #[test] fn stress() { const THREADS: usize = 8; + #[cfg(miri)] + const COUNT: usize = 500; + #[cfg(not(miri))] const COUNT: usize = 100_000; static DROPS: AtomicUsize = AtomicUsize::new(0); diff --git a/crossbeam-epoch/src/sync/queue.rs b/crossbeam-epoch/src/sync/queue.rs index 71ea1bcc0..d17a4e275 100644 --- a/crossbeam-epoch/src/sync/queue.rs +++ b/crossbeam-epoch/src/sync/queue.rs @@ -251,6 +251,9 @@ mod test { } } + #[cfg(miri)] + const CONC_COUNT: i64 = 1000; + #[cfg(not(miri))] const CONC_COUNT: i64 = 1000000; #[test] diff --git a/crossbeam-queue/tests/array_queue.rs b/crossbeam-queue/tests/array_queue.rs index 7b9dba0ea..306d035da 100644 --- a/crossbeam-queue/tests/array_queue.rs +++ b/crossbeam-queue/tests/array_queue.rs @@ -57,6 +57,7 @@ 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; @@ -114,6 +115,7 @@ fn len() { assert_eq!(q.len(), 0); } +#[cfg_attr(miri, ignore)] // Miri is too slow #[test] fn spsc() { const COUNT: usize = 100_000; @@ -142,6 +144,7 @@ fn spsc() { .unwrap(); } +#[cfg_attr(miri, ignore)] // Miri is too slow #[test] fn mpmc() { const COUNT: usize = 25_000; @@ -178,6 +181,7 @@ fn mpmc() { } } +#[cfg_attr(miri, ignore)] // Miri is too slow #[test] fn drops() { const RUNS: usize = 100; @@ -231,6 +235,9 @@ fn drops() { #[test] fn linearizable() { + #[cfg(miri)] + const COUNT: usize = 500; + #[cfg(not(miri))] const COUNT: usize = 25_000; const THREADS: usize = 4; diff --git a/crossbeam-queue/tests/seg_queue.rs b/crossbeam-queue/tests/seg_queue.rs index 6984a508f..b8bae8b91 100644 --- a/crossbeam-queue/tests/seg_queue.rs +++ b/crossbeam-queue/tests/seg_queue.rs @@ -52,6 +52,7 @@ fn len() { assert_eq!(q.len(), 0); } +#[cfg_attr(miri, ignore)] // Miri is too slow #[test] fn spsc() { const COUNT: usize = 100_000; @@ -79,6 +80,7 @@ fn spsc() { .unwrap(); } +#[cfg_attr(miri, ignore)] // Miri is too slow #[test] fn mpmc() { const COUNT: usize = 25_000; @@ -115,6 +117,7 @@ fn mpmc() { } } +#[cfg_attr(miri, ignore)] // Miri is too slow #[test] fn drops() { static DROPS: AtomicUsize = AtomicUsize::new(0);