Skip to content

Commit

Permalink
Add annotation for tests with miri ignore
Browse files Browse the repository at this point in the history
  • Loading branch information
tiif committed Nov 19, 2024
1 parent bb7ca75 commit 66e3947
Show file tree
Hide file tree
Showing 37 changed files with 101 additions and 25 deletions.
1 change: 1 addition & 0 deletions tokio-stream/tests/stream_chain.rs
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ where
}

#[tokio::test]
#[cfg_attr(miri, ignore)] // Block on https://github.com/tokio-rs/tokio/issues/6860
async fn pending_first() {
let (tx1, rx1) = mpsc::unbounded_channel_stream();
let (tx2, rx2) = mpsc::unbounded_channel_stream();
Expand Down
2 changes: 1 addition & 1 deletion tokio/tests/buffered.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ use std::net::TcpStream;
use std::thread;

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

Expand Down
2 changes: 1 addition & 1 deletion tokio/tests/coop_budget.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ use tokio::net::UdpSocket;
/// Since we are both sending and receiving, that should happen once per 64 packets, because budgets are of size 128
/// and there are two budget events per packet, a send and a recv.
#[tokio::test]
#[cfg_attr(miri, ignore)]
#[cfg_attr(miri, ignore)] // No `socket` on miri.
async fn coop_budget_udp_send_recv() {
const BUDGET: usize = 128;
const N_ITERATIONS: usize = 1024;
Expand Down
4 changes: 2 additions & 2 deletions tokio/tests/fs_copy.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ use tempfile::tempdir;
use tokio::fs;

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

Expand All @@ -22,7 +22,7 @@ async fn copy() {
}

#[tokio::test]
#[cfg_attr(miri, ignore)]
#[cfg_attr(miri, ignore)] // No `fchmod` in miri.
async fn copy_permissions() {
let dir = tempdir().unwrap();
let from_path = dir.path().join("foo.txt");
Expand Down
2 changes: 1 addition & 1 deletion tokio/tests/fs_link.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ use std::io::Write;
use tempfile::tempdir;

#[tokio::test]
#[cfg_attr(miri, ignore)]
#[cfg_attr(miri, ignore)] // No `linkat` in miri.
async fn test_hard_link() {
let dir = tempdir().unwrap();
let src = dir.path().join("src.txt");
Expand Down
2 changes: 1 addition & 1 deletion tokio/tests/fs_try_exists.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ use tempfile::tempdir;
use tokio::fs;

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

Expand Down
5 changes: 3 additions & 2 deletions tokio/tests/io_async_fd.rs
Original file line number Diff line number Diff line change
Expand Up @@ -616,6 +616,7 @@ fn driver_shutdown_wakes_poll_race() {

#[tokio::test]
#[cfg(any(target_os = "linux", target_os = "android"))]
#[cfg_attr(miri, ignore)] // No `socket` in miri.
async fn priority_event_on_oob_data() {
use std::net::SocketAddr;

Expand Down Expand Up @@ -704,7 +705,7 @@ async fn clear_ready_matching_clears_ready_mut() {

#[tokio::test]
#[cfg(target_os = "linux")]
#[cfg_attr(miri, ignore)]
#[cfg_attr(miri, ignore)] // No `socket` in miri.
async fn await_error_readiness_timestamping() {
use std::net::{Ipv4Addr, SocketAddr};

Expand Down Expand Up @@ -761,7 +762,7 @@ fn configure_timestamping_socket(udp_socket: &std::net::UdpSocket) -> std::io::R

#[tokio::test]
#[cfg(target_os = "linux")]
#[cfg_attr(miri, ignore)]
#[cfg_attr(miri, ignore)] // No `socket` in miri.
async fn await_error_readiness_invalid_address() {
use std::net::{Ipv4Addr, SocketAddr};
use tokio::io::{Interest, Ready};
Expand Down
5 changes: 4 additions & 1 deletion tokio/tests/io_copy_bidirectional.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#![warn(rust_2018_idioms)]
#![cfg(all(feature = "full", not(target_os = "wasi"), not(miri)))] // Wasi does not support bind()
#![cfg(all(feature = "full", not(target_os = "wasi")))] // Wasi does not support bind()

use std::time::Duration;
use tokio::io::{self, copy_bidirectional, AsyncReadExt, AsyncWriteExt};
Expand Down Expand Up @@ -59,6 +59,7 @@ where
}

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

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

#[tokio::test]
#[cfg_attr(miri, ignore)] // No `socket` in miri.
async fn blocking_one_side_does_not_block_other() {
symmetric(|handle, mut a, mut b| async move {
block_write(&mut a).await;
Expand Down
4 changes: 3 additions & 1 deletion tokio/tests/io_driver.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#![warn(rust_2018_idioms)]
// Wasi does not support panic recovery or threading
#![cfg(all(feature = "full", not(target_os = "wasi"), not(miri)))]
#![cfg(all(feature = "full", not(target_os = "wasi")))]

use tokio::net::TcpListener;
use tokio::runtime;
Expand Down Expand Up @@ -32,6 +32,7 @@ impl<T> Task<T> {
}

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

Expand Down
4 changes: 3 additions & 1 deletion tokio/tests/io_driver_drop.rs
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
#![warn(rust_2018_idioms)]
#![cfg(all(feature = "full", not(target_os = "wasi"), not(miri)))] // Wasi does not support bind
#![cfg(all(feature = "full", not(target_os = "wasi")))] // Wasi does not support bind

use tokio::net::TcpListener;
use tokio::runtime;
use tokio_test::{assert_err, assert_pending, assert_ready, task};

#[test]
#[cfg_attr(miri, ignore)] // No `socket` in miri.
fn tcp_doesnt_block() {
let rt = rt();

Expand All @@ -25,6 +26,7 @@ fn tcp_doesnt_block() {
}

#[test]
#[cfg_attr(miri, ignore)] // No `socket` in miri.
fn drop_wakes() {
let rt = rt();

Expand Down
3 changes: 2 additions & 1 deletion tokio/tests/net_bind_resource.rs
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
#![warn(rust_2018_idioms)]
#![cfg(all(feature = "full", not(target_os = "wasi"), not(miri)))] // Wasi doesn't support panic recovery or bind
#![cfg(all(feature = "full", not(target_os = "wasi")))] // Wasi doesn't support panic recovery or bind

use tokio::net::TcpListener;

use std::net;

#[test]
#[should_panic]
#[cfg_attr(miri, ignore)] // No `socket` in miri.
fn no_runtime_panics_binding_net_tcp_listener() {
let listener = net::TcpListener::bind("127.0.0.1:0").expect("failed to bind listener");
let _ = TcpListener::try_from(listener);
Expand Down
2 changes: 1 addition & 1 deletion tokio/tests/net_lookup_host.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ async fn lookup_str_socket_addr() {
}

#[tokio::test]
#[cfg_attr(miri, ignore)]
#[cfg_attr(miri, ignore)] // No `getaddrinfo` in miri.
async fn resolve_dns() -> io::Result<()> {
let mut hosts = net::lookup_host("localhost:3000").await?;
let host = hosts.next().unwrap();
Expand Down
9 changes: 8 additions & 1 deletion tokio/tests/net_panic.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#![warn(rust_2018_idioms)]
#![cfg(all(feature = "full", not(target_os = "wasi"), not(miri)))]
#![cfg(all(feature = "full", not(target_os = "wasi")))]
#![cfg(panic = "unwind")]

use std::error::Error;
Expand All @@ -12,6 +12,7 @@ mod support {
use support::panic::test_panic;

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

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

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

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

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

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

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

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

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

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

#[test]
#[cfg(unix)]
#[cfg_attr(miri, ignore)] // No `socket` in miri.
fn unix_datagram_from_std_panic_caller() -> Result<(), Box<dyn Error>> {
use std::os::unix::net::UnixDatagram as StdUDS;
use tokio::net::UnixDatagram;
Expand Down
17 changes: 16 additions & 1 deletion tokio/tests/net_unix_pipe.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
#![cfg(feature = "full")]
#![cfg(unix)]
#![cfg(not(miri))]

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Expand Down
Loading

0 comments on commit 66e3947

Please sign in to comment.