util: enable loom tests (#7644)

Co-authored-by: Benjamin Ran <[email protected]>
This commit is contained in:
Benjamin Ran
2025-11-06 19:20:08 +08:00
committed by GitHub
co-authored by Benjamin Ran
parent 0671c205cc
commit d84a9e9af3
12 changed files with 60 additions and 7 deletions
+4
View File
@@ -19,3 +19,7 @@ R-loom-multi-thread:
- tokio/src/runtime/scheduler/multi_thread/**
- tokio/src/runtime/task/*
- tokio/src/runtime/task/**
R-loom-util:
- tokio-util/src/*
- tokio-util/src/**/*
+16
View File
@@ -95,3 +95,19 @@ jobs:
working-directory: tokio
env:
SCOPE: ${{ matrix.scope }}
loom-util:
name: loom tokio-util
# base_ref is null when it's not a pull request
if: github.repository_owner == 'tokio-rs' && (contains(github.event.pull_request.labels.*.name, 'R-loom-util') || (github.base_ref == null))
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v5
- name: Install Rust ${{ env.rust_stable }}
uses: dtolnay/rust-toolchain@master
with:
toolchain: ${{ env.rust_stable }}
- uses: Swatinem/rust-cache@v2
- name: run tests
run: cargo test --lib --release --features full -- --nocapture
working-directory: tokio-util
+8 -4
View File
@@ -22,9 +22,9 @@ cfg_sync! {
}
cfg_signal! {
#[cfg(unix)]
#[cfg(all(unix, not(loom)))]
mod signal_unix;
#[cfg(unix)]
#[cfg(all(unix, not(loom)))]
pub use signal_unix::SignalStream;
#[cfg(any(windows, docsrs))]
@@ -39,12 +39,14 @@ cfg_time! {
}
cfg_net! {
#[cfg(not(loom))]
mod tcp_listener;
#[cfg(not(loom))]
pub use tcp_listener::TcpListenerStream;
#[cfg(unix)]
#[cfg(all(unix, not(loom)))]
mod unix_listener;
#[cfg(unix)]
#[cfg(all(unix, not(loom)))]
pub use unix_listener::UnixListenerStream;
}
@@ -57,6 +59,8 @@ cfg_io_util! {
}
cfg_fs! {
#[cfg(not(loom))]
mod read_dir;
#[cfg(not(loom))]
pub use read_dir::ReadDirStream;
}
+3
View File
@@ -57,6 +57,9 @@ futures-test = "0.3.5"
parking_lot = "0.12.0"
tempfile = "3.1.0"
[target.'cfg(loom)'.dev-dependencies]
loom = { version = "0.7", features = ["futures", "checkpoint"] }
[package.metadata.docs.rs]
all-features = true
# enable unstable features in the documentation
+1 -1
View File
@@ -212,7 +212,7 @@ where
}
}
#[cfg(test)]
#[cfg(all(test, not(loom)))]
mod tests {
use super::*;
use tokio::io::{repeat, AsyncReadExt, Repeat};
+9 -1
View File
@@ -1 +1,9 @@
pub(crate) use std::sync;
//! This module abstracts over `loom` and `std::sync` types depending on whether we
//! are running loom tests or not.
pub(crate) mod sync {
#[cfg(all(test, loom))]
pub(crate) use loom::sync::{Arc, Mutex, MutexGuard};
#[cfg(not(all(test, loom)))]
pub(crate) use std::sync::{Arc, Mutex, MutexGuard};
}
+2
View File
@@ -1,3 +1,5 @@
#![cfg(not(loom))]
//! TCP/UDP/Unix helpers for tokio.
use crate::either::Either;
+3
View File
@@ -15,3 +15,6 @@ pub use poll_semaphore::PollSemaphore;
mod reusable_box;
pub use reusable_box::ReusableBoxFuture;
#[cfg(test)]
mod tests;
@@ -100,6 +100,9 @@ fn drop_token_no_child() {
});
}
// Temporarily disabled due to a false positive in loom -
// see https://github.com/tokio-rs/tokio/pull/7644#issuecomment-3328381344
#[ignore]
#[test]
fn drop_token_with_children() {
loom::model(|| {
@@ -125,6 +128,9 @@ fn drop_token_with_children() {
});
}
// Temporarily disabled due to a false positive in loom -
// see https://github.com/tokio-rs/tokio/pull/7644#issuecomment-3328381344
#[ignore]
#[test]
fn drop_and_cancel_token() {
loom::model(|| {
@@ -150,6 +156,9 @@ fn drop_and_cancel_token() {
});
}
// Temporarily disabled due to a false positive in loom -
// see https://github.com/tokio-rs/tokio/pull/7644#issuecomment-3328381344
#[ignore]
#[test]
fn cancel_parent_and_child() {
loom::model(|| {
+2 -1
View File
@@ -1 +1,2 @@
#[cfg(loom)]
mod loom_cancellation_token;
+2
View File
@@ -1,3 +1,5 @@
#![cfg(not(loom))]
//! UDP framing
mod frame;
+1
View File
@@ -1,6 +1,7 @@
#![warn(rust_2018_idioms)]
#![cfg(not(target_os = "wasi"))] // Wasi doesn't support UDP
#![cfg(not(miri))] // No `socket` in Miri.
#![cfg(not(loom))] // No udp / UdpFramed in loom
use tokio::net::UdpSocket;
use tokio_stream::StreamExt;