Skip to content
Draft

test #80

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
95 changes: 30 additions & 65 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -120,8 +120,10 @@ jobs:
- name: test tokio full
run: |
set -euxo pipefail
cargo nextest run --features full
cargo test --doc --features full
# We use `--features "full,test-util"` instead of `--all-features` since
# `--all-features` includes `io_uring`, which is not available on all targets.
cargo nextest run --features full,test-util
cargo test --doc --features full,test-util
working-directory: tokio

test-workspace-all-features:
Expand Down Expand Up @@ -287,9 +289,12 @@ jobs:
strategy:
matrix:
include:
- os: windows-latest
- os: ubuntu-latest
- os: macos-latest
# We use `--features "full,test-util"` instead of `--all-features` since
# `--all-features` includes `io_uring`, which is not available on all targets.
- { os: windows-latest, features: "full,test-util" }
- { os: ubuntu-latest, features: "full,test-util" }
- { os: ubuntu-latest, features: "full,test-util,io-uring" }
- { os: macos-latest, features: "full,test-util" }
steps:
- uses: actions/checkout@v5
- name: Install Rust ${{ env.rust_stable }}
Expand All @@ -307,8 +312,8 @@ jobs:
- name: test tokio full --cfg unstable
run: |
set -euxo pipefail
cargo nextest run --all-features
cargo test --doc --all-features
cargo nextest run --features ${{ matrix.features }}
cargo test --doc --features ${{ matrix.features }}
working-directory: tokio
env:
RUSTFLAGS: --cfg tokio_unstable -Dwarnings
Expand Down Expand Up @@ -350,50 +355,6 @@ jobs:
# the unstable cfg to RustDoc
RUSTDOCFLAGS: --cfg tokio_unstable --cfg tokio_taskdump

test-uring:
name: test tokio full --cfg tokio_uring
needs: basics
runs-on: ${{ matrix.os }}
strategy:
matrix:
include:
- os: ubuntu-latest
steps:
- name: check if io-uring is supported in the CI environment
run: |
# Try to read the io-uring setting in the kernel config file.
# https://github.com/torvalds/linux/blob/75f5f23f8787c5e184fcb2fbcd02d8e9317dc5e7/init/Kconfig#L1782-L1789
CONFIG_FILE="/boot/config-$(uname -r)"
echo "Checking $CONFIG_FILE for io-uring support"
if ! grep -q "CONFIG_IO_URING=y" "$CONFIG_FILE"; then
echo "Error: io_uring is not supported"
exit 1
fi

- uses: actions/checkout@v5
- name: Install Rust ${{ env.rust_stable }}
uses: dtolnay/rust-toolchain@stable
with:
toolchain: ${{ env.rust_stable }}

- name: Install cargo-nextest
uses: taiki-e/install-action@v2
with:
tool: cargo-nextest

- uses: Swatinem/rust-cache@v2
- name: test tokio full --cfg tokio_uring
run: |
set -euxo pipefail
cargo nextest run --all-features
cargo test --doc --all-features
working-directory: tokio
env:
RUSTFLAGS: --cfg tokio_uring -Dwarnings
# in order to run doctests for unstable features, we must also pass
# the unstable cfg to RustDoc
RUSTDOCFLAGS: --cfg tokio_uring

check-unstable-mt-counters:
name: check tokio full --internal-mt-counters
needs: basics
Expand Down Expand Up @@ -552,7 +513,8 @@ jobs:
target: ${{ matrix.target }}

- uses: Swatinem/rust-cache@v2
- run: cargo check --workspace --all-features --target ${{ matrix.target }}
# We don't use --all-features since io-uring will be enabled and is not supported on those targets.
- run: cargo check --workspace --features full,test-util --target ${{ matrix.target }}
env:
RUSTFLAGS: --cfg tokio_unstable -Dwarnings

