Skip to content

Commit 161b8c8

Browse files
authored
ci: test more things with miri (#6885)
1 parent 9cc4a81 commit 161b8c8

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

66 files changed

+83
-34
lines changed

.github/workflows/ci.yml

+9-5
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@ env:
1717
# Change to specific Rust release to pin
1818
rust_stable: stable
1919
rust_nightly: nightly-2024-05-05
20+
# Pin a specific miri version
21+
rust_miri_nightly: nightly-2024-09-19
2022
rust_clippy: '1.77'
2123
# When updating this, also update:
2224
# - README.md
@@ -413,17 +415,19 @@ jobs:
413415
runs-on: ubuntu-latest
414416
steps:
415417
- uses: actions/checkout@v4
416-
- name: Install Rust ${{ env.rust_nightly }}
418+
- name: Install Rust ${{ env.rust_miri_nightly }}
417419
uses: dtolnay/rust-toolchain@stable
418420
with:
419-
toolchain: ${{ env.rust_nightly }}
421+
toolchain: ${{ env.rust_miri_nightly }}
420422
components: miri
423+
- name: Install cargo-nextest
424+
uses: taiki-e/install-action@v2
425+
with:
426+
tool: cargo-nextest
421427
- uses: Swatinem/rust-cache@v2
422428
- name: miri
423-
# Many of tests in tokio/tests and doctests use #[tokio::test] or
424-
# #[tokio::main] that calls epoll_create1 that Miri does not support.
425429
run: |
426-
cargo miri test --features full --lib --no-fail-fast
430+
cargo miri nextest run --features full --lib --tests --no-fail-fast
427431
working-directory: tokio
428432
env:
429433
MIRIFLAGS: -Zmiri-disable-isolation -Zmiri-strict-provenance -Zmiri-retag-fields

tests-build/tests/macros.rs

+1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
#[test]
2+
#[cfg_attr(miri, ignore)]
23
fn compile_fail_full() {
34
let t = trybuild::TestCases::new();
45

tests-integration/tests/process_stdio.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#![warn(rust_2018_idioms)]
2-
#![cfg(all(feature = "full", not(target_os = "wasi")))]
2+
#![cfg(all(feature = "full", not(target_os = "wasi"), not(miri)))]
33

44
use tokio::io::{AsyncBufReadExt, AsyncReadExt, AsyncWriteExt, BufReader};
55
use tokio::join;

tokio-util/tests/spawn_pinned.rs

+2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
#![warn(rust_2018_idioms)]
22
#![cfg(not(target_os = "wasi"))] // Wasi doesn't support threads
3+
// Blocked on https://github.com/rust-lang/miri/issues/3911
4+
#![cfg(not(miri))]
35

46
use std::rc::Rc;
57
use std::sync::Arc;

tokio-util/tests/time_delay_queue.rs

+1
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,7 @@ async fn single_short_delay() {
9292
}
9393

9494
#[tokio::test]
95+
#[cfg_attr(miri, ignore)] // Too slow on miri.
9596
async fn multi_delay_at_start() {
9697
time::pause();
9798

tokio-util/tests/udp.rs

+1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
#![warn(rust_2018_idioms)]
22
#![cfg(not(target_os = "wasi"))] // Wasi doesn't support UDP
3+
#![cfg(not(miri))] // No `socket` in Miri.
34

45
use tokio::net::UdpSocket;
56
use tokio_stream::StreamExt;

tokio/tests/buffered.rs

+1
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ use std::net::TcpStream;
99
use std::thread;
1010

1111
#[tokio::test]
12+
#[cfg_attr(miri, ignore)]
1213
async fn echo_server() {
1314
const N: usize = 1024;
1415

tokio/tests/coop_budget.rs

+1
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ use tokio::net::UdpSocket;
2222
/// Since we are both sending and receiving, that should happen once per 64 packets, because budgets are of size 128
2323
/// and there are two budget events per packet, a send and a recv.
2424
#[tokio::test]
25+
#[cfg_attr(miri, ignore)]
2526
async fn coop_budget_udp_send_recv() {
2627
const BUDGET: usize = 128;
2728
const N_ITERATIONS: usize = 1024;

tokio/tests/fs_copy.rs

+2
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ use tempfile::tempdir;
55
use tokio::fs;
66

77
#[tokio::test]
8+
#[cfg_attr(miri, ignore)]
89
async fn copy() {
910
let dir = tempdir().unwrap();
1011

@@ -21,6 +22,7 @@ async fn copy() {
2122
}
2223

2324
#[tokio::test]
25+
#[cfg_attr(miri, ignore)]
2426
async fn copy_permissions() {
2527
let dir = tempdir().unwrap();
2628
let from_path = dir.path().join("foo.txt");

tokio/tests/fs_file.rs

+1
Original file line numberDiff line numberDiff line change
@@ -203,6 +203,7 @@ async fn set_max_buf_size_write() {
203203
}
204204

205205
#[tokio::test]
206+
#[cfg_attr(miri, ignore)]
206207
#[cfg(unix)]
207208
async fn file_debug_fmt() {
208209
let tempfile = tempfile();

tokio/tests/fs_link.rs

+1
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ use std::io::Write;
77
use tempfile::tempdir;
88

99
#[tokio::test]
10+
#[cfg_attr(miri, ignore)]
1011
async fn test_hard_link() {
1112
let dir = tempdir().unwrap();
1213
let src = dir.path().join("src.txt");

tokio/tests/fs_try_exists.rs

+1
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ use tempfile::tempdir;
55
use tokio::fs;
66

77
#[tokio::test]
8+
#[cfg_attr(miri, ignore)]
89
async fn try_exists() {
910
let dir = tempdir().unwrap();
1011

tokio/tests/io_async_fd.rs

+5-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#![warn(rust_2018_idioms)]
2-
#![cfg(all(unix, feature = "full"))]
2+
#![cfg(all(unix, feature = "full", not(miri)))]
33

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

657657
#[tokio::test]
658+
#[cfg_attr(miri, ignore)]
658659
async fn clear_ready_matching_clears_ready() {
659660
use tokio::io::{Interest, Ready};
660661

@@ -678,6 +679,7 @@ async fn clear_ready_matching_clears_ready() {
678679
}
679680

680681
#[tokio::test]
682+
#[cfg_attr(miri, ignore)]
681683
async fn clear_ready_matching_clears_ready_mut() {
682684
use tokio::io::{Interest, Ready};
683685

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

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

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

759762
#[tokio::test]
760763
#[cfg(target_os = "linux")]
764+
#[cfg_attr(miri, ignore)]
761765
async fn await_error_readiness_invalid_address() {
762766
use std::net::{Ipv4Addr, SocketAddr};
763767
use tokio::io::{Interest, Ready};

tokio/tests/io_copy_bidirectional.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#![warn(rust_2018_idioms)]
2-
#![cfg(all(feature = "full", not(target_os = "wasi")))] // Wasi does not support bind()
2+
#![cfg(all(feature = "full", not(target_os = "wasi"), not(miri)))] // Wasi does not support bind()
33

44
use std::time::Duration;
55
use tokio::io::{self, copy_bidirectional, AsyncReadExt, AsyncWriteExt};

tokio/tests/io_driver.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#![warn(rust_2018_idioms)]
22
// Wasi does not support panic recovery or threading
3-
#![cfg(all(feature = "full", not(target_os = "wasi")))]
3+
#![cfg(all(feature = "full", not(target_os = "wasi"), not(miri)))]
44

55
use tokio::net::TcpListener;
66
use tokio::runtime;

tokio/tests/io_driver_drop.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#![warn(rust_2018_idioms)]
2-
#![cfg(all(feature = "full", not(target_os = "wasi")))] // Wasi does not support bind
2+
#![cfg(all(feature = "full", not(target_os = "wasi"), not(miri)))] // Wasi does not support bind
33

44
use tokio::net::TcpListener;
55
use tokio::runtime;

tokio/tests/io_read_to_end.rs

+1
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,7 @@ async fn read_to_end_uninit() {
7979
}
8080

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

tokio/tests/io_repeat.rs

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

44
use tokio::io::AsyncReadExt;
55

tokio/tests/net_bind_resource.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#![warn(rust_2018_idioms)]
2-
#![cfg(all(feature = "full", not(target_os = "wasi")))] // Wasi doesn't support panic recovery or bind
2+
#![cfg(all(feature = "full", not(target_os = "wasi"), not(miri)))] // Wasi doesn't support panic recovery or bind
33

44
use tokio::net::TcpListener;
55

tokio/tests/net_lookup_host.rs

+1
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ async fn lookup_str_socket_addr() {
2323
}
2424

2525
#[tokio::test]
26+
#[cfg_attr(miri, ignore)]
2627
async fn resolve_dns() -> io::Result<()> {
2728
let mut hosts = net::lookup_host("localhost:3000").await?;
2829
let host = hosts.next().unwrap();

tokio/tests/net_panic.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#![warn(rust_2018_idioms)]
2-
#![cfg(all(feature = "full", not(target_os = "wasi")))]
2+
#![cfg(all(feature = "full", not(target_os = "wasi"), not(miri)))]
33
#![cfg(panic = "unwind")]
44

55
use std::error::Error;

tokio/tests/net_unix_pipe.rs

+1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
#![cfg(feature = "full")]
22
#![cfg(unix)]
3+
#![cfg(not(miri))]
34

45
use tokio::io::{AsyncReadExt, AsyncWriteExt, Interest};
56
use tokio::net::unix::pipe;

tokio/tests/no_rt.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#![cfg(all(feature = "full", not(target_os = "wasi")))] // Wasi does not support panic recovery
1+
#![cfg(all(feature = "full", not(target_os = "wasi"), not(miri)))] // Wasi does not support panic recovery
22

33
use tokio::net::TcpStream;
44
use tokio::sync::oneshot;

tokio/tests/process_arg0.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#![warn(rust_2018_idioms)]
2-
#![cfg(all(feature = "full", unix))]
2+
#![cfg(all(feature = "full", unix, not(miri)))]
33

44
use tokio::process::Command;
55

tokio/tests/process_change_of_runtime.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
// This tests test the behavior of `process::Command::spawn` when it is used
44
// outside runtime, and when `process::Child::wait ` is used in a different
55
// runtime from which `process::Command::spawn` is used.
6-
#![cfg(all(unix, not(target_os = "freebsd")))]
6+
#![cfg(all(unix, not(target_os = "freebsd"), not(miri)))]
77

88
use std::process::Stdio;
99
use tokio::{process::Command, runtime::Runtime};

tokio/tests/process_issue_2174.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
// It is expected that `EVFILT_WRITE` would be returned with either the
88
// `EV_EOF` or `EV_ERROR` flag set. If either flag is set a write would be
99
// attempted, but that does not seem to occur.
10-
#![cfg(all(unix, not(target_os = "freebsd")))]
10+
#![cfg(all(unix, not(target_os = "freebsd"), not(miri)))]
1111

1212
use std::process::Stdio;
1313
use std::time::Duration;

tokio/tests/process_issue_42.rs

+1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
#![warn(rust_2018_idioms)]
22
#![cfg(feature = "full")]
33
#![cfg(unix)]
4+
#![cfg(not(miri))]
45

56
use futures::future::join_all;
67
use std::process::Stdio;

tokio/tests/process_kill_on_drop.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#![cfg(all(unix, feature = "process"))]
1+
#![cfg(all(unix, feature = "process", not(miri)))]
22
#![warn(rust_2018_idioms)]
33

44
use std::io::ErrorKind;

tokio/tests/process_raw_handle.rs

+1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
#![warn(rust_2018_idioms)]
22
#![cfg(feature = "full")]
33
#![cfg(windows)]
4+
#![cfg(not(miri))]
45

56
use tokio::process::Command;
67
use windows_sys::Win32::System::Threading::GetProcessId;

tokio/tests/process_smoke.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#![warn(rust_2018_idioms)]
2-
#![cfg(all(feature = "full", not(target_os = "wasi")))] // Wasi cannot run system commands
2+
#![cfg(all(feature = "full", not(target_os = "wasi"), not(miri)))] // Wasi cannot run system commands
33

44
use tokio::process::Command;
55
use tokio_test::assert_ok;

tokio/tests/rt_basic.rs

+1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
#![allow(unknown_lints, unexpected_cfgs)]
22
#![warn(rust_2018_idioms)]
33
#![cfg(feature = "full")]
4+
#![cfg(not(miri))] // Possible bug on Miri.
45

56
use tokio::runtime::Runtime;
67
use tokio::sync::oneshot;

tokio/tests/rt_common.rs

+1
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
#![allow(clippy::needless_range_loop)]
33
#![warn(rust_2018_idioms)]
44
#![cfg(feature = "full")]
5+
#![cfg(not(miri))]
56

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

tokio/tests/rt_handle_block_on.rs

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

44
// All io tests that deal with shutdown is currently ignored because there are known bugs in with
55
// shutting down the io driver while concurrently registering new resources. See

tokio/tests/rt_threaded.rs

+4-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
#![allow(unknown_lints, unexpected_cfgs)]
22
#![warn(rust_2018_idioms)]
3-
#![cfg(all(feature = "full", not(target_os = "wasi")))]
3+
// Too slow on miri.
4+
#![cfg(all(feature = "full", not(target_os = "wasi"), not(miri)))]
45

56
use tokio::io::{AsyncReadExt, AsyncWriteExt};
67
use tokio::net::{TcpListener, TcpStream};
@@ -321,6 +322,8 @@ fn start_stop_callbacks_called() {
321322
}
322323

323324
#[test]
325+
// too slow on miri
326+
#[cfg_attr(miri, ignore)]
324327
fn blocking() {
325328
// used for notifying the main thread
326329
const NUM: usize = 1_000;

tokio/tests/signal_ctrl_c.rs

+1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
#![warn(rust_2018_idioms)]
22
#![cfg(feature = "full")]
33
#![cfg(unix)]
4+
#![cfg(not(miri))] // No `sigaction` on Miri
45

56
mod support {
67
pub mod signal;

tokio/tests/signal_drop_recv.rs

+1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
#![warn(rust_2018_idioms)]
22
#![cfg(feature = "full")]
33
#![cfg(unix)]
4+
#![cfg(not(miri))]
45

56
mod support {
67
pub mod signal;

tokio/tests/signal_drop_rt.rs

+1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
#![warn(rust_2018_idioms)]
22
#![cfg(feature = "full")]
33
#![cfg(unix)]
4+
#![cfg(not(miri))]
45

56
mod support {
67
pub mod signal;

tokio/tests/signal_drop_signal.rs

+1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
#![warn(rust_2018_idioms)]
22
#![cfg(feature = "full")]
33
#![cfg(unix)]
4+
#![cfg(not(miri))]
45

56
mod support {
67
pub mod signal;

tokio/tests/signal_multi_rt.rs

+1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
#![warn(rust_2018_idioms)]
22
#![cfg(feature = "full")]
33
#![cfg(unix)]
4+
#![cfg(not(miri))] // No `sigaction` on Miri.
45

56
mod support {
67
pub mod signal;

tokio/tests/signal_no_rt.rs

+1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
#![warn(rust_2018_idioms)]
22
#![cfg(feature = "full")]
33
#![cfg(unix)]
4+
#![cfg(not(miri))] // No `sigaction` on Miri.
45

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

tokio/tests/signal_notify_both.rs

+1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
#![warn(rust_2018_idioms)]
22
#![cfg(feature = "full")]
33
#![cfg(unix)]
4+
#![cfg(not(miri))] // No `sigaction` on Miri.
45

56
mod support {
67
pub mod signal;

tokio/tests/signal_panic.rs

+1
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
#![cfg(feature = "full")]
33
#![cfg(unix)]
44
#![cfg(panic = "unwind")]
5+
#![cfg(not(miri))] // No `sigaction` on Miri.
56

67
use std::error::Error;
78
use tokio::runtime::Builder;

0 commit comments

Comments
 (0)