Skip to content

Commit c5a13dd

Browse files
committed
add sleep_until test
1 parent e5b28af commit c5a13dd

File tree

1 file changed

+10
-0
lines changed
  • src/tools/miri/tests/pass/shims

1 file changed

+10
-0
lines changed

src/tools/miri/tests/pass/shims/time.rs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
//@compile-flags: -Zmiri-disable-isolation
2+
#![feature(thread_sleep_until)]
23

34
use std::time::{Duration, Instant, SystemTime};
45

@@ -15,6 +16,14 @@ fn test_sleep() {
1516
assert!((after - before).as_millis() >= 100);
1617
}
1718

19+
fn test_sleep_until() {
20+
let before = Instant::now();
21+
let one_second_from_now = before + Duration::from_millis(100);
22+
std::thread::sleep_until(one_second_from_now);
23+
let after = Instant::now();
24+
assert!((after - before).as_millis() >= 100);
25+
}
26+
1827
fn main() {
1928
// Check `SystemTime`.
2029
let now1 = SystemTime::now();
@@ -49,4 +58,5 @@ fn main() {
4958
duration_sanity(diff);
5059

5160
test_sleep();
61+
test_sleep_until();
5262
}

0 commit comments

Comments
 (0)