Expand Down Expand Up @@ -622,8 +584,10 @@ jobs:
- name: Tests run with all features (including parking_lot)
run: |
set -euxo pipefail
cargo nextest run -p tokio --all-features --target ${{ matrix.target }}
cargo test --doc -p tokio --all-features --target ${{ matrix.target }}
# We use `--features "full,test-util"` instead of `--all-features` since
# `--all-features` includes `io_uring`, which is not available on all targets.
cargo nextest run -p tokio --features full,test-util --target ${{ matrix.target }}
cargo test --doc -p tokio --features full,test-util --target ${{ matrix.target }}
env:
RUST_TEST_THREADS: 1
RUSTFLAGS: --cfg tokio_unstable -Dwarnings --cfg tokio_no_tuning_tests ${{ matrix.rustflags }}
Expand Down Expand Up @@ -672,6 +636,8 @@ jobs:
- name: Tests run with all features (without parking_lot)
run: |
set -euxo pipefail
# We use `--features "full,test-util"` instead of `--all-features` since
# `--all-features` includes `io_uring`, which is not available on all targets.
cargo nextest run -p tokio --features full,test-util --target ${{ matrix.target }}
cargo test --doc -p tokio --features full,test-util --target ${{ matrix.target }}
env:
Expand Down Expand Up @@ -704,8 +670,10 @@ jobs:
- uses: Swatinem/rust-cache@v2
- name: test tokio --all-features
run: |
cargo nextest run -Zbuild-std --target target-specs/i686-unknown-linux-gnu.json -p tokio --all-features
cargo test --doc -Zbuild-std --target target-specs/i686-unknown-linux-gnu.json -p tokio --all-features
# We use `--features "full,test-util"` instead of `--all-features` since
# `--all-features` includes `io_uring`, which is not available on all targets.
cargo nextest run -Zbuild-std --target target-specs/i686-unknown-linux-gnu.json -p tokio --features full,test-util
cargo test --doc -Zbuild-std --target target-specs/i686-unknown-linux-gnu.json -p tokio --features full,test-util
env:
RUST_TEST_THREADS: 1
RUSTFLAGS: --cfg tokio_unstable --cfg tokio_taskdump -Dwarnings --cfg tokio_no_tuning_tests
Expand All @@ -731,7 +699,8 @@ jobs:
# https://github.com/tokio-rs/tokio/pull/5356
# https://github.com/tokio-rs/tokio/issues/5373
- name: Check
run: cargo hack check -Zbuild-std --target target-specs/i686-unknown-linux-gnu.json -p tokio --feature-powerset --depth 2 --keep-going
# We use `--skip io-uring` since io-uring crate doesn't provide a binding for the i686 target.
run: cargo hack check -Zbuild-std --target target-specs/i686-unknown-linux-gnu.json -p tokio --feature-powerset --skip io-uring --depth 2 --keep-going
env:
RUSTFLAGS: --cfg tokio_unstable --cfg tokio_taskdump -Dwarnings

Expand All @@ -743,12 +712,8 @@ jobs:
matrix:
include:
- { name: "", rustflags: "" }
# Try with unstable feature flags
- { name: "--unstable", rustflags: "--cfg tokio_unstable -Dwarnings" }
# Try with unstable and taskdump feature flags
- { name: "--unstable --taskdump", rustflags: "--cfg tokio_unstable -Dwarnings --cfg tokio_taskdump" }
- { name: "--tokio_uring", rustflags: "-Dwarnings --cfg tokio_uring" }
- { name: "--unstable --taskdump --tokio_uring", rustflags: "--cfg tokio_unstable -Dwarnings --cfg tokio_taskdump --cfg tokio_uring" }
steps:
- uses: actions/checkout@v5
- name: Install Rust ${{ env.rust_nightly }}
Expand Down Expand Up @@ -811,7 +776,7 @@ jobs:
cargo hack check --all-features --ignore-private
- name: "check --all-features --unstable -Z minimal-versions"
env:
RUSTFLAGS: --cfg tokio_unstable --cfg tokio_taskdump --cfg tokio_uring -Dwarnings
RUSTFLAGS: --cfg tokio_unstable --cfg tokio_taskdump -Dwarnings
run: |
# Remove dev-dependencies from Cargo.toml to prevent the next `cargo update`
# from determining minimal versions based on dev-dependencies.
Expand Down Expand Up @@ -847,7 +812,7 @@ jobs:
matrix:
rustflags:
- ""
- "--cfg tokio_unstable --cfg tokio_taskdump --cfg tokio_uring -Dwarnings"
- "--cfg tokio_unstable --cfg tokio_taskdump -Dwarnings"
steps:
- uses: actions/checkout@v5
- name: Install Rust ${{ env.rust_clippy }}
Expand All @@ -869,8 +834,8 @@ jobs:
run:
- os: windows-latest
- os: ubuntu-latest
RUSTFLAGS: --cfg tokio_taskdump --cfg tokio_uring
RUSTDOCFLAGS: --cfg tokio_taskdump --cfg tokio_uring
RUSTFLAGS: --cfg tokio_taskdump
RUSTDOCFLAGS: --cfg tokio_taskdump

