summaryrefslogtreecommitdiffstats
path: root/vendor/tokio/tests/task_abort.rs
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-05-30 03:57:31 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-05-30 03:57:31 +0000
commitdc0db358abe19481e475e10c32149b53370f1a1c (patch)
treeab8ce99c4b255ce46f99ef402c27916055b899ee /vendor/tokio/tests/task_abort.rs
parentReleasing progress-linux version 1.71.1+dfsg1-2~progress7.99u1. (diff)
downloadrustc-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/task_abort.rs')
-rw-r--r--vendor/tokio/tests/task_abort.rs34
1 files changed, 14 insertions, 20 deletions
diff --git a/vendor/tokio/tests/task_abort.rs b/vendor/tokio/tests/task_abort.rs
index cdaa405b8..492f8b551 100644
--- a/vendor/tokio/tests/task_abort.rs
+++ b/vendor/tokio/tests/task_abort.rs
@@ -1,9 +1,9 @@
#![warn(rust_2018_idioms)]
-#![cfg(feature = "full")]
+#![cfg(all(feature = "full", not(tokio_wasi)))] // Wasi doesn't support panic recovery
use std::sync::Arc;
use std::thread::sleep;
-use std::time::Duration;
+use tokio::time::Duration;
use tokio::runtime::Builder;
@@ -26,13 +26,10 @@ fn test_abort_without_panic_3157() {
.unwrap();
rt.block_on(async move {
- let handle = tokio::spawn(async move {
- println!("task started");
- tokio::time::sleep(std::time::Duration::new(100, 0)).await
- });
+ let handle = tokio::spawn(async move { tokio::time::sleep(Duration::new(100, 0)).await });
// wait for task to sleep.
- tokio::time::sleep(std::time::Duration::new(1, 0)).await;
+ tokio::time::sleep(Duration::from_millis(10)).await;
handle.abort();
let _ = handle.await;
@@ -89,7 +86,7 @@ fn test_abort_without_panic_3662() {
// Note: We do the following to trigger a deferred task cleanup.
//
// The relevant piece of code you want to look at is in:
- // `Inner::block_on` of `basic_scheduler.rs`.
+ // `Inner::block_on` of `scheduler/current_thread.rs`.
//
// We cause the cleanup to happen by having a poll return Pending once
// so that the scheduler can go into the "auxiliary tasks" mode, at
@@ -138,7 +135,7 @@ fn remote_abort_local_set_3929() {
});
let jh2 = std::thread::spawn(move || {
- sleep(Duration::from_millis(50));
+ sleep(Duration::from_millis(10));
jh.abort();
});
@@ -159,18 +156,17 @@ fn test_abort_wakes_task_3964() {
let handle = tokio::spawn(async move {
// Make sure the Arc is moved into the task
let _notify_dropped = notify_dropped;
- println!("task started");
- tokio::time::sleep(std::time::Duration::new(100, 0)).await
+ tokio::time::sleep(Duration::new(100, 0)).await
});
// wait for task to sleep.
- tokio::time::sleep(std::time::Duration::from_millis(10)).await;
+ tokio::time::sleep(Duration::from_millis(10)).await;
handle.abort();
drop(handle);
// wait for task to abort.
- tokio::time::sleep(std::time::Duration::from_millis(10)).await;
+ tokio::time::sleep(Duration::from_millis(10)).await;
// Check that the Arc has been dropped.
assert!(weak_notify_dropped.upgrade().is_none());
@@ -187,18 +183,17 @@ fn test_abort_task_that_panics_on_drop_contained() {
let handle = tokio::spawn(async move {
// Make sure the Arc is moved into the task
let _panic_dropped = PanicOnDrop;
- println!("task started");
- tokio::time::sleep(std::time::Duration::new(100, 0)).await
+ tokio::time::sleep(Duration::new(100, 0)).await
});
// wait for task to sleep.
- tokio::time::sleep(std::time::Duration::from_millis(10)).await;
+ tokio::time::sleep(Duration::from_millis(10)).await;
handle.abort();
drop(handle);
// wait for task to abort.
- tokio::time::sleep(std::time::Duration::from_millis(10)).await;
+ tokio::time::sleep(Duration::from_millis(10)).await;
});
}
@@ -211,12 +206,11 @@ fn test_abort_task_that_panics_on_drop_returned() {
let handle = tokio::spawn(async move {
// Make sure the Arc is moved into the task
let _panic_dropped = PanicOnDrop;
- println!("task started");
- tokio::time::sleep(std::time::Duration::new(100, 0)).await
+ tokio::time::sleep(Duration::new(100, 0)).await
});
// wait for task to sleep.
- tokio::time::sleep(std::time::Duration::from_millis(10)).await;
+ tokio::time::sleep(Duration::from_millis(10)).await;
handle.abort();
assert!(handle.await.unwrap_err().is_panic());