From 10134528c6b02b2cbc99bcae05c281120879b279 Mon Sep 17 00:00:00 2001 From: Jason Orendorff Date: Mon, 7 Nov 2022 16:51:47 -0600 Subject: [PATCH] Add a loom test that seems to pass. --- tokio/src/runtime/tests/loom_blocking.rs | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/tokio/src/runtime/tests/loom_blocking.rs b/tokio/src/runtime/tests/loom_blocking.rs index 89de85e4362..3ecb967a4fa 100644 --- a/tokio/src/runtime/tests/loom_blocking.rs +++ b/tokio/src/runtime/tests/loom_blocking.rs @@ -73,6 +73,26 @@ fn spawn_mandatory_blocking_should_run_even_when_shutting_down_from_other_thread }); } +#[test] +fn spawn_blocking_when_paused() { + use std::time::Duration; + loom::model(|| { + let rt = crate::runtime::Builder::new_current_thread() + .enable_time() + .start_paused(true) + .build() + .unwrap(); + let handle = rt.handle(); + let _enter = handle.enter(); + rt.block_on(crate::time::timeout( + Duration::from_millis(1), + crate::task::spawn_blocking(|| {}), + )) + .expect("timeout should not trigger") + .expect("blocking task should finish"); + }); +} + fn mk_runtime(num_threads: usize) -> Runtime { runtime::Builder::new_multi_thread() .worker_threads(num_threads)