Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add annotation for tests with miri ignore #6981

Merged
merged 3 commits into from
Nov 20, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -18,7 +18,7 @@ env:
rust_stable: stable
rust_nightly: nightly-2024-05-05
# Pin a specific miri version
rust_miri_nightly: nightly-2024-09-19
rust_miri_nightly: nightly-2024-10-21
rust_clippy: '1.77'
# When updating this, also update:
# - README.md
1 change: 1 addition & 0 deletions tokio-stream/tests/stream_chain.rs
Original file line number Diff line number Diff line change
@@ -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();
2 changes: 1 addition & 1 deletion tokio/tests/buffered.rs
Original file line number Diff line number Diff line change
@@ -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;

2 changes: 1 addition & 1 deletion tokio/tests/coop_budget.rs
Original file line number Diff line number Diff line change
@@ -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;
4 changes: 2 additions & 2 deletions tokio/tests/fs_copy.rs
Original file line number Diff line number Diff line change
@@ -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();

@@ -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");
2 changes: 1 addition & 1 deletion tokio/tests/fs_link.rs
Original file line number Diff line number Diff line change
@@ -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");
2 changes: 1 addition & 1 deletion tokio/tests/fs_try_exists.rs
Original file line number Diff line number Diff line change
@@ -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();

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};
@@ -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();
@@ -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();
@@ -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;
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;
@@ -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
@@ -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();

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();

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

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

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);
2 changes: 1 addition & 1 deletion tokio/tests/net_lookup_host.rs
Original file line number Diff line number Diff line change
@@ -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();
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;
@@ -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;
@@ -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();
@@ -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();

@@ -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;

@@ -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;

@@ -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;

@@ -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;
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;
@@ -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";

@@ -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";

@@ -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";

@@ -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";

@@ -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")
@@ -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";

@@ -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")
@@ -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")?;

@@ -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")?;

@@ -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";

@@ -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";

@@ -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";

@@ -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;

@@ -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;

@@ -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()?;

@@ -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()?;

4 changes: 3 additions & 1 deletion tokio/tests/no_rt.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#![cfg(all(feature = "full", not(target_os = "wasi"), not(miri)))] // Wasi does not support panic recovery
#![cfg(all(feature = "full", not(target_os = "wasi")))] // Wasi does not support panic recovery

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