steps:
- uses: actions/checkout@v5
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/uring-kernel-version-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,8 @@ jobs:
run: |
# Build both integration (tokio/tests/) and unit (e.g., tokio/src/fs/file/tests.rs) tests with io_uring enabled
rustup target add x86_64-unknown-linux-musl
RUSTFLAGS="--cfg tokio_uring" \
cargo test -p tokio --features full \
RUSTFLAGS="--cfg tokio_unstable" \
cargo test -p tokio --features full,io-uring \
--target x86_64-unknown-linux-musl --test 'fs*' --lib --no-run

- name: Prepare initramfs + tests binaries
Expand Down
1 change: 0 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,5 @@ unexpected_cfgs = { level = "warn", check-cfg = [
'cfg(tokio_no_tuning_tests)',
'cfg(tokio_taskdump)',
'cfg(tokio_unstable)',
'cfg(tokio_uring)',
'cfg(target_os, values("cygwin"))',
] }
18 changes: 11 additions & 7 deletions tokio/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,8 @@ signal = [
sync = []
test-util = ["rt", "sync", "time"]
time = []
# Unstable feature. Requires `--cfg tokio_unstable` to enable.
io-uring = ["dep:io-uring", "libc", "mio/os-poll", "mio/os-ext", "dep:slab"]

[dependencies]
tokio-macros = { version = "~2.5.0", path = "../tokio-macros", optional = true }
Expand All @@ -103,11 +105,13 @@ socket2 = { version = "0.6.0", optional = true, features = ["all"] }
[target.'cfg(tokio_unstable)'.dependencies]
tracing = { version = "0.1.29", default-features = false, features = ["std"], optional = true } # Not in full

[target.'cfg(all(tokio_uring, target_os = "linux"))'.dependencies]
io-uring = { version = "0.7.6", default-features = false }
libc = { version = "0.2.168" }
mio = { version = "1.0.1", default-features = false, features = ["os-poll", "os-ext"] }
slab = "0.4.9"
# Currently unstable. The API exposed by these features may be broken at any time.
# Requires `--cfg tokio_unstable` to enable.
[target.'cfg(all(tokio_unstable, target_os = "linux"))'.dependencies]
io-uring = { version = "0.7.6", default-features = false, optional = true }
libc = { version = "0.2.168", optional = true }
mio = { version = "1.0.1", default-features = false, features = ["os-poll", "os-ext"], optional = true }
slab = { version = "0.4.9", optional = true }

# Currently unstable. The API exposed by these features may be broken at any time.
# Requires `--cfg tokio_unstable` to enable.
Expand Down Expand Up @@ -165,10 +169,10 @@ tracing-mock = "= 0.1.0-beta.1"
[package.metadata.docs.rs]
all-features = true
# enable unstable features in the documentation
rustdoc-args = ["--cfg", "docsrs", "--cfg", "tokio_unstable", "--cfg", "tokio_taskdump", "--cfg", "tokio_uring"]
rustdoc-args = ["--cfg", "docsrs", "--cfg", "tokio_unstable", "--cfg", "tokio_taskdump"]
# it's necessary to _also_ pass `--cfg tokio_unstable` and `--cfg tokio_taskdump`
# to rustc, or else dependencies will not be enabled, and the docs build will fail.
rustc-args = ["--cfg", "tokio_unstable", "--cfg", "tokio_taskdump", "--cfg", "tokio_uring"]
rustc-args = ["--cfg", "tokio_unstable", "--cfg", "tokio_taskdump"]

[package.metadata.playground]
features = ["full", "test-util"]
Expand Down
2 changes: 1 addition & 1 deletion tokio/src/fs/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,7 @@ pub use self::metadata::metadata;

mod open_options;
pub use self::open_options::OpenOptions;
cfg_tokio_uring! {
cfg_io_uring! {
pub(crate) use self::open_options::UringOpenOptions;
}

Expand Down
Loading
Loading