aboutsummaryrefslogtreecommitdiff
path: root/tests/list.rs
diff options
context:
space:
mode:
Diffstat (limited to 'tests/list.rs')
-rw-r--r--tests/list.rs34
1 files changed, 28 insertions, 6 deletions
diff --git a/tests/list.rs b/tests/list.rs
index 619e1fc..ebe6f6f 100644
--- a/tests/list.rs
+++ b/tests/list.rs
@@ -67,6 +67,7 @@ fn len_empty_full() {
}
#[test]
+#[cfg_attr(miri, ignore)] // this test makes timing assumptions, but Miri is so slow it violates them
fn try_recv() {
let (s, r) = unbounded();
@@ -132,8 +133,13 @@ fn recv_timeout() {
#[test]
fn try_send() {
+ #[cfg(miri)]
+ const COUNT: usize = 50;
+ #[cfg(not(miri))]
+ const COUNT: usize = 1000;
+
let (s, r) = unbounded();
- for i in 0..1000 {
+ for i in 0..COUNT {
assert_eq!(s.try_send(i), Ok(()));
}
@@ -143,8 +149,13 @@ fn try_send() {
#[test]
fn send() {
+ #[cfg(miri)]
+ const COUNT: usize = 50;
+ #[cfg(not(miri))]
+ const COUNT: usize = 1000;
+
let (s, r) = unbounded();
- for i in 0..1000 {
+ for i in 0..COUNT {
assert_eq!(s.send(i), Ok(()));
}
@@ -154,8 +165,13 @@ fn send() {
#[test]
fn send_timeout() {
+ #[cfg(miri)]
+ const COUNT: usize = 50;
+ #[cfg(not(miri))]
+ const COUNT: usize = 1000;
+
let (s, r) = unbounded();
- for i in 0..1000 {
+ for i in 0..COUNT {
assert_eq!(s.send_timeout(i, ms(i as u64)), Ok(()));
}
@@ -383,10 +399,16 @@ fn stress_timeout_two_threads() {
.unwrap();
}
-#[cfg_attr(miri, ignore)] // Miri is too slow
#[test]
fn drops() {
+ #[cfg(miri)]
+ const RUNS: usize = 20;
+ #[cfg(not(miri))]
const RUNS: usize = 100;
+ #[cfg(miri)]
+ const STEPS: usize = 100;
+ #[cfg(not(miri))]
+ const STEPS: usize = 10_000;
static DROPS: AtomicUsize = AtomicUsize::new(0);
@@ -402,8 +424,8 @@ fn drops() {
let mut rng = thread_rng();
for _ in 0..RUNS {
- let steps = rng.gen_range(0..10_000);
- let additional = rng.gen_range(0..1000);
+ let steps = rng.gen_range(0..STEPS);
+ let additional = rng.gen_range(0..STEPS / 10);
DROPS.store(0, Ordering::SeqCst);
let (s, r) = unbounded::<DropCounter>();