Skip to content

Commit 4047d79

Browse files
authored
miri: add annotations for tests with miri ignore (#6981)
1 parent cbdceb9 commit 4047d79

37 files changed

+99
-24
lines changed

.github/workflows/ci.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ env:
1818
rust_stable: stable
1919
rust_nightly: nightly-2024-05-05
2020
# Pin a specific miri version
21-
rust_miri_nightly: nightly-2024-09-19
21+
rust_miri_nightly: nightly-2024-10-21
2222
rust_clippy: '1.77'
2323
# When updating this, also update:
2424
# - README.md

tokio-stream/tests/stream_chain.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ where
4949
}
5050

5151
#[tokio::test]
52+
#[cfg_attr(miri, ignore)] // Block on https://github.com/tokio-rs/tokio/issues/6860
5253
async fn pending_first() {
5354
let (tx1, rx1) = mpsc::unbounded_channel_stream();
5455
let (tx2, rx2) = mpsc::unbounded_channel_stream();

tokio/tests/buffered.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ use std::net::TcpStream;
99
use std::thread;
1010

1111
#[tokio::test]
12-
#[cfg_attr(miri, ignore)]
12+
#[cfg_attr(miri, ignore)] // No `socket` on miri.
1313
async fn echo_server() {
1414
const N: usize = 1024;
1515

tokio/tests/coop_budget.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ use tokio::net::UdpSocket;
2222
/// Since we are both sending and receiving, that should happen once per 64 packets, because budgets are of size 128
2323
/// and there are two budget events per packet, a send and a recv.
2424
#[tokio::test]
25-
#[cfg_attr(miri, ignore)]
25+
#[cfg_attr(miri, ignore)] // No `socket` on miri.
2626
async fn coop_budget_udp_send_recv() {
2727
const BUDGET: usize = 128;
2828
const N_ITERATIONS: usize = 1024;

tokio/tests/fs_copy.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ use tempfile::tempdir;
55
use tokio::fs;
66

77
#[tokio::test]
8-
#[cfg_attr(miri, ignore)]
8+
#[cfg_attr(miri, ignore)] // No `fchmod` in miri.
99
async fn copy() {
1010
let dir = tempdir().unwrap();
1111

@@ -22,7 +22,7 @@ async fn copy() {
2222
}
2323

2424
#[tokio::test]
25-
#[cfg_attr(miri, ignore)]
25+
#[cfg_attr(miri, ignore)] // No `fchmod` in miri.
2626
async fn copy_permissions() {
2727
let dir = tempdir().unwrap();
2828
let from_path = dir.path().join("foo.txt");

tokio/tests/fs_link.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ use std::io::Write;
77
use tempfile::tempdir;
88

99
#[tokio::test]
10-
#[cfg_attr(miri, ignore)]
10+
#[cfg_attr(miri, ignore)] // No `linkat` in miri.
1111
async fn test_hard_link() {
1212
let dir = tempdir().unwrap();
1313
let src = dir.path().join("src.txt");

tokio/tests/fs_try_exists.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ use tempfile::tempdir;
55
use tokio::fs;
66

77
#[tokio::test]
8-
#[cfg_attr(miri, ignore)]
8+
#[cfg_attr(miri, ignore)] // No `chmod` in miri.
99
async fn try_exists() {
1010
let dir = tempdir().unwrap();
1111

tokio/tests/io_copy_bidirectional.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#![warn(rust_2018_idioms)]
2-
#![cfg(all(feature = "full", not(target_os = "wasi"), not(miri)))] // Wasi does not support bind()
2+
#![cfg(all(feature = "full", not(target_os = "wasi")))] // Wasi does not support bind()
33

44
use std::time::Duration;
55
use tokio::io::{self, copy_bidirectional, AsyncReadExt, AsyncWriteExt};
@@ -59,6 +59,7 @@ where
5959
}
6060

6161
#[tokio::test]
62+
#[cfg_attr(miri, ignore)] // No `socket` in miri.
6263
async fn test_basic_transfer() {
6364
symmetric(|_handle, mut a, mut b| async move {
6465
a.write_all(b"test").await.unwrap();
@@ -70,6 +71,7 @@ async fn test_basic_transfer() {
7071
}
7172

7273
#[tokio::test]
74+
#[cfg_attr(miri, ignore)] // No `socket` in miri.
7375
async fn test_transfer_after_close() {
7476
symmetric(|handle, mut a, mut b| async move {
7577
AsyncWriteExt::shutdown(&mut a).await.unwrap();
@@ -89,6 +91,7 @@ async fn test_transfer_after_close() {
8991
}
9092

9193
#[tokio::test]
94+
#[cfg_attr(miri, ignore)] // No `socket` in miri.
9295
async fn blocking_one_side_does_not_block_other() {
9396
symmetric(|handle, mut a, mut b| async move {
9497
block_write(&mut a).await;

tokio/tests/io_driver.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#![warn(rust_2018_idioms)]
22
// Wasi does not support panic recovery or threading
3-
#![cfg(all(feature = "full", not(target_os = "wasi"), not(miri)))]
3+
#![cfg(all(feature = "full", not(target_os = "wasi")))]
44

55
use tokio::net::TcpListener;
66
use tokio::runtime;
@@ -32,6 +32,7 @@ impl<T> Task<T> {
3232
}
3333

3434
#[test]
35+
#[cfg_attr(miri, ignore)] // No `socket` in miri.
3536
fn test_drop_on_notify() {
3637
// When the reactor receives a kernel notification, it notifies the
3738
// task that holds the associated socket. If this notification results in
@@ -90,6 +91,7 @@ fn test_drop_on_notify() {
9091
#[should_panic(
9192
expected = "A Tokio 1.x context was found, but IO is disabled. Call `enable_io` on the runtime builder to enable IO."
9293
)]
94+
#[cfg_attr(miri, ignore)] // No `socket` in miri.
9395
fn panics_when_io_disabled() {
9496
let rt = runtime::Builder::new_current_thread().build().unwrap();
9597

tokio/tests/io_driver_drop.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
11
#![warn(rust_2018_idioms)]
2-
#![cfg(all(feature = "full", not(target_os = "wasi"), not(miri)))] // Wasi does not support bind
2+
#![cfg(all(feature = "full", not(target_os = "wasi")))] // Wasi does not support bind
33

44
use tokio::net::TcpListener;
55
use tokio::runtime;
66
use tokio_test::{assert_err, assert_pending, assert_ready, task};
77

88
#[test]
9+
#[cfg_attr(miri, ignore)] // No `socket` in miri.
910
fn tcp_doesnt_block() {
1011
let rt = rt();
1112

@@ -25,6 +26,7 @@ fn tcp_doesnt_block() {
2526
}
2627

2728
#[test]
29+
#[cfg_attr(miri, ignore)] // No `socket` in miri.
2830
fn drop_wakes() {
2931
let rt = rt();
3032

tokio/tests/net_bind_resource.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
11
#![warn(rust_2018_idioms)]
2-
#![cfg(all(feature = "full", not(target_os = "wasi"), not(miri)))] // Wasi doesn't support panic recovery or bind
2+
#![cfg(all(feature = "full", not(target_os = "wasi")))] // Wasi doesn't support panic recovery or bind
33

44
use tokio::net::TcpListener;
55

66
use std::net;
77

88
#[test]
99
#[should_panic]
10+
#[cfg_attr(miri, ignore)] // No `socket` in miri.
1011
fn no_runtime_panics_binding_net_tcp_listener() {
1112
let listener = net::TcpListener::bind("127.0.0.1:0").expect("failed to bind listener");
1213
let _ = TcpListener::try_from(listener);

tokio/tests/net_lookup_host.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ async fn lookup_str_socket_addr() {
2323
}
2424

2525
#[tokio::test]
26-
#[cfg_attr(miri, ignore)]
26+
#[cfg_attr(miri, ignore)] // No `getaddrinfo` in miri.
2727
async fn resolve_dns() -> io::Result<()> {
2828
let mut hosts = net::lookup_host("localhost:3000").await?;
2929
let host = hosts.next().unwrap();

tokio/tests/net_panic.rs

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#![warn(rust_2018_idioms)]
2-
#![cfg(all(feature = "full", not(target_os = "wasi"), not(miri)))]
2+
#![cfg(all(feature = "full", not(target_os = "wasi")))]
33
#![cfg(panic = "unwind")]
44

55
use std::error::Error;
@@ -12,6 +12,7 @@ mod support {
1212
use support::panic::test_panic;
1313

1414
#[test]
15+
#[cfg_attr(miri, ignore)] // No `socket` in miri.
1516
fn udp_socket_from_std_panic_caller() -> Result<(), Box<dyn Error>> {
1617
use std::net::SocketAddr;
1718
use tokio::net::UdpSocket;
@@ -34,6 +35,7 @@ fn udp_socket_from_std_panic_caller() -> Result<(), Box<dyn Error>> {
3435
}
3536

3637
#[test]
38+
#[cfg_attr(miri, ignore)] // No `socket` in miri.
3739
fn tcp_listener_from_std_panic_caller() -> Result<(), Box<dyn Error>> {
3840
let std_listener = std::net::TcpListener::bind("127.0.0.1:0").unwrap();
3941
std_listener.set_nonblocking(true).unwrap();
@@ -52,6 +54,7 @@ fn tcp_listener_from_std_panic_caller() -> Result<(), Box<dyn Error>> {
5254
}
5355

5456
#[test]
57+
#[cfg_attr(miri, ignore)] // No `socket` in miri.
5558
fn tcp_stream_from_std_panic_caller() -> Result<(), Box<dyn Error>> {
5659
let std_listener = std::net::TcpListener::bind("127.0.0.1:0").unwrap();
5760

@@ -73,6 +76,7 @@ fn tcp_stream_from_std_panic_caller() -> Result<(), Box<dyn Error>> {
7376

7477
#[test]
7578
#[cfg(unix)]
79+
#[cfg_attr(miri, ignore)] // No `socket` in miri.
7680
fn unix_listener_bind_panic_caller() -> Result<(), Box<dyn Error>> {
7781
use tokio::net::UnixListener;
7882

@@ -94,6 +98,7 @@ fn unix_listener_bind_panic_caller() -> Result<(), Box<dyn Error>> {
9498

9599
#[test]
96100
#[cfg(unix)]
101+
#[cfg_attr(miri, ignore)] // No `socket` in miri.
97102
fn unix_listener_from_std_panic_caller() -> Result<(), Box<dyn Error>> {
98103
use tokio::net::UnixListener;
99104

@@ -116,6 +121,7 @@ fn unix_listener_from_std_panic_caller() -> Result<(), Box<dyn Error>> {
116121

117122
#[test]
118123
#[cfg(unix)]
124+
#[cfg_attr(miri, ignore)] // No `socket` in miri.
119125
fn unix_stream_from_std_panic_caller() -> Result<(), Box<dyn Error>> {
120126
use tokio::net::UnixStream;
121127

@@ -139,6 +145,7 @@ fn unix_stream_from_std_panic_caller() -> Result<(), Box<dyn Error>> {
139145

140146
#[test]
141147
#[cfg(unix)]
148+
#[cfg_attr(miri, ignore)] // No `socket` in miri.
142149
fn unix_datagram_from_std_panic_caller() -> Result<(), Box<dyn Error>> {
143150
use std::os::unix::net::UnixDatagram as StdUDS;
144151
use tokio::net::UnixDatagram;

tokio/tests/net_unix_pipe.rs

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
#![cfg(feature = "full")]
22
#![cfg(unix)]
3-
#![cfg(not(miri))]
43

54
use tokio::io::{AsyncReadExt, AsyncWriteExt, Interest};
65
use tokio::net::unix::pipe;
@@ -38,6 +37,7 @@ impl AsRef<Path> for TempFifo {
3837
}
3938

4039
#[tokio::test]
40+
#[cfg_attr(miri, ignore)] // No `mkfifo` in miri.
4141
async fn fifo_simple_send() -> io::Result<()> {
4242
const DATA: &[u8] = b"this is some data to write to the fifo";
4343

@@ -69,6 +69,7 @@ async fn fifo_simple_send() -> io::Result<()> {
6969

7070
#[tokio::test]
7171
#[cfg(target_os = "linux")]
72+
#[cfg_attr(miri, ignore)] // No `mkfifo` in miri.
7273
async fn fifo_simple_send_sender_first() -> io::Result<()> {
7374
const DATA: &[u8] = b"this is some data to write to the fifo";
7475

@@ -105,6 +106,7 @@ async fn write_and_close(path: impl AsRef<Path>, msg: &[u8]) -> io::Result<()> {
105106
/// Checks EOF behavior with single reader and writers sequentially opening
106107
/// and closing a FIFO.
107108
#[tokio::test]
109+
#[cfg_attr(miri, ignore)] // No `mkfifo` in miri.
108110
async fn fifo_multiple_writes() -> io::Result<()> {
109111
const DATA: &[u8] = b"this is some data to write to the fifo";
110112

@@ -133,6 +135,7 @@ async fn fifo_multiple_writes() -> io::Result<()> {
133135
/// with writers sequentially opening and closing a FIFO.
134136
#[tokio::test]
135137
#[cfg(target_os = "linux")]
138+
#[cfg_attr(miri, ignore)] // No `socket` in miri.
136139
async fn fifo_resilient_reader() -> io::Result<()> {
137140
const DATA: &[u8] = b"this is some data to write to the fifo";
138141

@@ -163,6 +166,7 @@ async fn fifo_resilient_reader() -> io::Result<()> {
163166
}
164167

165168
#[tokio::test]
169+
#[cfg_attr(miri, ignore)] // No `O_NONBLOCK` for open64 in miri.
166170
async fn open_detects_not_a_fifo() -> io::Result<()> {
167171
let dir = tempfile::Builder::new()
168172
.prefix("tokio-fifo-tests")
@@ -185,6 +189,7 @@ async fn open_detects_not_a_fifo() -> io::Result<()> {
185189
}
186190

187191
#[tokio::test]
192+
#[cfg_attr(miri, ignore)] // No `mkfifo` in miri.
188193
async fn from_file() -> io::Result<()> {
189194
const DATA: &[u8] = b"this is some data to write to the fifo";
190195

@@ -221,6 +226,7 @@ async fn from_file() -> io::Result<()> {
221226
}
222227

223228
#[tokio::test]
229+
#[cfg_attr(miri, ignore)] // No `fstat` in miri.
224230
async fn from_file_detects_not_a_fifo() -> io::Result<()> {
225231
let dir = tempfile::Builder::new()
226232
.prefix("tokio-fifo-tests")
@@ -245,6 +251,7 @@ async fn from_file_detects_not_a_fifo() -> io::Result<()> {
245251
}
246252

247253
#[tokio::test]
254+
#[cfg_attr(miri, ignore)] // No `mkfifo` in miri.
248255
async fn from_file_detects_wrong_access_mode() -> io::Result<()> {
249256
let fifo = TempFifo::new("wrong_access_mode")?;
250257

@@ -276,6 +283,7 @@ fn is_nonblocking<T: AsRawFd>(fd: &T) -> io::Result<bool> {
276283
}
277284

278285
#[tokio::test]
286+
#[cfg_attr(miri, ignore)] // No `mkfifo` in miri.
279287
async fn from_file_sets_nonblock() -> io::Result<()> {
280288
let fifo = TempFifo::new("sets_nonblock")?;
281289

@@ -303,6 +311,7 @@ fn writable_by_poll(writer: &pipe::Sender) -> bool {
303311
}
304312

305313
#[tokio::test]
314+
#[cfg_attr(miri, ignore)] // No `mkfifo` in miri.
306315
async fn try_read_write() -> io::Result<()> {
307316
const DATA: &[u8] = b"this is some data to write to the fifo";
308317

@@ -343,6 +352,7 @@ async fn try_read_write() -> io::Result<()> {
343352
}
344353

345354
#[tokio::test]
355+
#[cfg_attr(miri, ignore)] // No `mkfifo` in miri.
346356
async fn try_read_write_vectored() -> io::Result<()> {
347357
const DATA: &[u8] = b"this is some data to write to the fifo";
348358

@@ -390,6 +400,7 @@ async fn try_read_write_vectored() -> io::Result<()> {
390400
}
391401

392402
#[tokio::test]
403+
#[cfg_attr(miri, ignore)] // No `mkfifo` in miri.
393404
async fn try_read_buf() -> std::io::Result<()> {
394405
const DATA: &[u8] = b"this is some data to write to the fifo";
395406

@@ -458,6 +469,7 @@ async fn anon_pipe_simple_send() -> io::Result<()> {
458469
}
459470

460471
#[tokio::test]
472+
#[cfg_attr(miri, ignore)] // No F_GETFL for fcntl in miri.
461473
async fn anon_pipe_spawn_echo() -> std::io::Result<()> {
462474
use tokio::process::Command;
463475

@@ -488,6 +500,7 @@ async fn anon_pipe_spawn_echo() -> std::io::Result<()> {
488500

489501
#[tokio::test]
490502
#[cfg(target_os = "linux")]
503+
#[cfg_attr(miri, ignore)] // No `fstat` in miri.
491504
async fn anon_pipe_from_owned_fd() -> std::io::Result<()> {
492505
use nix::fcntl::OFlag;
493506

@@ -507,6 +520,7 @@ async fn anon_pipe_from_owned_fd() -> std::io::Result<()> {
507520
}
508521

509522
#[tokio::test]
523+
#[cfg_attr(miri, ignore)] // No F_GETFL for fcntl in miri.
510524
async fn anon_pipe_into_nonblocking_fd() -> std::io::Result<()> {
511525
let (tx, rx) = pipe::pipe()?;
512526

@@ -520,6 +534,7 @@ async fn anon_pipe_into_nonblocking_fd() -> std::io::Result<()> {
520534
}
521535

522536
#[tokio::test]
537+
#[cfg_attr(miri, ignore)] // No F_GETFL for fcntl in miri.
523538
async fn anon_pipe_into_blocking_fd() -> std::io::Result<()> {
524539
let (tx, rx) = pipe::pipe()?;
525540

tokio/tests/no_rt.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#![cfg(all(feature = "full", not(target_os = "wasi"), not(miri)))] // Wasi does not support panic recovery
1+
#![cfg(all(feature = "full", not(target_os = "wasi")))] // Wasi does not support panic recovery
22

33
use tokio::net::TcpStream;
44
use tokio::sync::oneshot;
@@ -20,6 +20,7 @@ fn timeout_panics_when_no_tokio_context() {
2020
#[should_panic(
2121
expected = "there is no reactor running, must be called from the context of a Tokio 1.x runtime"
2222
)]
23+
#[cfg_attr(miri, ignore)] // No `socket` in miri.
2324
fn panics_when_no_reactor() {
2425
let srv = TcpListener::bind("127.0.0.1:0").unwrap();
2526
let addr = srv.local_addr().unwrap();
@@ -36,6 +37,7 @@ async fn timeout_value() {
3637
#[should_panic(
3738
expected = "there is no reactor running, must be called from the context of a Tokio 1.x runtime"
3839
)]
40+
#[cfg_attr(miri, ignore)] // No `socket` in miri.
3941
fn io_panics_when_no_tokio_context() {
4042
let _ = tokio::net::TcpListener::from_std(std::net::TcpListener::bind("127.0.0.1:0").unwrap());
4143
}

0 commit comments

Comments
 (0)