net: enable more Miri tests for TCP socket (#8180)

This commit is contained in:
WhySoBad
2026-06-02 23:50:54 +08:00
committed by GitHub
parent 326bd2cc44
commit 2de86e557c
4 changed files with 38 additions and 45 deletions
+1 -1
View File
@@ -18,7 +18,7 @@ env:
rust_stable: stable
rust_nightly: nightly-2025-10-12
# Pin a specific miri version
rust_miri_nightly: nightly-2026-05-20
rust_miri_nightly: nightly-2026-05-30
rust_clippy: '1.88'
# When updating this, also update:
# - README.md
-1
View File
@@ -89,7 +89,6 @@ async fn test_transfer_after_close() {
}
#[tokio::test]
#[cfg_attr(miri, ignore)] // Miri currently only processes host I/O events when switching into the scheduler: See https://github.com/rust-lang/miri/issues/5047
async fn blocking_one_side_does_not_block_other() {
symmetric(|handle, mut a, mut b| async move {
block_write(&mut a).await;
-2
View File
@@ -1155,7 +1155,6 @@ rt_test! {
#[cfg(not(target_os = "wasi"))] // Wasi does not support bind
#[test]
#[cfg_attr(miri, ignore)] // Miri currently only processes host I/O events when switching into the scheduler: See https://github.com/rust-lang/miri/issues/5047
fn local_set_client_server_block_on() {
let rt = rt();
let (tx, rx) = mpsc::channel();
@@ -1169,7 +1168,6 @@ rt_test! {
}
#[cfg(not(target_os = "wasi"))] // Wasi does not support bind
#[cfg_attr(miri, ignore)] // Miri currently only processes host I/O events when switching into the scheduler: See https://github.com/rust-lang/miri/issues/5047
async fn client_server_local(tx: mpsc::Sender<()>) {
let server = assert_ok!(TcpListener::bind("127.0.0.1:0").await);
+37 -41
View File
@@ -113,52 +113,48 @@ async fn try_read_write() {
written.reserve(10 * 1024 * 1024);
client.writable().await.unwrap();
#[cfg(not(miri))]
// Miri currently has a memory leak when `readv` returns an error: See https://github.com/rust-lang/miri/pull/5054
{
// 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());
// 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 => {
break;
}
match client.try_write_vectored(&data_bufs) {
Ok(n) => {
written.extend(&DATA[..n]);
}
Err(ref e) if e.kind() == io::ErrorKind::WouldBlock => {
break;
}
Err(e) => panic!("error = {e:?}"),
}
}
{
// Write buffer full
let mut writable = task::spawn(client.writable());
assert_pending!(writable.poll());
// Drain the socket from the server end using vectored I/O
let mut read = vec![0; written.len()];
let mut i = 0;
while i < read.len() {
server.readable().await.unwrap();
let mut bufs: Vec<_> = read[i..]
.chunks_mut(0x10000)
.map(io::IoSliceMut::new)
.collect();
match server.try_read_vectored(&mut bufs) {
Ok(n) => i += n,
Err(ref e) if e.kind() == io::ErrorKind::WouldBlock => continue,
Err(e) => panic!("error = {e:?}"),
}
}
{
// Write buffer full
let mut writable = task::spawn(client.writable());
assert_pending!(writable.poll());
// Drain the socket from the server end using vectored I/O
let mut read = vec![0; written.len()];
let mut i = 0;
while i < read.len() {
server.readable().await.unwrap();
let mut bufs: Vec<_> = read[i..]
.chunks_mut(0x10000)
.map(io::IoSliceMut::new)
.collect();
match server.try_read_vectored(&mut bufs) {
Ok(n) => i += n,
Err(ref e) if e.kind() == io::ErrorKind::WouldBlock => continue,
Err(e) => panic!("error = {e:?}"),
}
}
assert_eq!(read, written);
}
assert_eq!(read, written);
}
// Now, we listen for shutdown