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 more test to be tested with miri in CI #6885

Merged
merged 15 commits into from
Oct 11, 2024
7 changes: 3 additions & 4 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -420,14 +420,13 @@ jobs:
components: miri
- uses: Swatinem/rust-cache@v2
- name: miri
# Many of tests in tokio/tests and doctests use #[tokio::test] or
# #[tokio::main] that calls epoll_create1 that Miri does not support.
run: |
cargo miri test --features full --lib --no-fail-fast
rustup toolchain install nightly-2024-09-19 --component miri --profile minimal --no-self-update
rustup override set nightly
cargo miri test --features full --lib --tests --no-fail-fast
Copy link
Contributor Author

@tiif tiif Oct 10, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am trying to keep the change minimal, so I don't really want to change env.rust_nightly, but I am not sure if this will work.

EDIT: This won't work

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We'll probably want to get them back in sync as a follow-up PR, then.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you mean rust_miri_nightly and rust_nightly?

working-directory: tokio
env:
MIRIFLAGS: -Zmiri-disable-isolation -Zmiri-strict-provenance -Zmiri-retag-fields

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Deleting this line seems like a spurious change.

asan:
name: asan
needs: basics
Expand Down
1 change: 1 addition & 0 deletions tests-build/tests/macros.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#[test]
#[cfg_attr(miri, ignore)]
fn compile_fail_full() {
let t = trybuild::TestCases::new();

Expand Down
2 changes: 1 addition & 1 deletion tests-integration/tests/process_stdio.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")))]
#![cfg(all(feature = "full", not(target_os = "wasi"), not(miri)))]

use tokio::io::{AsyncBufReadExt, AsyncReadExt, AsyncWriteExt, BufReader};
use tokio::join;
Expand Down
2 changes: 2 additions & 0 deletions tokio-util/tests/spawn_pinned.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
#![warn(rust_2018_idioms)]
#![cfg(not(target_os = "wasi"))] // Wasi doesn't support threads
// Blocked on https://github.com/rust-lang/miri/issues/3911
#![cfg(not(miri))]
Comment on lines +3 to +4
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Was this fixed?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, but I don't think the latest fix is synced to rustc yet.


use std::rc::Rc;
use std::sync::Arc;
Expand Down
1 change: 1 addition & 0 deletions tokio-util/tests/udp.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#![warn(rust_2018_idioms)]
#![cfg(not(target_os = "wasi"))] // Wasi doesn't support UDP
#![cfg(not(miri))] // No `socket` in Miri.

use tokio::net::UdpSocket;
use tokio_stream::StreamExt;
Expand Down
1 change: 1 addition & 0 deletions tokio/tests/buffered.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ use std::net::TcpStream;
use std::thread;

#[tokio::test]
#[cfg_attr(miri, ignore)]
async fn echo_server() {
const N: usize = 1024;

Expand Down
1 change: 1 addition & 0 deletions tokio/tests/coop_budget.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +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)]
async fn coop_budget_udp_send_recv() {
const BUDGET: usize = 128;
const N_ITERATIONS: usize = 1024;
Expand Down
2 changes: 2 additions & 0 deletions tokio/tests/fs_copy.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ use tempfile::tempdir;
use tokio::fs;

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

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

#[tokio::test]
#[cfg_attr(miri, ignore)]
async fn copy_permissions() {
let dir = tempdir().unwrap();
let from_path = dir.path().join("foo.txt");
Expand Down
1 change: 1 addition & 0 deletions tokio/tests/fs_file.rs
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,7 @@ async fn set_max_buf_size_write() {
}

#[tokio::test]
#[cfg_attr(miri, ignore)]
#[cfg(unix)]
async fn file_debug_fmt() {
let tempfile = tempfile();
Expand Down
1 change: 1 addition & 0 deletions tokio/tests/fs_link.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ use std::io::Write;
use tempfile::tempdir;

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

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

Expand Down
6 changes: 5 additions & 1 deletion tokio/tests/io_async_fd.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#![warn(rust_2018_idioms)]
#![cfg(all(unix, feature = "full"))]
#![cfg(all(unix, feature = "full", not(miri)))]

use std::os::unix::io::{AsRawFd, RawFd};
use std::sync::{
Expand Down Expand Up @@ -655,6 +655,7 @@ fn send_oob_data<S: AsRawFd>(stream: &S, data: &[u8]) -> io::Result<usize> {
}

#[tokio::test]
#[cfg_attr(miri, ignore)]
async fn clear_ready_matching_clears_ready() {
use tokio::io::{Interest, Ready};

Expand All @@ -678,6 +679,7 @@ async fn clear_ready_matching_clears_ready() {
}

#[tokio::test]
#[cfg_attr(miri, ignore)]
async fn clear_ready_matching_clears_ready_mut() {
use tokio::io::{Interest, Ready};

Expand All @@ -702,6 +704,7 @@ async fn clear_ready_matching_clears_ready_mut() {

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

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

#[tokio::test]
#[cfg(target_os = "linux")]
#[cfg_attr(miri, ignore)]
async fn await_error_readiness_invalid_address() {
use std::net::{Ipv4Addr, SocketAddr};
use tokio::io::{Interest, Ready};
Expand Down
2 changes: 1 addition & 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")))] // Wasi does not support bind()
#![cfg(all(feature = "full", not(target_os = "wasi"), not(miri)))] // Wasi does not support bind()

use std::time::Duration;
use tokio::io::{self, copy_bidirectional, AsyncReadExt, AsyncWriteExt};
Expand Down
2 changes: 1 addition & 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")))]
#![cfg(all(feature = "full", not(target_os = "wasi"), not(miri)))]

use tokio::net::TcpListener;
use tokio::runtime;
Expand Down
2 changes: 1 addition & 1 deletion tokio/tests/io_driver_drop.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")))] // Wasi does not support bind
#![cfg(all(feature = "full", not(target_os = "wasi"), not(miri)))] // Wasi does not support bind

use tokio::net::TcpListener;
use tokio::runtime;
Expand Down
1 change: 1 addition & 0 deletions tokio/tests/io_read_to_end.rs
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ async fn read_to_end_uninit() {
}

#[tokio::test]
#[cfg_attr(miri, ignore)] // too slow with miri
async fn read_to_end_doesnt_grow_with_capacity() {
let arr: Vec<u8> = (0..100).collect();

Expand Down
2 changes: 1 addition & 1 deletion tokio/tests/io_repeat.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#![warn(rust_2018_idioms)]
#![cfg(feature = "full")]
#![cfg(all(feature = "full", not(miri)))]

use tokio::io::AsyncReadExt;

Expand Down
2 changes: 1 addition & 1 deletion tokio/tests/net_bind_resource.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")))] // Wasi doesn't support panic recovery or bind
#![cfg(all(feature = "full", not(target_os = "wasi"), not(miri)))] // Wasi doesn't support panic recovery or bind

use tokio::net::TcpListener;

Expand Down
1 change: 1 addition & 0 deletions tokio/tests/net_lookup_host.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ async fn lookup_str_socket_addr() {
}

#[tokio::test]
#[cfg_attr(miri, ignore)]
async fn resolve_dns() -> io::Result<()> {
let mut hosts = net::lookup_host("localhost:3000").await?;
let host = hosts.next().unwrap();
Expand Down
2 changes: 1 addition & 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")))]
#![cfg(all(feature = "full", not(target_os = "wasi"), not(miri)))]
#![cfg(panic = "unwind")]

use std::error::Error;
Expand Down
1 change: 1 addition & 0 deletions tokio/tests/net_unix_pipe.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#![cfg(feature = "full")]
#![cfg(unix)]
#![cfg(not(miri))]

use tokio::io::{AsyncReadExt, AsyncWriteExt, Interest};
use tokio::net::unix::pipe;
Expand Down
2 changes: 1 addition & 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")))] // Wasi does not support panic recovery
#![cfg(all(feature = "full", not(target_os = "wasi"), not(miri)))] // Wasi does not support panic recovery

use tokio::net::TcpStream;
use tokio::sync::oneshot;
Expand Down
2 changes: 1 addition & 1 deletion tokio/tests/process_arg0.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#![warn(rust_2018_idioms)]
#![cfg(all(feature = "full", unix))]
#![cfg(all(feature = "full", unix, not(miri)))]

use tokio::process::Command;

Expand Down
2 changes: 1 addition & 1 deletion tokio/tests/process_change_of_runtime.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
// This tests test the behavior of `process::Command::spawn` when it is used
// outside runtime, and when `process::Child::wait ` is used in a different
// runtime from which `process::Command::spawn` is used.
#![cfg(all(unix, not(target_os = "freebsd")))]
#![cfg(all(unix, not(target_os = "freebsd"), not(miri)))]

use std::process::Stdio;
use tokio::{process::Command, runtime::Runtime};
Expand Down
2 changes: 1 addition & 1 deletion tokio/tests/process_issue_2174.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
// It is expected that `EVFILT_WRITE` would be returned with either the
// `EV_EOF` or `EV_ERROR` flag set. If either flag is set a write would be
// attempted, but that does not seem to occur.
#![cfg(all(unix, not(target_os = "freebsd")))]
#![cfg(all(unix, not(target_os = "freebsd"), not(miri)))]

use std::process::Stdio;
use std::time::Duration;
Expand Down
1 change: 1 addition & 0 deletions tokio/tests/process_issue_42.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#![warn(rust_2018_idioms)]
#![cfg(feature = "full")]
#![cfg(unix)]
#![cfg(not(miri))]

use futures::future::join_all;
use std::process::Stdio;
Expand Down
2 changes: 1 addition & 1 deletion tokio/tests/process_kill_on_drop.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#![cfg(all(unix, feature = "process"))]
#![cfg(all(unix, feature = "process", not(miri)))]
#![warn(rust_2018_idioms)]

use std::io::ErrorKind;
Expand Down
1 change: 1 addition & 0 deletions tokio/tests/process_raw_handle.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#![warn(rust_2018_idioms)]
#![cfg(feature = "full")]
#![cfg(windows)]
#![cfg(not(miri))]

use tokio::process::Command;
use windows_sys::Win32::System::Threading::GetProcessId;
Expand Down
2 changes: 1 addition & 1 deletion tokio/tests/process_smoke.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")))] // Wasi cannot run system commands
#![cfg(all(feature = "full", not(target_os = "wasi"), not(miri)))] // Wasi cannot run system commands

use tokio::process::Command;
use tokio_test::assert_ok;
Expand Down
1 change: 1 addition & 0 deletions tokio/tests/rt_basic.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#![allow(unknown_lints, unexpected_cfgs)]
#![warn(rust_2018_idioms)]
#![cfg(feature = "full")]
#![cfg(not(miri))] // Possible bug on Miri.

use tokio::runtime::Runtime;
use tokio::sync::oneshot;
Expand Down
1 change: 1 addition & 0 deletions tokio/tests/rt_common.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
#![allow(clippy::needless_range_loop)]
#![warn(rust_2018_idioms)]
#![cfg(feature = "full")]
#![cfg(not(miri))]

// Tests to run on both current-thread & multi-thread runtime variants.

Expand Down
4 changes: 3 additions & 1 deletion tokio/tests/rt_handle_block_on.rs
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This both disables miri for the entire file and for specific tests.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Right, thanks for catching this.

Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#![warn(rust_2018_idioms)]
#![cfg(feature = "full")]
#![cfg(all(feature = "full", not(miri)))]

// All io tests that deal with shutdown is currently ignored because there are known bugs in with
// shutting down the io driver while concurrently registering new resources. See
Expand Down Expand Up @@ -143,6 +143,7 @@ rt_test! {
}

#[test]
#[cfg_attr(miri, ignore)]
fn fs_shutdown_before_started() {
let rt = rt();
let _enter = rt.enter();
Expand Down Expand Up @@ -175,6 +176,7 @@ rt_test! {
}

#[test]
#[cfg_attr(miri, ignore)]
fn spawn_blocking_after_shutdown_fails() {
use tokio::task::spawn_blocking;
let rt = rt();
Expand Down
5 changes: 4 additions & 1 deletion tokio/tests/rt_threaded.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#![allow(unknown_lints, unexpected_cfgs)]
#![warn(rust_2018_idioms)]
#![cfg(all(feature = "full", not(target_os = "wasi")))]
// Too slow on miri.
#![cfg(all(feature = "full", not(target_os = "wasi"), not(miri)))]

use tokio::io::{AsyncReadExt, AsyncWriteExt};
use tokio::net::{TcpListener, TcpStream};
Expand Down Expand Up @@ -322,6 +323,8 @@ fn start_stop_callbacks_called() {
}

#[test]
// too slow on miri
#[cfg_attr(miri, ignore)]
fn blocking() {
// used for notifying the main thread
const NUM: usize = 1_000;
Expand Down
1 change: 1 addition & 0 deletions tokio/tests/signal_ctrl_c.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#![warn(rust_2018_idioms)]
#![cfg(feature = "full")]
#![cfg(unix)]
#![cfg(not(miri))] // No `sigaction` on Miri

mod support {
pub mod signal;
Expand Down
1 change: 1 addition & 0 deletions tokio/tests/signal_drop_recv.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#![warn(rust_2018_idioms)]
#![cfg(feature = "full")]
#![cfg(unix)]
#![cfg(not(miri))]

mod support {
pub mod signal;
Expand Down
1 change: 1 addition & 0 deletions tokio/tests/signal_drop_rt.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#![warn(rust_2018_idioms)]
#![cfg(feature = "full")]
#![cfg(unix)]
#![cfg(not(miri))]

mod support {
pub mod signal;
Expand Down
1 change: 1 addition & 0 deletions tokio/tests/signal_drop_signal.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#![warn(rust_2018_idioms)]
#![cfg(feature = "full")]
#![cfg(unix)]
#![cfg(not(miri))]

mod support {
pub mod signal;
Expand Down
1 change: 1 addition & 0 deletions tokio/tests/signal_multi_rt.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#![warn(rust_2018_idioms)]
#![cfg(feature = "full")]
#![cfg(unix)]
#![cfg(not(miri))] // No `sigaction` on Miri.

mod support {
pub mod signal;
Expand Down
1 change: 1 addition & 0 deletions tokio/tests/signal_no_rt.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#![warn(rust_2018_idioms)]
#![cfg(feature = "full")]
#![cfg(unix)]
#![cfg(not(miri))] // No `sigaction` on Miri.

use tokio::signal::unix::{signal, SignalKind};

Expand Down
1 change: 1 addition & 0 deletions tokio/tests/signal_notify_both.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#![warn(rust_2018_idioms)]
#![cfg(feature = "full")]
#![cfg(unix)]
#![cfg(not(miri))] // No `sigaction` on Miri.

mod support {
pub mod signal;
Expand Down
1 change: 1 addition & 0 deletions tokio/tests/signal_panic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
#![cfg(feature = "full")]
#![cfg(unix)]
#![cfg(panic = "unwind")]
#![cfg(not(miri))] // No `sigaction` on Miri.

use std::error::Error;
use tokio::runtime::Builder;
Expand Down
1 change: 1 addition & 0 deletions tokio/tests/signal_twice.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#![warn(rust_2018_idioms)]
#![cfg(feature = "full")]
#![cfg(unix)]
#![cfg(not(miri))] // No `sigaction` on Miri.

mod support {
pub mod signal;
Expand Down
Loading
Loading