mirror of
https://github.com/tokio-rs/tokio.git
synced 2025-10-01 12:20:39 +00:00
test: test with tracing (#3906)
This commit is contained in:
parent
b877629cb1
commit
90e1935c48
2
.github/workflows/ci.yml
vendored
2
.github/workflows/ci.yml
vendored
@ -122,7 +122,7 @@ jobs:
|
|||||||
|
|
||||||
# Run `tokio` with "unstable" cfg flag.
|
# Run `tokio` with "unstable" cfg flag.
|
||||||
- name: test tokio full --cfg unstable
|
- name: test tokio full --cfg unstable
|
||||||
run: cargo test --features full
|
run: cargo test --all-features
|
||||||
working-directory: tokio
|
working-directory: tokio
|
||||||
env:
|
env:
|
||||||
RUSTFLAGS: --cfg tokio_unstable -Dwarnings
|
RUSTFLAGS: --cfg tokio_unstable -Dwarnings
|
||||||
|
@ -30,7 +30,7 @@ fn basic() {
|
|||||||
|
|
||||||
for _ in 0..2 {
|
for _ in 0..2 {
|
||||||
for _ in 0..2 {
|
for _ in 0..2 {
|
||||||
let (task, _) = task::joinable::<_, Runtime>(async {});
|
let (task, _) = super::joinable::<_, Runtime>(async {});
|
||||||
local.push_back(task, &inject);
|
local.push_back(task, &inject);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -39,7 +39,7 @@ fn basic() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Push another task
|
// Push another task
|
||||||
let (task, _) = task::joinable::<_, Runtime>(async {});
|
let (task, _) = super::joinable::<_, Runtime>(async {});
|
||||||
local.push_back(task, &inject);
|
local.push_back(task, &inject);
|
||||||
|
|
||||||
while local.pop().is_some() {
|
while local.pop().is_some() {
|
||||||
@ -81,7 +81,7 @@ fn steal_overflow() {
|
|||||||
let mut n = 0;
|
let mut n = 0;
|
||||||
|
|
||||||
// push a task, pop a task
|
// push a task, pop a task
|
||||||
let (task, _) = task::joinable::<_, Runtime>(async {});
|
let (task, _) = super::joinable::<_, Runtime>(async {});
|
||||||
local.push_back(task, &inject);
|
local.push_back(task, &inject);
|
||||||
|
|
||||||
if local.pop().is_some() {
|
if local.pop().is_some() {
|
||||||
@ -89,7 +89,7 @@ fn steal_overflow() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
for _ in 0..6 {
|
for _ in 0..6 {
|
||||||
let (task, _) = task::joinable::<_, Runtime>(async {});
|
let (task, _) = super::joinable::<_, Runtime>(async {});
|
||||||
local.push_back(task, &inject);
|
local.push_back(task, &inject);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -133,7 +133,7 @@ fn multi_stealer() {
|
|||||||
|
|
||||||
// Push work
|
// Push work
|
||||||
for _ in 0..NUM_TASKS {
|
for _ in 0..NUM_TASKS {
|
||||||
let (task, _) = task::joinable::<_, Runtime>(async {});
|
let (task, _) = super::joinable::<_, Runtime>(async {});
|
||||||
local.push_back(task, &inject);
|
local.push_back(task, &inject);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -170,10 +170,10 @@ fn chained_steal() {
|
|||||||
|
|
||||||
// Load up some tasks
|
// Load up some tasks
|
||||||
for _ in 0..4 {
|
for _ in 0..4 {
|
||||||
let (task, _) = task::joinable::<_, Runtime>(async {});
|
let (task, _) = super::joinable::<_, Runtime>(async {});
|
||||||
l1.push_back(task, &inject);
|
l1.push_back(task, &inject);
|
||||||
|
|
||||||
let (task, _) = task::joinable::<_, Runtime>(async {});
|
let (task, _) = super::joinable::<_, Runtime>(async {});
|
||||||
l2.push_back(task, &inject);
|
l2.push_back(task, &inject);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,3 +1,24 @@
|
|||||||
|
#[cfg(not(all(tokio_unstable, feature = "tracing")))]
|
||||||
|
use crate::runtime::task::joinable;
|
||||||
|
|
||||||
|
#[cfg(all(tokio_unstable, feature = "tracing"))]
|
||||||
|
use self::joinable_wrapper::joinable;
|
||||||
|
|
||||||
|
#[cfg(all(tokio_unstable, feature = "tracing"))]
|
||||||
|
mod joinable_wrapper {
|
||||||
|
use crate::runtime::task::{JoinHandle, Notified, Schedule};
|
||||||
|
use tracing::Instrument;
|
||||||
|
|
||||||
|
pub(crate) fn joinable<T, S>(task: T) -> (Notified<S>, JoinHandle<T::Output>)
|
||||||
|
where
|
||||||
|
T: std::future::Future + Send + 'static,
|
||||||
|
S: Schedule,
|
||||||
|
{
|
||||||
|
let span = tracing::trace_span!("test_span");
|
||||||
|
crate::runtime::task::joinable(task.instrument(span))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
cfg_loom! {
|
cfg_loom! {
|
||||||
mod loom_basic_scheduler;
|
mod loom_basic_scheduler;
|
||||||
mod loom_blocking;
|
mod loom_blocking;
|
||||||
|
@ -10,7 +10,7 @@ fn fits_256() {
|
|||||||
let inject = queue::Inject::new();
|
let inject = queue::Inject::new();
|
||||||
|
|
||||||
for _ in 0..256 {
|
for _ in 0..256 {
|
||||||
let (task, _) = task::joinable::<_, Runtime>(async {});
|
let (task, _) = super::joinable::<_, Runtime>(async {});
|
||||||
local.push_back(task, &inject);
|
local.push_back(task, &inject);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -25,7 +25,7 @@ fn overflow() {
|
|||||||
let inject = queue::Inject::new();
|
let inject = queue::Inject::new();
|
||||||
|
|
||||||
for _ in 0..257 {
|
for _ in 0..257 {
|
||||||
let (task, _) = task::joinable::<_, Runtime>(async {});
|
let (task, _) = super::joinable::<_, Runtime>(async {});
|
||||||
local.push_back(task, &inject);
|
local.push_back(task, &inject);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -49,7 +49,7 @@ fn steal_batch() {
|
|||||||
let inject = queue::Inject::new();
|
let inject = queue::Inject::new();
|
||||||
|
|
||||||
for _ in 0..4 {
|
for _ in 0..4 {
|
||||||
let (task, _) = task::joinable::<_, Runtime>(async {});
|
let (task, _) = super::joinable::<_, Runtime>(async {});
|
||||||
local1.push_back(task, &inject);
|
local1.push_back(task, &inject);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -103,7 +103,7 @@ fn stress1() {
|
|||||||
|
|
||||||
for _ in 0..NUM_LOCAL {
|
for _ in 0..NUM_LOCAL {
|
||||||
for _ in 0..NUM_PUSH {
|
for _ in 0..NUM_PUSH {
|
||||||
let (task, _) = task::joinable::<_, Runtime>(async {});
|
let (task, _) = super::joinable::<_, Runtime>(async {});
|
||||||
local.push_back(task, &inject);
|
local.push_back(task, &inject);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -158,7 +158,7 @@ fn stress2() {
|
|||||||
let mut num_pop = 0;
|
let mut num_pop = 0;
|
||||||
|
|
||||||
for i in 0..NUM_TASKS {
|
for i in 0..NUM_TASKS {
|
||||||
let (task, _) = task::joinable::<_, Runtime>(async {});
|
let (task, _) = super::joinable::<_, Runtime>(async {});
|
||||||
local.push_back(task, &inject);
|
local.push_back(task, &inject);
|
||||||
|
|
||||||
if i % 128 == 0 && local.pop().is_some() {
|
if i % 128 == 0 && local.pop().is_some() {
|
||||||
|
@ -7,13 +7,13 @@ use std::sync::Arc;
|
|||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn create_drop() {
|
fn create_drop() {
|
||||||
let _ = task::joinable::<_, Runtime>(async { unreachable!() });
|
let _ = super::joinable::<_, Runtime>(async { unreachable!() });
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn schedule() {
|
fn schedule() {
|
||||||
with(|rt| {
|
with(|rt| {
|
||||||
let (task, _) = task::joinable(async {
|
let (task, _) = super::joinable(async {
|
||||||
crate::task::yield_now().await;
|
crate::task::yield_now().await;
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -26,7 +26,7 @@ fn schedule() {
|
|||||||
#[test]
|
#[test]
|
||||||
fn shutdown() {
|
fn shutdown() {
|
||||||
with(|rt| {
|
with(|rt| {
|
||||||
let (task, _) = task::joinable(async {
|
let (task, _) = super::joinable(async {
|
||||||
loop {
|
loop {
|
||||||
crate::task::yield_now().await;
|
crate::task::yield_now().await;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user