runtime: add thread_park_ok test (#7402)

This commit is contained in:
Alice Ryhl
2025-06-16 09:49:00 +02:00
committed by GitHub
parent 933fa498d0
commit 99a03a502e
+18
View File
@@ -220,6 +220,24 @@ rt_test! {
assert_eq!(answer, 42);
}
#[test]
fn thread_park_ok() {
use core::task::Poll;
let rt = rt();
let mut exit = false;
rt.handle().block_on(core::future::poll_fn(move |cx| {
if exit {
return Poll::Ready(());
}
cx.waker().wake_by_ref();
// Verify that consuming the park token does not result in a hang.
std::thread::current().unpark();
std::thread::park();
exit = true;
Poll::Pending
}));
}
// ==== net ======
#[test]