summaryrefslogtreecommitdiffstats
path: root/vendor/futures-channel/tests
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-17 12:20:29 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-17 12:20:29 +0000
commit631cd5845e8de329d0e227aaa707d7ea228b8f8f (patch)
treea1b87c8f8cad01cf18f7c5f57a08f102771ed303 /vendor/futures-channel/tests
parentAdding debian version 1.69.0+dfsg1-1. (diff)
downloadrustc-631cd5845e8de329d0e227aaa707d7ea228b8f8f.tar.xz
rustc-631cd5845e8de329d0e227aaa707d7ea228b8f8f.zip
Merging upstream version 1.70.0+dfsg1.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'vendor/futures-channel/tests')
-rw-r--r--vendor/futures-channel/tests/mpsc-close.rs1
-rw-r--r--vendor/futures-channel/tests/mpsc-size_hint.rs40
-rw-r--r--vendor/futures-channel/tests/mpsc.rs18
-rw-r--r--vendor/futures-channel/tests/oneshot.rs8
4 files changed, 58 insertions, 9 deletions
diff --git a/vendor/futures-channel/tests/mpsc-close.rs b/vendor/futures-channel/tests/mpsc-close.rs
index 81203d334..1a14067ec 100644
--- a/vendor/futures-channel/tests/mpsc-close.rs
+++ b/vendor/futures-channel/tests/mpsc-close.rs
@@ -147,6 +147,7 @@ fn single_receiver_drop_closes_channel_and_drains() {
// Stress test that `try_send()`s occurring concurrently with receiver
// close/drops don't appear as successful sends.
+#[cfg_attr(miri, ignore)] // Miri is too slow
#[test]
fn stress_try_send_as_receiver_closes() {
const AMT: usize = 10000;
diff --git a/vendor/futures-channel/tests/mpsc-size_hint.rs b/vendor/futures-channel/tests/mpsc-size_hint.rs
new file mode 100644
index 000000000..d9cdaa31f
--- /dev/null
+++ b/vendor/futures-channel/tests/mpsc-size_hint.rs
@@ -0,0 +1,40 @@
+use futures::channel::mpsc;
+use futures::stream::Stream;
+
+#[test]
+fn unbounded_size_hint() {
+ let (tx, mut rx) = mpsc::unbounded::<u32>();
+ assert_eq!((0, None), rx.size_hint());
+ tx.unbounded_send(1).unwrap();
+ assert_eq!((1, None), rx.size_hint());
+ rx.try_next().unwrap().unwrap();
+ assert_eq!((0, None), rx.size_hint());
+ tx.unbounded_send(2).unwrap();
+ tx.unbounded_send(3).unwrap();
+ assert_eq!((2, None), rx.size_hint());
+ drop(tx);
+ assert_eq!((2, Some(2)), rx.size_hint());
+ rx.try_next().unwrap().unwrap();
+ assert_eq!((1, Some(1)), rx.size_hint());
+ rx.try_next().unwrap().unwrap();
+ assert_eq!((0, Some(0)), rx.size_hint());
+}
+
+#[test]
+fn channel_size_hint() {
+ let (mut tx, mut rx) = mpsc::channel::<u32>(10);
+ assert_eq!((0, None), rx.size_hint());
+ tx.try_send(1).unwrap();
+ assert_eq!((1, None), rx.size_hint());
+ rx.try_next().unwrap().unwrap();
+ assert_eq!((0, None), rx.size_hint());
+ tx.try_send(2).unwrap();
+ tx.try_send(3).unwrap();
+ assert_eq!((2, None), rx.size_hint());
+ drop(tx);
+ assert_eq!((2, Some(2)), rx.size_hint());
+ rx.try_next().unwrap().unwrap();
+ assert_eq!((1, Some(1)), rx.size_hint());
+ rx.try_next().unwrap().unwrap();
+ assert_eq!((0, Some(0)), rx.size_hint());
+}
diff --git a/vendor/futures-channel/tests/mpsc.rs b/vendor/futures-channel/tests/mpsc.rs
index 88cdef13d..444c8e10f 100644
--- a/vendor/futures-channel/tests/mpsc.rs
+++ b/vendor/futures-channel/tests/mpsc.rs
@@ -200,7 +200,7 @@ fn tx_close_gets_none() {
#[test]
fn stress_shared_unbounded() {
- const AMT: u32 = 10000;
+ const AMT: u32 = if cfg!(miri) { 100 } else { 10000 };
const NTHREADS: u32 = 8;
let (tx, rx) = mpsc::unbounded::<i32>();
@@ -229,7 +229,7 @@ fn stress_shared_unbounded() {
#[test]
fn stress_shared_bounded_hard() {
- const AMT: u32 = 10000;
+ const AMT: u32 = if cfg!(miri) { 100 } else { 10000 };
const NTHREADS: u32 = 8;
let (tx, rx) = mpsc::channel::<i32>(0);
@@ -259,7 +259,7 @@ fn stress_shared_bounded_hard() {
#[allow(clippy::same_item_push)]
#[test]
fn stress_receiver_multi_task_bounded_hard() {
- const AMT: usize = 10_000;
+ const AMT: usize = if cfg!(miri) { 100 } else { 10_000 };
const NTHREADS: u32 = 2;
let (mut tx, rx) = mpsc::channel::<usize>(0);
@@ -327,6 +327,8 @@ fn stress_receiver_multi_task_bounded_hard() {
/// after sender dropped.
#[test]
fn stress_drop_sender() {
+ const ITER: usize = if cfg!(miri) { 100 } else { 10000 };
+
fn list() -> impl Stream<Item = i32> {
let (tx, rx) = mpsc::channel(1);
thread::spawn(move || {
@@ -335,7 +337,7 @@ fn stress_drop_sender() {
rx
}
- for _ in 0..10000 {
+ for _ in 0..ITER {
let v: Vec<_> = block_on(list().collect());
assert_eq!(v, vec![1, 2, 3]);
}
@@ -382,7 +384,9 @@ fn stress_close_receiver_iter() {
#[test]
fn stress_close_receiver() {
- for _ in 0..10000 {
+ const ITER: usize = if cfg!(miri) { 50 } else { 10000 };
+
+ for _ in 0..ITER {
stress_close_receiver_iter();
}
}
@@ -397,7 +401,7 @@ async fn stress_poll_ready_sender(mut sender: mpsc::Sender<u32>, count: u32) {
#[allow(clippy::same_item_push)]
#[test]
fn stress_poll_ready() {
- const AMT: u32 = 1000;
+ const AMT: u32 = if cfg!(miri) { 100 } else { 1000 };
const NTHREADS: u32 = 8;
/// Run a stress test using the specified channel capacity.
@@ -426,7 +430,7 @@ fn stress_poll_ready() {
#[test]
fn try_send_1() {
- const N: usize = 3000;
+ const N: usize = if cfg!(miri) { 100 } else { 3000 };
let (mut tx, rx) = mpsc::channel(0);
let t = thread::spawn(move || {
diff --git a/vendor/futures-channel/tests/oneshot.rs b/vendor/futures-channel/tests/oneshot.rs
index 979cd8a15..6b48376dc 100644
--- a/vendor/futures-channel/tests/oneshot.rs
+++ b/vendor/futures-channel/tests/oneshot.rs
@@ -35,6 +35,8 @@ fn cancel_notifies() {
#[test]
fn cancel_lots() {
+ const N: usize = if cfg!(miri) { 100 } else { 20000 };
+
let (tx, rx) = mpsc::channel::<(Sender<_>, mpsc::Sender<_>)>();
let t = thread::spawn(move || {
for (mut tx, tx2) in rx {
@@ -43,7 +45,7 @@ fn cancel_lots() {
}
});
- for _ in 0..20000 {
+ for _ in 0..N {
let (otx, orx) = oneshot::channel::<u32>();
let (tx2, rx2) = mpsc::channel();
tx.send((otx, tx2)).unwrap();
@@ -101,6 +103,8 @@ fn is_canceled() {
#[test]
fn cancel_sends() {
+ const N: usize = if cfg!(miri) { 100 } else { 20000 };
+
let (tx, rx) = mpsc::channel::<Sender<_>>();
let t = thread::spawn(move || {
for otx in rx {
@@ -108,7 +112,7 @@ fn cancel_sends() {
}
});
- for _ in 0..20000 {
+ for _ in 0..N {
let (otx, mut orx) = oneshot::channel::<u32>();
tx.send(otx).unwrap();