aboutsummaryrefslogtreecommitdiff
path: root/tests/select.rs
diff options
context:
space:
mode:
Diffstat (limited to 'tests/select.rs')
-rw-r--r--tests/select.rs62
1 files changed, 46 insertions, 16 deletions
diff --git a/tests/select.rs b/tests/select.rs
index fcc291e..f24aed8 100644
--- a/tests/select.rs
+++ b/tests/select.rs
@@ -1,5 +1,7 @@
//! Tests for channel selection using the `Select` struct.
+#![allow(clippy::drop_copy)]
+
use std::any::Any;
use std::cell::Cell;
use std::thread;
@@ -406,6 +408,7 @@ fn both_ready() {
.unwrap();
}
+#[cfg_attr(miri, ignore)] // Miri is too slow
#[test]
fn loop_try() {
const RUNS: usize = 20;
@@ -690,6 +693,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 +734,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 +772,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);
@@ -895,12 +907,12 @@ fn matching() {
for i in 0..THREADS {
scope.spawn(move |_| {
let mut sel = Select::new();
- let oper1 = sel.recv(&r);
- let oper2 = sel.send(&s);
+ let oper1 = sel.recv(r);
+ let oper2 = sel.send(s);
let oper = sel.select();
match oper.index() {
- ix if ix == oper1 => assert_ne!(oper.recv(&r), Ok(i)),
- ix if ix == oper2 => assert!(oper.send(&s, i).is_ok()),
+ ix if ix == oper1 => assert_ne!(oper.recv(r), Ok(i)),
+ ix if ix == oper2 => assert!(oper.send(s, i).is_ok()),
_ => unreachable!(),
}
});
@@ -921,12 +933,12 @@ fn matching_with_leftover() {
for i in 0..THREADS {
scope.spawn(move |_| {
let mut sel = Select::new();
- let oper1 = sel.recv(&r);
- let oper2 = sel.send(&s);
+ let oper1 = sel.recv(r);
+ let oper2 = sel.send(s);
let oper = sel.select();
match oper.index() {
- ix if ix == oper1 => assert_ne!(oper.recv(&r), Ok(i)),
- ix if ix == oper2 => assert!(oper.send(&s, i).is_ok()),
+ ix if ix == oper1 => assert_ne!(oper.recv(r), Ok(i)),
+ ix if ix == oper2 => assert!(oper.send(s, i).is_ok()),
_ => unreachable!(),
}
});
@@ -940,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<dyn Any + Send>;
@@ -998,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 {
@@ -1050,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 {
@@ -1102,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);
@@ -1148,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::<()>();
@@ -1212,8 +1239,8 @@ fn sync_and_clone() {
let (s, r) = &bounded::<usize>(0);
let mut sel = Select::new();
- let oper1 = sel.recv(&r);
- let oper2 = sel.send(&s);
+ let oper1 = sel.recv(r);
+ let oper2 = sel.send(s);
let sel = &sel;
scope(|scope| {
@@ -1222,8 +1249,8 @@ fn sync_and_clone() {
let mut sel = sel.clone();
let oper = sel.select();
match oper.index() {
- ix if ix == oper1 => assert_ne!(oper.recv(&r), Ok(i)),
- ix if ix == oper2 => assert!(oper.send(&s, i).is_ok()),
+ ix if ix == oper1 => assert_ne!(oper.recv(r), Ok(i)),
+ ix if ix == oper2 => assert!(oper.send(s, i).is_ok()),
_ => unreachable!(),
}
});
@@ -1241,8 +1268,8 @@ fn send_and_clone() {
let (s, r) = &bounded::<usize>(0);
let mut sel = Select::new();
- let oper1 = sel.recv(&r);
- let oper2 = sel.send(&s);
+ let oper1 = sel.recv(r);
+ let oper2 = sel.send(s);
scope(|scope| {
for i in 0..THREADS {
@@ -1250,8 +1277,8 @@ fn send_and_clone() {
scope.spawn(move |_| {
let oper = sel.select();
match oper.index() {
- ix if ix == oper1 => assert_ne!(oper.recv(&r), Ok(i)),
- ix if ix == oper2 => assert!(oper.send(&s, i).is_ok()),
+ ix if ix == oper1 => assert_ne!(oper.recv(r), Ok(i)),
+ ix if ix == oper2 => assert!(oper.send(s, i).is_ok()),
_ => unreachable!(),
}
});
@@ -1264,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);