diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-05-30 03:57:31 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-05-30 03:57:31 +0000 |
commit | dc0db358abe19481e475e10c32149b53370f1a1c (patch) | |
tree | ab8ce99c4b255ce46f99ef402c27916055b899ee /vendor/tokio/tests/io_copy_bidirectional.rs | |
parent | Releasing progress-linux version 1.71.1+dfsg1-2~progress7.99u1. (diff) | |
download | rustc-dc0db358abe19481e475e10c32149b53370f1a1c.tar.xz rustc-dc0db358abe19481e475e10c32149b53370f1a1c.zip |
Merging upstream version 1.72.1+dfsg1.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'vendor/tokio/tests/io_copy_bidirectional.rs')
-rw-r--r-- | vendor/tokio/tests/io_copy_bidirectional.rs | 40 |
1 files changed, 26 insertions, 14 deletions
diff --git a/vendor/tokio/tests/io_copy_bidirectional.rs b/vendor/tokio/tests/io_copy_bidirectional.rs index 0ce7f85c5..c54967595 100644 --- a/vendor/tokio/tests/io_copy_bidirectional.rs +++ b/vendor/tokio/tests/io_copy_bidirectional.rs @@ -1,5 +1,5 @@ #![warn(rust_2018_idioms)] -#![cfg(feature = "full")] +#![cfg(all(feature = "full", not(tokio_wasi)))] // Wasi does not support bind() use std::time::Duration; use tokio::io::{self, copy_bidirectional, AsyncReadExt, AsyncWriteExt}; @@ -26,7 +26,7 @@ async fn block_write(s: &mut TcpStream) -> usize { result = s.write(&BUF) => { copied += result.expect("write error") }, - _ = tokio::time::sleep(Duration::from_millis(100)) => { + _ = tokio::time::sleep(Duration::from_millis(10)) => { break; } } @@ -111,18 +111,30 @@ async fn blocking_one_side_does_not_block_other() { } #[tokio::test] -async fn immediate_exit_on_error() { - symmetric(|handle, mut a, mut b| async move { - block_write(&mut a).await; +async fn immediate_exit_on_write_error() { + let payload = b"here, take this"; + let error = || io::Error::new(io::ErrorKind::Other, "no thanks!"); - // Fill up the b->copy->a path. We expect that this will _not_ drain - // before we exit the copy task. - let _bytes_written = block_write(&mut b).await; + let mut a = tokio_test::io::Builder::new() + .read(payload) + .write_error(error()) + .build(); - // Drop b. We should not wait for a to consume the data buffered in the - // copy loop, since b will be failing writes. - drop(b); - assert!(handle.await.unwrap().is_err()); - }) - .await + let mut b = tokio_test::io::Builder::new() + .read(payload) + .write_error(error()) + .build(); + + assert!(copy_bidirectional(&mut a, &mut b).await.is_err()); +} + +#[tokio::test] +async fn immediate_exit_on_read_error() { + let error = || io::Error::new(io::ErrorKind::Other, "got nothing!"); + + let mut a = tokio_test::io::Builder::new().read_error(error()).build(); + + let mut b = tokio_test::io::Builder::new().read_error(error()).build(); + + assert!(copy_bidirectional(&mut a, &mut b).await.is_err()); } |