From f37a7b18027707bc30fa13c6460371d158f46a63 Mon Sep 17 00:00:00 2001 From: "M.Amin Rayej" Date: Sun, 3 Sep 2023 02:21:43 +0330 Subject: [PATCH] remove assumption about constantly being ready --- tokio/tests/tcp_stream.rs | 14 +------------- tokio/tests/uds_stream.rs | 14 +------------- 2 files changed, 2 insertions(+), 26 deletions(-) diff --git a/tokio/tests/tcp_stream.rs b/tokio/tests/tcp_stream.rs index 725a60169ea..3dd9d55f319 100644 --- a/tokio/tests/tcp_stream.rs +++ b/tokio/tests/tcp_stream.rs @@ -5,7 +5,7 @@ use tokio::io::{AsyncReadExt, AsyncWriteExt, Interest}; use tokio::net::{TcpListener, TcpStream}; use tokio::try_join; use tokio_test::task; -use tokio_test::{assert_ok, assert_pending, assert_ready_ok}; +use tokio_test::{assert_ok, assert_pending}; use std::io; use std::task::Poll; @@ -57,10 +57,6 @@ async fn try_read_write() { // Fill the write buffer using non-vectored I/O loop { - // Still ready - let mut writable = task::spawn(client.writable()); - assert_ready_ok!(writable.poll()); - match client.try_write(DATA) { Ok(n) => written.extend(&DATA[..n]), Err(ref e) if e.kind() == io::ErrorKind::WouldBlock => { @@ -98,10 +94,6 @@ async fn try_read_write() { // Fill the write buffer using vectored I/O let data_bufs: Vec<_> = DATA.chunks(10).map(io::IoSlice::new).collect(); loop { - // Still ready - let mut writable = task::spawn(client.writable()); - assert_ready_ok!(writable.poll()); - match client.try_write_vectored(&data_bufs) { Ok(n) => written.extend(&DATA[..n]), Err(ref e) if e.kind() == io::ErrorKind::WouldBlock => { @@ -313,10 +305,6 @@ async fn try_read_buf() { // Fill the write buffer loop { - // Still ready - let mut writable = task::spawn(client.writable()); - assert_ready_ok!(writable.poll()); - match client.try_write(DATA) { Ok(n) => written.extend(&DATA[..n]), Err(ref e) if e.kind() == io::ErrorKind::WouldBlock => { diff --git a/tokio/tests/uds_stream.rs b/tokio/tests/uds_stream.rs index b8c4e6a8eed..924aa1261e9 100644 --- a/tokio/tests/uds_stream.rs +++ b/tokio/tests/uds_stream.rs @@ -7,7 +7,7 @@ use std::task::Poll; use tokio::io::{AsyncReadExt, AsyncWriteExt, Interest}; use tokio::net::{UnixListener, UnixStream}; -use tokio_test::{assert_ok, assert_pending, assert_ready_ok, task}; +use tokio_test::{assert_ok, assert_pending, task}; use futures::future::{poll_fn, try_join}; @@ -92,10 +92,6 @@ async fn try_read_write() -> std::io::Result<()> { // Fill the write buffer using non-vectored I/O loop { - // Still ready - let mut writable = task::spawn(client.writable()); - assert_ready_ok!(writable.poll()); - match client.try_write(msg) { Ok(n) => written.extend(&msg[..n]), Err(ref e) if e.kind() == io::ErrorKind::WouldBlock => { @@ -133,10 +129,6 @@ async fn try_read_write() -> std::io::Result<()> { // Fill the write buffer using vectored I/O let msg_bufs: Vec<_> = msg.chunks(3).map(io::IoSlice::new).collect(); loop { - // Still ready - let mut writable = task::spawn(client.writable()); - assert_ready_ok!(writable.poll()); - match client.try_write_vectored(&msg_bufs) { Ok(n) => written.extend(&msg[..n]), Err(ref e) if e.kind() == io::ErrorKind::WouldBlock => { @@ -329,10 +321,6 @@ async fn try_read_buf() -> std::io::Result<()> { // Fill the write buffer loop { - // Still ready - let mut writable = task::spawn(client.writable()); - assert_ready_ok!(writable.poll()); - match client.try_write(msg) { Ok(n) => written.extend(&msg[..n]), Err(ref e) if e.kind() == io::ErrorKind::WouldBlock => {