From 39b28e3c5d711a69c13c6ec748d1ff058cf126c3 Mon Sep 17 00:00:00 2001 From: tiif Date: Wed, 1 Jan 2025 07:05:18 +0000 Subject: [PATCH 1/5] Disable all failed test --- tokio/src/net/tcp/listener.rs | 1 + tokio/src/net/tcp/socket.rs | 1 + tokio/src/net/tcp/stream.rs | 1 + tokio/src/net/udp.rs | 3 +++ tokio/src/net/unix/datagram/socket.rs | 19 +++++++++++++++++++ tokio/src/net/unix/stream.rs | 1 + tokio/src/process/mod.rs | 2 ++ tokio/src/runtime/runtime.rs | 1 + 8 files changed, 29 insertions(+) diff --git a/tokio/src/net/tcp/listener.rs b/tokio/src/net/tcp/listener.rs index 618da62b477..1545e654128 100644 --- a/tokio/src/net/tcp/listener.rs +++ b/tokio/src/net/tcp/listener.rs @@ -83,6 +83,7 @@ impl TcpListener { /// # Examples /// /// ```no_run + /// # if cfg!(miri) { return } // No `socket` in miri. /// use tokio::net::TcpListener; /// /// use std::io; diff --git a/tokio/src/net/tcp/socket.rs b/tokio/src/net/tcp/socket.rs index 762546ee309..a9b454b3c52 100644 --- a/tokio/src/net/tcp/socket.rs +++ b/tokio/src/net/tcp/socket.rs @@ -743,6 +743,7 @@ impl TcpSocket { /// # Examples /// /// ``` + /// # if cfg!(miri) { return } // No `socket` in miri. /// use tokio::net::TcpSocket; /// use socket2::{Domain, Socket, Type}; /// diff --git a/tokio/src/net/tcp/stream.rs b/tokio/src/net/tcp/stream.rs index 82f4c05f67b..f07e899ddf8 100644 --- a/tokio/src/net/tcp/stream.rs +++ b/tokio/src/net/tcp/stream.rs @@ -213,6 +213,7 @@ impl TcpStream { /// # Examples /// /// ``` + /// # if cfg!(miri) { return } // No `socket` in miri. /// use std::error::Error; /// use std::io::Read; /// use tokio::net::TcpListener; diff --git a/tokio/src/net/udp.rs b/tokio/src/net/udp.rs index 58bf566a728..00802b036dd 100644 --- a/tokio/src/net/udp.rs +++ b/tokio/src/net/udp.rs @@ -134,6 +134,7 @@ impl UdpSocket { /// # Example /// /// ```no_run + /// # if cfg!(miri) { return } // No `socket` in miri. /// use tokio::net::UdpSocket; /// use std::io; /// @@ -295,6 +296,7 @@ impl UdpSocket { /// # Example /// /// ``` + /// # if cfg!(miri) { return } // No `socket` in miri. /// use tokio::net::UdpSocket; /// /// # use std::{io, net::SocketAddr}; @@ -1979,6 +1981,7 @@ impl UdpSocket { /// /// # Examples /// ``` + /// # if cfg!(miri) { return } // No `socket` in miri. /// use tokio::net::UdpSocket; /// use std::io; /// diff --git a/tokio/src/net/unix/datagram/socket.rs b/tokio/src/net/unix/datagram/socket.rs index 0fde57da133..18a747a2918 100644 --- a/tokio/src/net/unix/datagram/socket.rs +++ b/tokio/src/net/unix/datagram/socket.rs @@ -35,6 +35,7 @@ cfg_net_unix! { /// # Examples /// Using named sockets, associated with a filesystem path: /// ``` + /// # if cfg!(miri) { return } // No `socket` in miri. /// # use std::error::Error; /// # #[tokio::main] /// # async fn main() -> Result<(), Box> { @@ -67,6 +68,7 @@ cfg_net_unix! { /// /// Using unnamed sockets, created as a pair /// ``` + /// # if cfg!(miri) { return } // No `socketpair` in miri. /// # use std::error::Error; /// # #[tokio::main] /// # async fn main() -> Result<(), Box> { @@ -371,6 +373,7 @@ impl UnixDatagram { /// /// # Examples /// ``` + /// # if cfg!(miri) { return } // No `socket` in miri. /// # use std::error::Error; /// # #[tokio::main] /// # async fn main() -> Result<(), Box> { @@ -403,6 +406,7 @@ impl UnixDatagram { /// /// # Examples /// ``` + /// # if cfg!(miri) { return } // No SOCK_DGRAM for socketpair in miri. /// # use std::error::Error; /// # #[tokio::main] /// # async fn main() -> Result<(), Box> { @@ -457,6 +461,7 @@ impl UnixDatagram { /// explicitly with [`Runtime::enter`](crate::runtime::Runtime::enter) function. /// # Examples /// ``` + /// # if cfg!(miri) { return } // No `socket` in miri. /// # use std::error::Error; /// # #[tokio::main] /// # async fn main() -> Result<(), Box> { @@ -521,6 +526,7 @@ impl UnixDatagram { /// /// # Examples /// ``` + /// # if cfg!(miri) { return } // No `socket` in miri. /// # use std::error::Error; /// # #[tokio::main] /// # async fn main() -> Result<(), Box> { @@ -560,6 +566,7 @@ impl UnixDatagram { /// /// # Examples /// ``` + /// # if cfg!(miri) { return } // No `socket` in miri. /// # use std::error::Error; /// # #[tokio::main] /// # async fn main() -> Result<(), Box> { @@ -604,6 +611,7 @@ impl UnixDatagram { /// /// # Examples /// ``` + /// # if cfg!(miri) { return } // No `socketpair` in miri. /// # use std::error::Error; /// # #[tokio::main] /// # async fn main() -> Result<(), Box> { @@ -734,6 +742,7 @@ impl UnixDatagram { /// /// # Examples /// ``` + /// # if cfg!(miri) { return } // No `socketpair` in miri. /// # use std::error::Error; /// # #[tokio::main] /// # async fn main() -> Result<(), Box> { @@ -884,6 +893,7 @@ impl UnixDatagram { /// /// # Examples /// ``` + /// # if cfg!(miri) { return } // No `socket` in miri. /// # use std::error::Error; /// # #[tokio::main] /// # async fn main() -> Result<(), Box> { @@ -1000,6 +1010,7 @@ impl UnixDatagram { /// /// # Examples /// ``` + /// # if cfg!(miri) { return } // No `socketpair` in miri. /// # use std::error::Error; /// # #[tokio::main] /// # async fn main() -> Result<(), Box> { @@ -1050,6 +1061,7 @@ impl UnixDatagram { /// /// # Examples /// ``` + /// # if cfg!(miri) { return } // No `socket` in miri. /// # use std::error::Error; /// # #[tokio::main] /// # async fn main() -> Result<(), Box> { @@ -1100,6 +1112,7 @@ impl UnixDatagram { /// /// # Examples /// ``` + /// # if cfg!(miri) { return } // No `socket` in miri. /// # use std::error::Error; /// # #[tokio::main] /// # async fn main() -> Result<(), Box> { @@ -1416,6 +1429,7 @@ impl UnixDatagram { /// # Examples /// For a socket bound to a local path /// ``` + /// # if cfg!(miri) { return } // No `socket` in miri. /// # use std::error::Error; /// # #[tokio::main] /// # async fn main() -> Result<(), Box> { @@ -1438,6 +1452,7 @@ impl UnixDatagram { /// /// For an unbound socket /// ``` + /// # if cfg!(miri) { return } // No `socket` in miri. /// # use std::error::Error; /// # #[tokio::main] /// # async fn main() -> Result<(), Box> { @@ -1462,6 +1477,7 @@ impl UnixDatagram { /// # Examples /// For a peer with a local path /// ``` + /// # if cfg!(miri) { return } // No `socket` in miri. /// # use std::error::Error; /// # #[tokio::main] /// # async fn main() -> Result<(), Box> { @@ -1487,6 +1503,7 @@ impl UnixDatagram { /// /// For an unbound peer /// ``` + /// # if cfg!(miri) { return } // No `socketpair` in miri. /// # use std::error::Error; /// # #[tokio::main] /// # async fn main() -> Result<(), Box> { @@ -1508,6 +1525,7 @@ impl UnixDatagram { /// /// # Examples /// ``` + /// # if cfg!(miri) { return } // No `socket` in miri. /// # use std::error::Error; /// # #[tokio::main] /// # async fn main() -> Result<(), Box> { @@ -1535,6 +1553,7 @@ impl UnixDatagram { /// /// # Examples /// ``` + /// # if cfg!(miri) { return } // No `socketpair` in miri. /// # use std::error::Error; /// # #[tokio::main] /// # async fn main() -> Result<(), Box> { diff --git a/tokio/src/net/unix/stream.rs b/tokio/src/net/unix/stream.rs index cc7b2bf44a1..16dc03f9a30 100644 --- a/tokio/src/net/unix/stream.rs +++ b/tokio/src/net/unix/stream.rs @@ -833,6 +833,7 @@ impl UnixStream { /// # Examples /// /// ``` + /// # if cfg!(miri) { return } // No `socket` in miri. /// use std::error::Error; /// use std::io::Read; /// use tokio::net::UnixListener; diff --git a/tokio/src/process/mod.rs b/tokio/src/process/mod.rs index 8ca4818362a..f83d268d78f 100644 --- a/tokio/src/process/mod.rs +++ b/tokio/src/process/mod.rs @@ -810,6 +810,7 @@ impl Command { /// Basic usage: /// /// ```no_run + /// # if cfg!(miri) { return } // No `pidfd_spawnp` in miri. /// use tokio::process::Command; /// /// async fn run_ls() -> std::process::ExitStatus { @@ -1192,6 +1193,7 @@ impl Child { /// This function is cancel safe. /// /// ``` + /// # if cfg!(miri) { return } // No`pidfd_spawnp` in miri. /// # #[cfg(not(unix))]fn main(){} /// # #[cfg(unix)] /// use tokio::io::AsyncWriteExt; diff --git a/tokio/src/runtime/runtime.rs b/tokio/src/runtime/runtime.rs index 242c37e0fbc..692ddf1b946 100644 --- a/tokio/src/runtime/runtime.rs +++ b/tokio/src/runtime/runtime.rs @@ -421,6 +421,7 @@ impl Runtime { /// # Examples /// /// ``` + /// # if cfg!(miri) { return } // miri report error when main thread terminated without waiting all remaining threads. /// use tokio::runtime::Runtime; /// use tokio::task; /// From 3eb4ace6c65955b4ff42c59e3f5b85a4cb8ea7b9 Mon Sep 17 00:00:00 2001 From: tiif Date: Wed, 1 Jan 2025 07:11:38 +0000 Subject: [PATCH 2/5] Update CI --- .github/workflows/ci.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 407df8a4a54..721f9c885b9 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -399,6 +399,7 @@ jobs: - name: miri run: | cargo miri nextest run --features full --lib --tests --no-fail-fast + cargo miri test --doc --all-features --no-fail-fast working-directory: tokio env: MIRIFLAGS: -Zmiri-disable-isolation -Zmiri-strict-provenance -Zmiri-retag-fields From 2fd4d417f0c96111092484af50b3a30f792924d3 Mon Sep 17 00:00:00 2001 From: tiif Date: Wed, 1 Jan 2025 11:50:55 +0000 Subject: [PATCH 3/5] Fix typo --- tokio/src/process/mod.rs | 2 +- tokio/src/runtime/runtime.rs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/tokio/src/process/mod.rs b/tokio/src/process/mod.rs index f83d268d78f..3077c4edc90 100644 --- a/tokio/src/process/mod.rs +++ b/tokio/src/process/mod.rs @@ -1193,7 +1193,7 @@ impl Child { /// This function is cancel safe. /// /// ``` - /// # if cfg!(miri) { return } // No`pidfd_spawnp` in miri. + /// # if cfg!(miri) { return } // No `pidfd_spawnp` in miri. /// # #[cfg(not(unix))]fn main(){} /// # #[cfg(unix)] /// use tokio::io::AsyncWriteExt; diff --git a/tokio/src/runtime/runtime.rs b/tokio/src/runtime/runtime.rs index 692ddf1b946..ea6bb247941 100644 --- a/tokio/src/runtime/runtime.rs +++ b/tokio/src/runtime/runtime.rs @@ -421,7 +421,7 @@ impl Runtime { /// # Examples /// /// ``` - /// # if cfg!(miri) { return } // miri report error when main thread terminated without waiting all remaining threads. + /// # if cfg!(miri) { return } // Miri reports error when main thread terminated without waiting all remaining threads. /// use tokio::runtime::Runtime; /// use tokio::task; /// From 87993ef864b25f2bbd8b5f54afd42ab9509b292a Mon Sep 17 00:00:00 2001 From: tiif Date: Thu, 2 Jan 2025 12:40:21 +0000 Subject: [PATCH 4/5] Add a new job for miri doc test --- .github/workflows/ci.yml | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 721f9c885b9..5408aec2976 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -399,11 +399,29 @@ jobs: - name: miri run: | cargo miri nextest run --features full --lib --tests --no-fail-fast - cargo miri test --doc --all-features --no-fail-fast working-directory: tokio env: MIRIFLAGS: -Zmiri-disable-isolation -Zmiri-strict-provenance -Zmiri-retag-fields + miri-doc-test: + name: miri-doc-test + needs: basics + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - name: Install Rust ${{ env.rust_miri_nightly }} + uses: dtolnay/rust-toolchain@stable + with: + toolchain: ${{ env.rust_miri_nightly }} + components: miri + - uses: Swatinem/rust-cache@v2 + - name: miri-doc-test + run: | + cargo miri test --doc --all-features --no-fail-fast + working-directory: tokio + env: + MIRIFLAGS: -Zmiri-disable-isolation -Zmiri-strict-provenance -Zmiri-retag-fields + asan: name: asan needs: basics From bed392133de12221f87c2e7cffefcbe2889e9466 Mon Sep 17 00:00:00 2001 From: tiif Date: Thu, 2 Jan 2025 12:50:35 +0000 Subject: [PATCH 5/5] remove trailing whitespace --- .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 5408aec2976..ed5470e52a3 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -420,7 +420,7 @@ jobs: cargo miri test --doc --all-features --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 asan: name: asan