Skip to content

Commit 0ad4dd4

Browse files
committed
std: add thread parking tests
1 parent 99182dd commit 0ad4dd4

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

Diff for: library/std/src/thread/tests.rs

+22
Original file line numberDiff line numberDiff line change
@@ -244,6 +244,28 @@ fn test_try_panic_any_message_unit_struct() {
244244
}
245245
}
246246

247+
#[test]
248+
fn test_park_unpark_before() {
249+
for _ in 0..10 {
250+
thread::current().unpark();
251+
thread::park();
252+
}
253+
}
254+
255+
#[test]
256+
fn test_park_unpark_called_other_thread() {
257+
for _ in 0..10 {
258+
let th = thread::current();
259+
260+
let _guard = thread::spawn(move || {
261+
super::sleep(Duration::from_millis(50));
262+
th.unpark();
263+
});
264+
265+
thread::park();
266+
}
267+
}
268+
247269
#[test]
248270
fn test_park_timeout_unpark_before() {
249271
for _ in 0..10 {

0 commit comments

Comments
 (0)