From a4cbbddc8e45ea4271636bc42fea8baf8bc51523 Mon Sep 17 00:00:00 2001 From: Ralf Jung Date: Sat, 3 Oct 2020 15:27:23 +0200 Subject: [PATCH] merge parking test into general synchronization test --- tests/run-pass/concurrency/parking.rs | 37 ----------------------- tests/run-pass/concurrency/parking.stderr | 2 -- tests/run-pass/concurrency/sync.rs | 30 ++++++++++++++++++ 3 files changed, 30 insertions(+), 39 deletions(-) delete mode 100644 tests/run-pass/concurrency/parking.rs delete mode 100644 tests/run-pass/concurrency/parking.stderr diff --git a/tests/run-pass/concurrency/parking.rs b/tests/run-pass/concurrency/parking.rs deleted file mode 100644 index 1ed742931fe..00000000000 --- a/tests/run-pass/concurrency/parking.rs +++ /dev/null @@ -1,37 +0,0 @@ -// ignore-windows: Concurrency on Windows is not supported yet. -// compile-flags: -Zmiri-disable-isolation - -use std::thread; -use std::time::{Duration, Instant}; - -// Normally, waiting in park/park_timeout may spuriously wake up early, but we -// know Miri's timed synchronization primitives do not do that. - -fn park_timeout() { - let start = Instant::now(); - - thread::park_timeout(Duration::from_millis(200)); - - assert!((200..500).contains(&start.elapsed().as_millis())); -} - -fn park_unpark() { - let t1 = thread::current(); - let t2 = thread::spawn(move || { - thread::park(); - thread::sleep(Duration::from_millis(200)); - t1.unpark(); - }); - - let start = Instant::now(); - - t2.thread().unpark(); - thread::park(); - - assert!((200..500).contains(&start.elapsed().as_millis())); -} - -fn main() { - park_timeout(); - park_unpark(); -} diff --git a/tests/run-pass/concurrency/parking.stderr b/tests/run-pass/concurrency/parking.stderr deleted file mode 100644 index 2dbfb7721d3..00000000000 --- a/tests/run-pass/concurrency/parking.stderr +++ /dev/null @@ -1,2 +0,0 @@ -warning: thread support is experimental. For example, Miri does not detect data races yet. - diff --git a/tests/run-pass/concurrency/sync.rs b/tests/run-pass/concurrency/sync.rs index b36ad27ebe1..69943e5495e 100644 --- a/tests/run-pass/concurrency/sync.rs +++ b/tests/run-pass/concurrency/sync.rs @@ -312,6 +312,34 @@ fn check_rwlock_unlock_bug2() { h.join().unwrap(); } +fn park_timeout() { + let start = Instant::now(); + + thread::park_timeout(Duration::from_millis(200)); + // Normally, waiting in park/park_timeout may spuriously wake up early, but we + // know Miri's timed synchronization primitives do not do that. + + assert!((200..500).contains(&start.elapsed().as_millis())); +} + +fn park_unpark() { + let t1 = thread::current(); + let t2 = thread::spawn(move || { + thread::park(); + thread::sleep(Duration::from_millis(200)); + t1.unpark(); + }); + + let start = Instant::now(); + + t2.thread().unpark(); + thread::park(); + // Normally, waiting in park/park_timeout may spuriously wake up early, but we + // know Miri's timed synchronization primitives do not do that. + + assert!((200..500).contains(&start.elapsed().as_millis())); +} + fn main() { check_barriers(); check_conditional_variables_notify_one(); @@ -327,4 +355,6 @@ fn main() { check_once(); check_rwlock_unlock_bug1(); check_rwlock_unlock_bug2(); + park_timeout(); + park_unpark(); } -- 2.44.0