diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index b6295d9c4cb..3a9d579e377 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,17 +415,19 @@ 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 + - name: Install cargo-nextest + uses: taiki-e/install-action@v2 + with: + tool: cargo-nextest - 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 nextest run --features full --lib --tests --no-fail-fast working-directory: tokio env: MIRIFLAGS: -Zmiri-disable-isolation -Zmiri-strict-provenance -Zmiri-retag-fields 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 df883ef767f..a0c211a43f7 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/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-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/src/sync/watch.rs b/tokio/src/sync/watch.rs index af72e30dd32..7d042a6f950 100644 --- a/tokio/src/sync/watch.rs +++ b/tokio/src/sync/watch.rs @@ -1336,6 +1336,29 @@ impl Sender { self.shared.ref_count_rx.load(Relaxed) } + /// Returns the number of senders that currently exist. + /// + /// # Examples + /// + /// ``` + /// use tokio::sync::watch; + /// + /// #[tokio::main] + /// async fn main() { + /// let (tx1, rx) = watch::channel("hello"); + /// + /// assert_eq!(1, tx1.sender_count()); + /// + /// let tx2 = tx1.clone(); + /// + /// assert_eq!(2, tx1.sender_count()); + /// assert_eq!(2, tx2.sender_count()); + /// } + /// ``` + pub fn sender_count(&self) -> usize { + self.shared.ref_count_tx.load(Relaxed) + } + /// Returns `true` if senders belong to the same channel. /// /// # Examples 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 856ac6db19b..469d2a4acbe 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..5a48817b1a0 100644 --- a/tokio/tests/io_repeat.rs +++ b/tokio/tests/io_repeat.rs @@ -1,5 +1,5 @@ #![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 12f9e16592f..ecf283886e2 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..81656bd8140 100644 --- a/tokio/tests/rt_handle_block_on.rs +++ b/tokio/tests/rt_handle_block_on.rs @@ -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 diff --git a/tokio/tests/rt_threaded.rs b/tokio/tests/rt_threaded.rs index b6666616f9f..b32ab3195ae 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}; @@ -321,6 +322,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..ca0d76a6f24 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..c8e381da830 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..141cccfbae9 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..64c427d1fea 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..d74e897f493 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..853c72de44b 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_mpsc.rs b/tokio/tests/sync_mpsc.rs index 3d91c5cf3e8..638ced588ce 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 { 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/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}; 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 c72dcea39d6..99f5f5c2b22 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 b06628f03a0..fd89ebeabd3 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..879d1b72a2b 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}; 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 586ceb42e5b..d3d88b147ef 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 std::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 126af1cac7c..9af7a8824ea 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 tokio::io::ReadBuf; use tokio::net::UnixDatagram; diff --git a/tokio/tests/uds_socket.rs b/tokio/tests/uds_socket.rs index 5261ffe5da3..bc3e57b2b21 100644 --- a/tokio/tests/uds_socket.rs +++ b/tokio/tests/uds_socket.rs @@ -1,6 +1,7 @@ #![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 37e53aafcd2..392bbc0bb6c 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; #[cfg(target_os = "android")]