diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-05-30 03:57:31 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-05-30 03:57:31 +0000 |
commit | dc0db358abe19481e475e10c32149b53370f1a1c (patch) | |
tree | ab8ce99c4b255ce46f99ef402c27916055b899ee /vendor/tokio/tests/rt_handle.rs | |
parent | Releasing progress-linux version 1.71.1+dfsg1-2~progress7.99u1. (diff) | |
download | rustc-dc0db358abe19481e475e10c32149b53370f1a1c.tar.xz rustc-dc0db358abe19481e475e10c32149b53370f1a1c.zip |
Merging upstream version 1.72.1+dfsg1.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'vendor/tokio/tests/rt_handle.rs')
-rw-r--r-- | vendor/tokio/tests/rt_handle.rs | 67 |
1 files changed, 67 insertions, 0 deletions
diff --git a/vendor/tokio/tests/rt_handle.rs b/vendor/tokio/tests/rt_handle.rs new file mode 100644 index 000000000..34c99cdae --- /dev/null +++ b/vendor/tokio/tests/rt_handle.rs @@ -0,0 +1,67 @@ +#![warn(rust_2018_idioms)] +#![cfg(feature = "full")] + +use tokio::runtime::Runtime; + +#[test] +fn basic_enter() { + let rt1 = rt(); + let rt2 = rt(); + + let enter1 = rt1.enter(); + let enter2 = rt2.enter(); + + drop(enter2); + drop(enter1); +} + +#[test] +#[should_panic] +fn interleave_enter_different_rt() { + let rt1 = rt(); + let rt2 = rt(); + + let enter1 = rt1.enter(); + let enter2 = rt2.enter(); + + drop(enter1); + drop(enter2); +} + +#[test] +#[should_panic] +fn interleave_enter_same_rt() { + let rt1 = rt(); + + let _enter1 = rt1.enter(); + let enter2 = rt1.enter(); + let enter3 = rt1.enter(); + + drop(enter2); + drop(enter3); +} + +#[test] +#[cfg(not(tokio_wasi))] +fn interleave_then_enter() { + let _ = std::panic::catch_unwind(|| { + let rt1 = rt(); + let rt2 = rt(); + + let enter1 = rt1.enter(); + let enter2 = rt2.enter(); + + drop(enter1); + drop(enter2); + }); + + // Can still enter + let rt3 = rt(); + let _enter = rt3.enter(); +} + +fn rt() -> Runtime { + tokio::runtime::Builder::new_current_thread() + .build() + .unwrap() +} |