From 91b3fa74511e7a936ede56db99a3aa626c0ca77c Mon Sep 17 00:00:00 2001 From: tiif Date: Sat, 21 Sep 2024 00:30:57 +0800 Subject: [PATCH 01/14] Ignore miri on test that failed --- tests-build/tests/macros.rs | 1 + tests-integration/tests/process_stdio.rs | 2 +- tokio-util/tests/spawn_pinned.rs | 2 ++ tokio-util/tests/udp.rs | 1 + tokio/tests/buffered.rs | 1 + tokio/tests/coop_budget.rs | 1 + tokio/tests/fs_copy.rs | 2 ++ tokio/tests/fs_file.rs | 1 + tokio/tests/fs_link.rs | 1 + tokio/tests/fs_try_exists.rs | 1 + tokio/tests/io_async_fd.rs | 6 +++++- tokio/tests/io_copy_bidirectional.rs | 2 +- tokio/tests/io_driver.rs | 2 +- tokio/tests/io_driver_drop.rs | 2 +- tokio/tests/io_read_to_end.rs | 1 + tokio/tests/io_repeat.rs | 3 ++- tokio/tests/net_bind_resource.rs | 2 +- tokio/tests/net_lookup_host.rs | 1 + tokio/tests/net_panic.rs | 2 +- tokio/tests/net_unix_pipe.rs | 1 + tokio/tests/no_rt.rs | 2 +- tokio/tests/process_arg0.rs | 2 +- tokio/tests/process_change_of_runtime.rs | 2 +- tokio/tests/process_issue_2174.rs | 2 +- tokio/tests/process_issue_42.rs | 1 + tokio/tests/process_kill_on_drop.rs | 2 +- tokio/tests/process_raw_handle.rs | 1 + tokio/tests/process_smoke.rs | 2 +- tokio/tests/rt_basic.rs | 1 + tokio/tests/rt_common.rs | 1 + tokio/tests/rt_handle_block_on.rs | 5 ++++- tokio/tests/rt_threaded.rs | 5 ++++- tokio/tests/signal_ctrl_c.rs | 1 + tokio/tests/signal_drop_recv.rs | 1 + tokio/tests/signal_drop_rt.rs | 1 + tokio/tests/signal_drop_signal.rs | 1 + tokio/tests/signal_multi_rt.rs | 1 + tokio/tests/signal_no_rt.rs | 1 + tokio/tests/signal_notify_both.rs | 1 + tokio/tests/signal_panic.rs | 1 + tokio/tests/signal_twice.rs | 1 + tokio/tests/signal_usr1.rs | 1 + tokio/tests/sync_mutex_owned.rs | 1 + tokio/tests/task_blocking.rs | 2 +- tokio/tests/tcp_accept.rs | 2 +- tokio/tests/tcp_connect.rs | 2 +- tokio/tests/tcp_echo.rs | 2 +- tokio/tests/tcp_into_split.rs | 2 +- tokio/tests/tcp_into_std.rs | 2 +- tokio/tests/tcp_peek.rs | 2 +- tokio/tests/tcp_shutdown.rs | 2 +- tokio/tests/tcp_socket.rs | 2 +- tokio/tests/tcp_split.rs | 2 +- tokio/tests/tcp_stream.rs | 2 +- tokio/tests/time_pause.rs | 1 + tokio/tests/time_sleep.rs | 1 + tokio/tests/udp.rs | 2 +- tokio/tests/uds_cred.rs | 2 +- tokio/tests/uds_datagram.rs | 1 + tokio/tests/uds_socket.rs | 2 ++ tokio/tests/uds_split.rs | 1 + tokio/tests/uds_stream.rs | 1 + 62 files changed, 76 insertions(+), 29 deletions(-) diff --git a/tests-build/tests/macros.rs b/tests-build/tests/macros.rs index 0a180dfb74f..8de08125d30 100644 --- a/tests-build/tests/macros.rs +++ b/tests-build/tests/macros.rs @@ -1,4 +1,5 @@ #[test] +#[cfg_attr(miri, ignore)] fn compile_fail_full() { let t = trybuild::TestCases::new(); diff --git a/tests-integration/tests/process_stdio.rs b/tests-integration/tests/process_stdio.rs index 634099a9d39..54446671e36 100644 --- a/tests-integration/tests/process_stdio.rs +++ b/tests-integration/tests/process_stdio.rs @@ -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; diff --git a/tokio-util/tests/spawn_pinned.rs b/tokio-util/tests/spawn_pinned.rs index e05b4095eb4..110fdab0abc 100644 --- a/tokio-util/tests/spawn_pinned.rs +++ b/tokio-util/tests/spawn_pinned.rs @@ -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))] use std::rc::Rc; use std::sync::Arc; diff --git a/tokio-util/tests/udp.rs b/tokio-util/tests/udp.rs index 8a70289c263..6e31b3a5394 100644 --- a/tokio-util/tests/udp.rs +++ b/tokio-util/tests/udp.rs @@ -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; diff --git a/tokio/tests/buffered.rs b/tokio/tests/buffered.rs index 27e75d10d52..bb67255f57d 100644 --- a/tokio/tests/buffered.rs +++ b/tokio/tests/buffered.rs @@ -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; diff --git a/tokio/tests/coop_budget.rs b/tokio/tests/coop_budget.rs index 0c4cc7e6497..2400187d0d5 100644 --- a/tokio/tests/coop_budget.rs +++ b/tokio/tests/coop_budget.rs @@ -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; diff --git a/tokio/tests/fs_copy.rs b/tokio/tests/fs_copy.rs index 3311710e9dc..4f8daadf269 100644 --- a/tokio/tests/fs_copy.rs +++ b/tokio/tests/fs_copy.rs @@ -5,6 +5,7 @@ use tempfile::tempdir; use tokio::fs; #[tokio::test] +#[cfg_attr(miri, ignore)] async fn copy() { let dir = tempdir().unwrap(); @@ -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"); diff --git a/tokio/tests/fs_file.rs b/tokio/tests/fs_file.rs index 520c4ec8438..5eb43265e89 100644 --- a/tokio/tests/fs_file.rs +++ b/tokio/tests/fs_file.rs @@ -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(); diff --git a/tokio/tests/fs_link.rs b/tokio/tests/fs_link.rs index 48da5f67dd9..36cd1fe0d05 100644 --- a/tokio/tests/fs_link.rs +++ b/tokio/tests/fs_link.rs @@ -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"); diff --git a/tokio/tests/fs_try_exists.rs b/tokio/tests/fs_try_exists.rs index dca554dda45..56d4bca18a4 100644 --- a/tokio/tests/fs_try_exists.rs +++ b/tokio/tests/fs_try_exists.rs @@ -5,6 +5,7 @@ use tempfile::tempdir; use tokio::fs; #[tokio::test] +#[cfg_attr(miri, ignore)] async fn try_exists() { let dir = tempdir().unwrap(); diff --git a/tokio/tests/io_async_fd.rs b/tokio/tests/io_async_fd.rs index f4dcfcf0927..fc708369314 100644 --- a/tokio/tests/io_async_fd.rs +++ b/tokio/tests/io_async_fd.rs @@ -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::{ @@ -655,6 +655,7 @@ fn send_oob_data(stream: &S, data: &[u8]) -> io::Result { } #[tokio::test] +#[cfg_attr(miri, ignore)] async fn clear_ready_matching_clears_ready() { use tokio::io::{Interest, Ready}; @@ -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}; @@ -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}; @@ -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}; diff --git a/tokio/tests/io_copy_bidirectional.rs b/tokio/tests/io_copy_bidirectional.rs index 3cdce32d0ce..44ba6ecdf40 100644 --- a/tokio/tests/io_copy_bidirectional.rs +++ b/tokio/tests/io_copy_bidirectional.rs @@ -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}; diff --git a/tokio/tests/io_driver.rs b/tokio/tests/io_driver.rs index 2e2c84746c9..5fa1fd1da19 100644 --- a/tokio/tests/io_driver.rs +++ b/tokio/tests/io_driver.rs @@ -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; diff --git a/tokio/tests/io_driver_drop.rs b/tokio/tests/io_driver_drop.rs index c3182637916..85c83c7ba91 100644 --- a/tokio/tests/io_driver_drop.rs +++ b/tokio/tests/io_driver_drop.rs @@ -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; diff --git a/tokio/tests/io_read_to_end.rs b/tokio/tests/io_read_to_end.rs index 29b60becec4..6573f8b68b2 100644 --- a/tokio/tests/io_read_to_end.rs +++ b/tokio/tests/io_read_to_end.rs @@ -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 = (0..100).collect(); diff --git a/tokio/tests/io_repeat.rs b/tokio/tests/io_repeat.rs index b3745877cd5..c55f7d3a793 100644 --- a/tokio/tests/io_repeat.rs +++ b/tokio/tests/io_repeat.rs @@ -1,5 +1,6 @@ #![warn(rust_2018_idioms)] -#![cfg(feature = "full")] +#![cfg(all(feature = "full", not(miri)))] + use tokio::io::AsyncReadExt; diff --git a/tokio/tests/net_bind_resource.rs b/tokio/tests/net_bind_resource.rs index 05fd1604b87..b29e0976255 100644 --- a/tokio/tests/net_bind_resource.rs +++ b/tokio/tests/net_bind_resource.rs @@ -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; diff --git a/tokio/tests/net_lookup_host.rs b/tokio/tests/net_lookup_host.rs index 667030c7e02..6adce83ecbb 100644 --- a/tokio/tests/net_lookup_host.rs +++ b/tokio/tests/net_lookup_host.rs @@ -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(); diff --git a/tokio/tests/net_panic.rs b/tokio/tests/net_panic.rs index 9d6e87d9aee..fc1777c0e79 100644 --- a/tokio/tests/net_panic.rs +++ b/tokio/tests/net_panic.rs @@ -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; diff --git a/tokio/tests/net_unix_pipe.rs b/tokio/tests/net_unix_pipe.rs index 37b8b41bd31..c6d2ab34203 100644 --- a/tokio/tests/net_unix_pipe.rs +++ b/tokio/tests/net_unix_pipe.rs @@ -1,5 +1,6 @@ #![cfg(feature = "full")] #![cfg(unix)] +#![cfg(not(miri))] use tokio::io::{AsyncReadExt, AsyncWriteExt, Interest}; use tokio::net::unix::pipe; diff --git a/tokio/tests/no_rt.rs b/tokio/tests/no_rt.rs index 89c7ce0aa57..22cf17f6d4c 100644 --- a/tokio/tests/no_rt.rs +++ b/tokio/tests/no_rt.rs @@ -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; diff --git a/tokio/tests/process_arg0.rs b/tokio/tests/process_arg0.rs index 4fabea0fe1f..b966d4e76ec 100644 --- a/tokio/tests/process_arg0.rs +++ b/tokio/tests/process_arg0.rs @@ -1,5 +1,5 @@ #![warn(rust_2018_idioms)] -#![cfg(all(feature = "full", unix))] +#![cfg(all(feature = "full", unix, not(miri)))] use tokio::process::Command; diff --git a/tokio/tests/process_change_of_runtime.rs b/tokio/tests/process_change_of_runtime.rs index 94efe35b146..968463fdd8b 100644 --- a/tokio/tests/process_change_of_runtime.rs +++ b/tokio/tests/process_change_of_runtime.rs @@ -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}; diff --git a/tokio/tests/process_issue_2174.rs b/tokio/tests/process_issue_2174.rs index 2f8c73a58d0..7627a57db0c 100644 --- a/tokio/tests/process_issue_2174.rs +++ b/tokio/tests/process_issue_2174.rs @@ -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; diff --git a/tokio/tests/process_issue_42.rs b/tokio/tests/process_issue_42.rs index 569c122e36a..536feee349f 100644 --- a/tokio/tests/process_issue_42.rs +++ b/tokio/tests/process_issue_42.rs @@ -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; diff --git a/tokio/tests/process_kill_on_drop.rs b/tokio/tests/process_kill_on_drop.rs index d919b1a27fe..2f2e2b36d15 100644 --- a/tokio/tests/process_kill_on_drop.rs +++ b/tokio/tests/process_kill_on_drop.rs @@ -1,4 +1,4 @@ -#![cfg(all(unix, feature = "process"))] +#![cfg(all(unix, feature = "process", not(miri)))] #![warn(rust_2018_idioms)] use std::io::ErrorKind; diff --git a/tokio/tests/process_raw_handle.rs b/tokio/tests/process_raw_handle.rs index fbe22b07c88..8d08c7f74e2 100644 --- a/tokio/tests/process_raw_handle.rs +++ b/tokio/tests/process_raw_handle.rs @@ -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; diff --git a/tokio/tests/process_smoke.rs b/tokio/tests/process_smoke.rs index 635b951a065..e7fec6d61be 100644 --- a/tokio/tests/process_smoke.rs +++ b/tokio/tests/process_smoke.rs @@ -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; diff --git a/tokio/tests/rt_basic.rs b/tokio/tests/rt_basic.rs index 4c558c90e28..f2ec0df9ff6 100644 --- a/tokio/tests/rt_basic.rs +++ b/tokio/tests/rt_basic.rs @@ -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; diff --git a/tokio/tests/rt_common.rs b/tokio/tests/rt_common.rs index 2c4fc9e0c94..07e8c218067 100644 --- a/tokio/tests/rt_common.rs +++ b/tokio/tests/rt_common.rs @@ -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. diff --git a/tokio/tests/rt_handle_block_on.rs b/tokio/tests/rt_handle_block_on.rs index 95365ec5216..7b9e7349b9c 100644 --- a/tokio/tests/rt_handle_block_on.rs +++ b/tokio/tests/rt_handle_block_on.rs @@ -1,5 +1,6 @@ #![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 @@ -143,6 +144,7 @@ rt_test! { } #[test] + #[cfg_attr(miri, ignore)] fn fs_shutdown_before_started() { let rt = rt(); let _enter = rt.enter(); @@ -175,6 +177,7 @@ rt_test! { } #[test] + #[cfg_attr(miri, ignore)] fn spawn_blocking_after_shutdown_fails() { use tokio::task::spawn_blocking; let rt = rt(); diff --git a/tokio/tests/rt_threaded.rs b/tokio/tests/rt_threaded.rs index a4742dd234e..cf3c3150a8d 100644 --- a/tokio/tests/rt_threaded.rs +++ b/tokio/tests/rt_threaded.rs @@ -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}; @@ -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; diff --git a/tokio/tests/signal_ctrl_c.rs b/tokio/tests/signal_ctrl_c.rs index 4b057ee7e14..ebeee4d9e2e 100644 --- a/tokio/tests/signal_ctrl_c.rs +++ b/tokio/tests/signal_ctrl_c.rs @@ -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; diff --git a/tokio/tests/signal_drop_recv.rs b/tokio/tests/signal_drop_recv.rs index b0d9213e618..f1da899b040 100644 --- a/tokio/tests/signal_drop_recv.rs +++ b/tokio/tests/signal_drop_recv.rs @@ -1,6 +1,7 @@ #![warn(rust_2018_idioms)] #![cfg(feature = "full")] #![cfg(unix)] +#![cfg(not(miri))] mod support { pub mod signal; diff --git a/tokio/tests/signal_drop_rt.rs b/tokio/tests/signal_drop_rt.rs index b931d7a9033..24fd72865c0 100644 --- a/tokio/tests/signal_drop_rt.rs +++ b/tokio/tests/signal_drop_rt.rs @@ -1,6 +1,7 @@ #![warn(rust_2018_idioms)] #![cfg(feature = "full")] #![cfg(unix)] +#![cfg(not(miri))] mod support { pub mod signal; diff --git a/tokio/tests/signal_drop_signal.rs b/tokio/tests/signal_drop_signal.rs index 92ac4050d57..9eedd3f467e 100644 --- a/tokio/tests/signal_drop_signal.rs +++ b/tokio/tests/signal_drop_signal.rs @@ -1,6 +1,7 @@ #![warn(rust_2018_idioms)] #![cfg(feature = "full")] #![cfg(unix)] +#![cfg(not(miri))] mod support { pub mod signal; diff --git a/tokio/tests/signal_multi_rt.rs b/tokio/tests/signal_multi_rt.rs index 1e0402c4794..65806d9168f 100644 --- a/tokio/tests/signal_multi_rt.rs +++ b/tokio/tests/signal_multi_rt.rs @@ -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; diff --git a/tokio/tests/signal_no_rt.rs b/tokio/tests/signal_no_rt.rs index db284e16513..6b7ddcb9468 100644 --- a/tokio/tests/signal_no_rt.rs +++ b/tokio/tests/signal_no_rt.rs @@ -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}; diff --git a/tokio/tests/signal_notify_both.rs b/tokio/tests/signal_notify_both.rs index 3481f808b36..4a9df693b93 100644 --- a/tokio/tests/signal_notify_both.rs +++ b/tokio/tests/signal_notify_both.rs @@ -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; diff --git a/tokio/tests/signal_panic.rs b/tokio/tests/signal_panic.rs index 6b662e54b96..6078d220b90 100644 --- a/tokio/tests/signal_panic.rs +++ b/tokio/tests/signal_panic.rs @@ -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; diff --git a/tokio/tests/signal_twice.rs b/tokio/tests/signal_twice.rs index 8f33d22a82d..0fe7bf74f56 100644 --- a/tokio/tests/signal_twice.rs +++ b/tokio/tests/signal_twice.rs @@ -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; diff --git a/tokio/tests/signal_usr1.rs b/tokio/tests/signal_usr1.rs index d74c7d31ab5..86ba0ecddf4 100644 --- a/tokio/tests/signal_usr1.rs +++ b/tokio/tests/signal_usr1.rs @@ -1,6 +1,7 @@ #![warn(rust_2018_idioms)] #![cfg(feature = "full")] #![cfg(unix)] +#![cfg(not(miri))] // No `sigaction` in Miri. mod support { pub mod signal; diff --git a/tokio/tests/sync_mutex_owned.rs b/tokio/tests/sync_mutex_owned.rs index badcef3d08e..d890c5327f1 100644 --- a/tokio/tests/sync_mutex_owned.rs +++ b/tokio/tests/sync_mutex_owned.rs @@ -59,6 +59,7 @@ fn readiness() { /// is aborted prematurely. #[tokio::test] #[cfg(feature = "full")] +#[cfg_attr(miri, ignore)] async fn aborted_future_1() { use std::time::Duration; use tokio::time::{interval, timeout}; diff --git a/tokio/tests/task_blocking.rs b/tokio/tests/task_blocking.rs index b9cce9a4aa4..b0e6e62ef70 100644 --- a/tokio/tests/task_blocking.rs +++ b/tokio/tests/task_blocking.rs @@ -1,5 +1,5 @@ #![warn(rust_2018_idioms)] -#![cfg(all(feature = "full", not(target_os = "wasi")))] // Wasi doesn't support threads +#![cfg(all(feature = "full", not(target_os = "wasi"), not(miri)))] // Wasi doesn't support threads use tokio::{runtime, task, time}; use tokio_test::assert_ok; diff --git a/tokio/tests/tcp_accept.rs b/tokio/tests/tcp_accept.rs index d547c48daa3..e76dec406ce 100644 --- a/tokio/tests/tcp_accept.rs +++ b/tokio/tests/tcp_accept.rs @@ -1,5 +1,5 @@ #![warn(rust_2018_idioms)] -#![cfg(all(feature = "full", not(target_os = "wasi")))] // Wasi doesn't support bind +#![cfg(all(feature = "full", not(target_os = "wasi"), not(miri)))] // Wasi doesn't support bind use tokio::net::{TcpListener, TcpStream}; use tokio::sync::{mpsc, oneshot}; diff --git a/tokio/tests/tcp_connect.rs b/tokio/tests/tcp_connect.rs index 269ba8ef695..2e9cf722948 100644 --- a/tokio/tests/tcp_connect.rs +++ b/tokio/tests/tcp_connect.rs @@ -1,5 +1,5 @@ #![warn(rust_2018_idioms)] -#![cfg(all(feature = "full", not(target_os = "wasi")))] // Wasi doesn't support bind +#![cfg(all(feature = "full", not(target_os = "wasi"), not(miri)))] // Wasi doesn't support bind use tokio::net::{TcpListener, TcpStream}; use tokio::sync::oneshot; diff --git a/tokio/tests/tcp_echo.rs b/tokio/tests/tcp_echo.rs index dfd4dd7b9f4..2ec1a134806 100644 --- a/tokio/tests/tcp_echo.rs +++ b/tokio/tests/tcp_echo.rs @@ -1,5 +1,5 @@ #![warn(rust_2018_idioms)] -#![cfg(all(feature = "full", not(target_os = "wasi")))] // Wasi doesn't support bind +#![cfg(all(feature = "full", not(target_os = "wasi"), not(miri)))] // Wasi doesn't support bind use tokio::io::{self, AsyncReadExt, AsyncWriteExt}; use tokio::net::{TcpListener, TcpStream}; diff --git a/tokio/tests/tcp_into_split.rs b/tokio/tests/tcp_into_split.rs index df8efadb50f..34f35ca9241 100644 --- a/tokio/tests/tcp_into_split.rs +++ b/tokio/tests/tcp_into_split.rs @@ -1,5 +1,5 @@ #![warn(rust_2018_idioms)] -#![cfg(all(feature = "full", not(target_os = "wasi")))] // Wasi doesn't support bind +#![cfg(all(feature = "full", not(target_os = "wasi"), not(miri)))] // Wasi doesn't support bind use std::io::{Error, ErrorKind, Result}; use std::io::{Read, Write}; diff --git a/tokio/tests/tcp_into_std.rs b/tokio/tests/tcp_into_std.rs index 58996f75c90..95a61525dd1 100644 --- a/tokio/tests/tcp_into_std.rs +++ b/tokio/tests/tcp_into_std.rs @@ -1,5 +1,5 @@ #![warn(rust_2018_idioms)] -#![cfg(all(feature = "full", not(target_os = "wasi")))] // Wasi doesn't support bind +#![cfg(all(feature = "full", not(target_os = "wasi"), not(miri)))] // Wasi doesn't support bind use std::io::Read; use std::io::Result; diff --git a/tokio/tests/tcp_peek.rs b/tokio/tests/tcp_peek.rs index b2d3eda097e..2ebcb418803 100644 --- a/tokio/tests/tcp_peek.rs +++ b/tokio/tests/tcp_peek.rs @@ -1,5 +1,5 @@ #![warn(rust_2018_idioms)] -#![cfg(all(feature = "full", not(target_os = "wasi")))] // Wasi doesn't support bind +#![cfg(all(feature = "full", not(target_os = "wasi"), not(miri)))] // Wasi doesn't support bind use tokio::io::AsyncReadExt; use tokio::net::TcpStream; diff --git a/tokio/tests/tcp_shutdown.rs b/tokio/tests/tcp_shutdown.rs index 86c1485a4a4..d5a6488e783 100644 --- a/tokio/tests/tcp_shutdown.rs +++ b/tokio/tests/tcp_shutdown.rs @@ -1,5 +1,5 @@ #![warn(rust_2018_idioms)] -#![cfg(all(feature = "full", not(target_os = "wasi")))] // Wasi doesn't support bind +#![cfg(all(feature = "full", not(target_os = "wasi"), not(miri)))] // Wasi doesn't support bind use tokio::io::{self, AsyncReadExt, AsyncWriteExt}; use tokio::net::{TcpListener, TcpStream}; diff --git a/tokio/tests/tcp_socket.rs b/tokio/tests/tcp_socket.rs index faead95c0bb..0abebb6ccb2 100644 --- a/tokio/tests/tcp_socket.rs +++ b/tokio/tests/tcp_socket.rs @@ -1,5 +1,5 @@ #![warn(rust_2018_idioms)] -#![cfg(all(feature = "full", not(target_os = "wasi")))] // Wasi doesn't support bind +#![cfg(all(feature = "full", not(target_os = "wasi"), not(miri)))] // Wasi doesn't support bind use std::time::Duration; use tokio::net::TcpSocket; diff --git a/tokio/tests/tcp_split.rs b/tokio/tests/tcp_split.rs index 32aaa1f771b..4cbec846cfa 100644 --- a/tokio/tests/tcp_split.rs +++ b/tokio/tests/tcp_split.rs @@ -1,5 +1,5 @@ #![warn(rust_2018_idioms)] -#![cfg(all(feature = "full", not(target_os = "wasi")))] // Wasi doesn't support bind +#![cfg(all(feature = "full", not(target_os = "wasi"), not(miri)))] // Wasi doesn't support bind use std::io::Result; use std::io::{Read, Write}; diff --git a/tokio/tests/tcp_stream.rs b/tokio/tests/tcp_stream.rs index 725a60169ea..7b58df98eb2 100644 --- a/tokio/tests/tcp_stream.rs +++ b/tokio/tests/tcp_stream.rs @@ -1,5 +1,5 @@ #![warn(rust_2018_idioms)] -#![cfg(all(feature = "full", not(target_os = "wasi")))] // Wasi doesn't support bind +#![cfg(all(feature = "full", not(target_os = "wasi"), not(miri)))] // Wasi doesn't support bind use tokio::io::{AsyncReadExt, AsyncWriteExt, Interest}; use tokio::net::{TcpListener, TcpStream}; diff --git a/tokio/tests/time_pause.rs b/tokio/tests/time_pause.rs index a14f7e22c61..a0936a98daa 100644 --- a/tokio/tests/time_pause.rs +++ b/tokio/tests/time_pause.rs @@ -47,6 +47,7 @@ async fn pause_time_in_spawn_threads() { assert_err!(t.await); } +#[cfg(not(miri))] // Too slow on miri. #[test] fn paused_time_is_deterministic() { let run_1 = paused_time_stress_run(); diff --git a/tokio/tests/time_sleep.rs b/tokio/tests/time_sleep.rs index 6da7ada0394..e1b5f4d2999 100644 --- a/tokio/tests/time_sleep.rs +++ b/tokio/tests/time_sleep.rs @@ -1,5 +1,6 @@ #![warn(rust_2018_idioms)] #![cfg(feature = "full")] +#![cfg(not(miri))] // Too slow on Miri. use std::future::Future; use std::task::Context; diff --git a/tokio/tests/udp.rs b/tokio/tests/udp.rs index eea281c2316..a2b99007251 100644 --- a/tokio/tests/udp.rs +++ b/tokio/tests/udp.rs @@ -1,5 +1,5 @@ #![warn(rust_2018_idioms)] -#![cfg(all(feature = "full", not(target_os = "wasi")))] // Wasi does not support bind or UDP +#![cfg(all(feature = "full", not(target_os = "wasi"), not(miri)))] // Wasi does not support bind or UDP use futures::future::poll_fn; use std::io; diff --git a/tokio/tests/uds_cred.rs b/tokio/tests/uds_cred.rs index c2b3914dfe7..7facffaed63 100644 --- a/tokio/tests/uds_cred.rs +++ b/tokio/tests/uds_cred.rs @@ -1,6 +1,6 @@ #![warn(rust_2018_idioms)] #![cfg(feature = "full")] -#![cfg(all(unix, not(target_os = "dragonfly")))] +#![cfg(all(unix, not(target_os = "dragonfly"), not(miri)))] use tokio::net::UnixStream; diff --git a/tokio/tests/uds_datagram.rs b/tokio/tests/uds_datagram.rs index ad22a0b99dd..4cbe66fb431 100644 --- a/tokio/tests/uds_datagram.rs +++ b/tokio/tests/uds_datagram.rs @@ -1,6 +1,7 @@ #![warn(rust_2018_idioms)] #![cfg(feature = "full")] #![cfg(unix)] +#![cfg(not(miri))] use futures::future::poll_fn; use tokio::io::ReadBuf; diff --git a/tokio/tests/uds_socket.rs b/tokio/tests/uds_socket.rs index 5261ffe5da3..fb718def59e 100644 --- a/tokio/tests/uds_socket.rs +++ b/tokio/tests/uds_socket.rs @@ -1,6 +1,8 @@ #![warn(rust_2018_idioms)] #![cfg(feature = "full")] #![cfg(unix)] +#![cfg(not(miri))] + use futures::future::try_join; use std::io; diff --git a/tokio/tests/uds_split.rs b/tokio/tests/uds_split.rs index 81614237eca..b6c2fa6f016 100644 --- a/tokio/tests/uds_split.rs +++ b/tokio/tests/uds_split.rs @@ -1,6 +1,7 @@ #![warn(rust_2018_idioms)] #![cfg(feature = "full")] #![cfg(unix)] +#![cfg(not(miri))] use tokio::io::{AsyncRead, AsyncReadExt, AsyncWrite, AsyncWriteExt}; use tokio::net::UnixStream; diff --git a/tokio/tests/uds_stream.rs b/tokio/tests/uds_stream.rs index 626a96fa31e..b016bb8298f 100644 --- a/tokio/tests/uds_stream.rs +++ b/tokio/tests/uds_stream.rs @@ -1,6 +1,7 @@ #![cfg(feature = "full")] #![warn(rust_2018_idioms)] #![cfg(unix)] +#![cfg(not(miri))] use std::io; use std::task::Poll; From c75732bd8431b6fc1291c320c4dfa6bda5da9777 Mon Sep 17 00:00:00 2001 From: tiif Date: Tue, 8 Oct 2024 01:24:17 +0800 Subject: [PATCH 02/14] rustfmt --- tokio/tests/io_repeat.rs | 1 - tokio/tests/rt_handle_block_on.rs | 1 - tokio/tests/rt_threaded.rs | 4 ++-- tokio/tests/signal_multi_rt.rs | 2 +- tokio/tests/signal_no_rt.rs | 2 +- tokio/tests/signal_notify_both.rs | 2 +- tokio/tests/signal_panic.rs | 2 +- tokio/tests/signal_twice.rs | 2 +- tokio/tests/signal_usr1.rs | 2 +- tokio/tests/uds_socket.rs | 1 - 10 files changed, 8 insertions(+), 11 deletions(-) diff --git a/tokio/tests/io_repeat.rs b/tokio/tests/io_repeat.rs index c55f7d3a793..5a48817b1a0 100644 --- a/tokio/tests/io_repeat.rs +++ b/tokio/tests/io_repeat.rs @@ -1,7 +1,6 @@ #![warn(rust_2018_idioms)] #![cfg(all(feature = "full", not(miri)))] - use tokio::io::AsyncReadExt; #[tokio::test] diff --git a/tokio/tests/rt_handle_block_on.rs b/tokio/tests/rt_handle_block_on.rs index 7b9e7349b9c..08edc70d66c 100644 --- a/tokio/tests/rt_handle_block_on.rs +++ b/tokio/tests/rt_handle_block_on.rs @@ -1,7 +1,6 @@ #![warn(rust_2018_idioms)] #![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 // https://github.com/tokio-rs/tokio/pull/3569#pullrequestreview-612703467 for more details. diff --git a/tokio/tests/rt_threaded.rs b/tokio/tests/rt_threaded.rs index cf3c3150a8d..bf9608822c7 100644 --- a/tokio/tests/rt_threaded.rs +++ b/tokio/tests/rt_threaded.rs @@ -1,6 +1,6 @@ #![allow(unknown_lints, unexpected_cfgs)] #![warn(rust_2018_idioms)] -// Too slow on miri. +// Too slow on miri. #![cfg(all(feature = "full", not(target_os = "wasi"), not(miri)))] use tokio::io::{AsyncReadExt, AsyncWriteExt}; @@ -324,7 +324,7 @@ fn start_stop_callbacks_called() { #[test] // too slow on miri -#[cfg_attr(miri, ignore)] +#[cfg_attr(miri, ignore)] fn blocking() { // used for notifying the main thread const NUM: usize = 1_000; diff --git a/tokio/tests/signal_multi_rt.rs b/tokio/tests/signal_multi_rt.rs index 65806d9168f..ca0d76a6f24 100644 --- a/tokio/tests/signal_multi_rt.rs +++ b/tokio/tests/signal_multi_rt.rs @@ -1,7 +1,7 @@ #![warn(rust_2018_idioms)] #![cfg(feature = "full")] #![cfg(unix)] -#![cfg(not(miri))] // No `sigaction` on Miri. +#![cfg(not(miri))] // No `sigaction` on Miri. mod support { pub mod signal; diff --git a/tokio/tests/signal_no_rt.rs b/tokio/tests/signal_no_rt.rs index 6b7ddcb9468..c8e381da830 100644 --- a/tokio/tests/signal_no_rt.rs +++ b/tokio/tests/signal_no_rt.rs @@ -1,7 +1,7 @@ #![warn(rust_2018_idioms)] #![cfg(feature = "full")] #![cfg(unix)] -#![cfg(not(miri))] // No `sigaction` on Miri. +#![cfg(not(miri))] // No `sigaction` on Miri. use tokio::signal::unix::{signal, SignalKind}; diff --git a/tokio/tests/signal_notify_both.rs b/tokio/tests/signal_notify_both.rs index 4a9df693b93..141cccfbae9 100644 --- a/tokio/tests/signal_notify_both.rs +++ b/tokio/tests/signal_notify_both.rs @@ -1,7 +1,7 @@ #![warn(rust_2018_idioms)] #![cfg(feature = "full")] #![cfg(unix)] -#![cfg(not(miri))] // No `sigaction` on Miri. +#![cfg(not(miri))] // No `sigaction` on Miri. mod support { pub mod signal; diff --git a/tokio/tests/signal_panic.rs b/tokio/tests/signal_panic.rs index 6078d220b90..64c427d1fea 100644 --- a/tokio/tests/signal_panic.rs +++ b/tokio/tests/signal_panic.rs @@ -2,7 +2,7 @@ #![cfg(feature = "full")] #![cfg(unix)] #![cfg(panic = "unwind")] -#![cfg(not(miri))] // No `sigaction` on Miri. +#![cfg(not(miri))] // No `sigaction` on Miri. use std::error::Error; use tokio::runtime::Builder; diff --git a/tokio/tests/signal_twice.rs b/tokio/tests/signal_twice.rs index 0fe7bf74f56..d74e897f493 100644 --- a/tokio/tests/signal_twice.rs +++ b/tokio/tests/signal_twice.rs @@ -1,7 +1,7 @@ #![warn(rust_2018_idioms)] #![cfg(feature = "full")] #![cfg(unix)] -#![cfg(not(miri))] // No `sigaction` on Miri. +#![cfg(not(miri))] // No `sigaction` on Miri. mod support { pub mod signal; diff --git a/tokio/tests/signal_usr1.rs b/tokio/tests/signal_usr1.rs index 86ba0ecddf4..853c72de44b 100644 --- a/tokio/tests/signal_usr1.rs +++ b/tokio/tests/signal_usr1.rs @@ -1,7 +1,7 @@ #![warn(rust_2018_idioms)] #![cfg(feature = "full")] #![cfg(unix)] -#![cfg(not(miri))] // No `sigaction` in Miri. +#![cfg(not(miri))] // No `sigaction` in Miri. mod support { pub mod signal; diff --git a/tokio/tests/uds_socket.rs b/tokio/tests/uds_socket.rs index fb718def59e..bc3e57b2b21 100644 --- a/tokio/tests/uds_socket.rs +++ b/tokio/tests/uds_socket.rs @@ -3,7 +3,6 @@ #![cfg(unix)] #![cfg(not(miri))] - use futures::future::try_join; use std::io; use tokio::{ From 842787dd0de66dfcc8af14aae1fbd8af23687aca Mon Sep 17 00:00:00 2001 From: tiif Date: Tue, 8 Oct 2024 10:34:40 +0800 Subject: [PATCH 03/14] Change the run command iin ci.yml --- .github/workflows/ci.yml | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index b6295d9c4cb..bf14f128e3d 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -420,13 +420,11 @@ 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 + cargo miri test --features full --lib --tests --no-fail-fast working-directory: tokio env: - MIRIFLAGS: -Zmiri-disable-isolation -Zmiri-strict-provenance -Zmiri-retag-fields + MIRIFLAGS: -Zmiri-disable-isolation -Zmiri-strict-provenance -Zmiri-retag-fields -Zmiri-tree-borrows asan: name: asan From 9324ca20e848a7feebcc9c29cb3fa4e55255f783 Mon Sep 17 00:00:00 2001 From: tiif Date: Thu, 10 Oct 2024 09:15:41 +0800 Subject: [PATCH 04/14] Remove tree borrows --- .github/workflows/ci.yml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index bf14f128e3d..c5d4f4bf346 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -424,8 +424,7 @@ jobs: cargo miri test --features full --lib --tests --no-fail-fast working-directory: tokio env: - MIRIFLAGS: -Zmiri-disable-isolation -Zmiri-strict-provenance -Zmiri-retag-fields -Zmiri-tree-borrows - + MIRIFLAGS: -Zmiri-disable-isolation -Zmiri-strict-provenance -Zmiri-retag-fields asan: name: asan needs: basics From 173149311aa86284b0906a83ae79c8b619c80f08 Mon Sep 17 00:00:00 2001 From: tiif Date: Thu, 10 Oct 2024 09:18:18 +0800 Subject: [PATCH 05/14] Try to configure the date --- .github/workflows/ci.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index c5d4f4bf346..ff06b00cc97 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -421,6 +421,8 @@ jobs: - uses: Swatinem/rust-cache@v2 - name: miri run: | + rustup toolchain install nightly 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 working-directory: tokio env: From 55654797b770eae6fce703210c3b9e35ff0f8460 Mon Sep 17 00:00:00 2001 From: tiif Date: Thu, 10 Oct 2024 09:21:48 +0800 Subject: [PATCH 06/14] Fix typo --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index ff06b00cc97..7d160050cca 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -421,7 +421,7 @@ jobs: - uses: Swatinem/rust-cache@v2 - name: miri run: | - rustup toolchain install nightly nightly-2024-09-19 --component miri --profile minimal --no-self-update + 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 working-directory: tokio From 879da01bd8e40e714e12b7f54c37627e6ea88ccb Mon Sep 17 00:00:00 2001 From: tiif Date: Thu, 10 Oct 2024 09:30:24 +0800 Subject: [PATCH 07/14] Try to pin a specific miri version --- .github/workflows/ci.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 7d160050cca..033948b2aae 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -17,6 +17,8 @@ env: # Change to specific Rust release to pin rust_stable: stable rust_nightly: nightly-2024-05-05 + # Pin a specific miri version + rust_miri_nightly: nightly-2024-09-19 rust_clippy: '1.77' # When updating this, also update: # - README.md @@ -413,16 +415,14 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - - name: Install Rust ${{ env.rust_nightly }} + - name: Install Rust ${{ env.rust_miri_nightly }} uses: dtolnay/rust-toolchain@stable with: - toolchain: ${{ env.rust_nightly }} + toolchain: ${{ env.rust_miri_nightly }} components: miri - uses: Swatinem/rust-cache@v2 - name: miri run: | - 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 working-directory: tokio env: From 40c3c26df074a38303eb709fbbe96485d987b3bd Mon Sep 17 00:00:00 2001 From: tiif Date: Thu, 10 Oct 2024 10:18:28 +0800 Subject: [PATCH 08/14] Ignore time pause --- tokio/tests/time_pause.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tokio/tests/time_pause.rs b/tokio/tests/time_pause.rs index a0936a98daa..98c72ff6e14 100644 --- a/tokio/tests/time_pause.rs +++ b/tokio/tests/time_pause.rs @@ -1,5 +1,6 @@ #![warn(rust_2018_idioms)] #![cfg(feature = "full")] +#![cfg(not(miri))] // Too slow on miri. use rand::SeedableRng; use rand::{rngs::StdRng, Rng}; @@ -47,7 +48,6 @@ async fn pause_time_in_spawn_threads() { assert_err!(t.await); } -#[cfg(not(miri))] // Too slow on miri. #[test] fn paused_time_is_deterministic() { let run_1 = paused_time_stress_run(); From 146134d137625b48a7b118b9ec67d868ceb60adc Mon Sep 17 00:00:00 2001 From: tiif Date: Thu, 10 Oct 2024 10:20:30 +0800 Subject: [PATCH 09/14] Fix rustfmt --- tokio/tests/time_pause.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tokio/tests/time_pause.rs b/tokio/tests/time_pause.rs index 98c72ff6e14..879d1b72a2b 100644 --- a/tokio/tests/time_pause.rs +++ b/tokio/tests/time_pause.rs @@ -1,6 +1,6 @@ #![warn(rust_2018_idioms)] #![cfg(feature = "full")] -#![cfg(not(miri))] // Too slow on miri. +#![cfg(not(miri))] // Too slow on miri. use rand::SeedableRng; use rand::{rngs::StdRng, Rng}; From 4a12abca506856c2677eca28be2e16cf6c350353 Mon Sep 17 00:00:00 2001 From: tiif Date: Thu, 10 Oct 2024 23:01:19 +0800 Subject: [PATCH 10/14] Fix spurious deleted line --- .github/workflows/ci.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 033948b2aae..c25719f7de7 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -427,6 +427,7 @@ jobs: working-directory: tokio env: MIRIFLAGS: -Zmiri-disable-isolation -Zmiri-strict-provenance -Zmiri-retag-fields + asan: name: asan needs: basics From f1c36c9a4c57c6a93d4be2e3756b45a8bfd0ba3d Mon Sep 17 00:00:00 2001 From: tiif Date: Thu, 10 Oct 2024 23:09:32 +0800 Subject: [PATCH 11/14] Ignore miri for entire file --- tokio/tests/rt_handle_block_on.rs | 2 -- 1 file changed, 2 deletions(-) diff --git a/tokio/tests/rt_handle_block_on.rs b/tokio/tests/rt_handle_block_on.rs index 08edc70d66c..81656bd8140 100644 --- a/tokio/tests/rt_handle_block_on.rs +++ b/tokio/tests/rt_handle_block_on.rs @@ -143,7 +143,6 @@ rt_test! { } #[test] - #[cfg_attr(miri, ignore)] fn fs_shutdown_before_started() { let rt = rt(); let _enter = rt.enter(); @@ -176,7 +175,6 @@ rt_test! { } #[test] - #[cfg_attr(miri, ignore)] fn spawn_blocking_after_shutdown_fails() { use tokio::task::spawn_blocking; let rt = rt(); From 936edf7480e4ff39a5985528c4ee44b59ca32d6e Mon Sep 17 00:00:00 2001 From: tiif Date: Thu, 10 Oct 2024 23:34:52 +0800 Subject: [PATCH 12/14] Add one more too slow --- tokio/tests/sync_mpsc.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/tokio/tests/sync_mpsc.rs b/tokio/tests/sync_mpsc.rs index 3d91c5cf3e8..468b3926354 100644 --- a/tokio/tests/sync_mpsc.rs +++ b/tokio/tests/sync_mpsc.rs @@ -680,6 +680,7 @@ async fn try_reserve_many_on_closed_channel() { } #[maybe_tokio_test] +#[cfg_attr(miri, ignore)] // Too slow on miri. async fn try_reserve_many_full() { // Reserve n capacity and send k messages for n in 1..100 { From 92fcd41723892fd40dde259920b51c3f8e8b89ec Mon Sep 17 00:00:00 2001 From: tiif Date: Fri, 11 Oct 2024 00:03:37 +0800 Subject: [PATCH 13/14] Disable a few more slow test --- tokio-util/tests/time_delay_queue.rs | 1 + tokio/tests/sync_mpsc.rs | 2 +- tokio/tests/sync_rwlock.rs | 1 + 3 files changed, 3 insertions(+), 1 deletion(-) diff --git a/tokio-util/tests/time_delay_queue.rs b/tokio-util/tests/time_delay_queue.rs index 9915b11b58a..855b82dd40e 100644 --- a/tokio-util/tests/time_delay_queue.rs +++ b/tokio-util/tests/time_delay_queue.rs @@ -92,6 +92,7 @@ async fn single_short_delay() { } #[tokio::test] +#[cfg_attr(miri, ignore)] // Too slow on miri. async fn multi_delay_at_start() { time::pause(); diff --git a/tokio/tests/sync_mpsc.rs b/tokio/tests/sync_mpsc.rs index 468b3926354..638ced588ce 100644 --- a/tokio/tests/sync_mpsc.rs +++ b/tokio/tests/sync_mpsc.rs @@ -680,7 +680,7 @@ async fn try_reserve_many_on_closed_channel() { } #[maybe_tokio_test] -#[cfg_attr(miri, ignore)] // Too slow on miri. +#[cfg_attr(miri, ignore)] // Too slow on miri. async fn try_reserve_many_full() { // Reserve n capacity and send k messages for n in 1..100 { diff --git a/tokio/tests/sync_rwlock.rs b/tokio/tests/sync_rwlock.rs index f711804ce26..5a58b4971b9 100644 --- a/tokio/tests/sync_rwlock.rs +++ b/tokio/tests/sync_rwlock.rs @@ -173,6 +173,7 @@ async fn write_order() { // A single RwLock is contested by tasks in multiple threads #[cfg(all(feature = "full", not(target_os = "wasi")))] // Wasi doesn't support threads +#[cfg_attr(miri, ignore)] // Too slow on miri. #[tokio::test(flavor = "multi_thread", worker_threads = 8)] async fn multithreaded() { use futures::stream::{self, StreamExt}; From 4f3751888cc6fa7e0e6c28fd1ffb56f579746692 Mon Sep 17 00:00:00 2001 From: tiif Date: Fri, 11 Oct 2024 00:07:29 +0800 Subject: [PATCH 14/14] Try to speed up the test using nextest --- .github/workflows/ci.yml | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index c25719f7de7..3a9d579e377 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -420,10 +420,14 @@ jobs: with: toolchain: ${{ env.rust_miri_nightly }} components: miri + - name: Install cargo-nextest + uses: taiki-e/install-action@v2 + with: + tool: cargo-nextest - uses: Swatinem/rust-cache@v2 - name: miri run: | - cargo miri test --features full --lib --tests --no-fail-fast + cargo miri nextest run --features full --lib --tests --no-fail-fast working-directory: tokio env: MIRIFLAGS: -Zmiri-disable-isolation -Zmiri-strict-provenance -Zmiri-retag-fields