1use std::time::Duration;
2
3use futures::future::pending;
4use rasio::timer::{sleep_with, TimeoutExt, TimerDriver};
5
6use crate::async_spec;
7
8pub async fn test_sleep(syscall: &dyn TimerDriver) {
9 sleep_with(Duration::from_micros(10), syscall).await;
10
11 sleep_with(Duration::from_millis(20), syscall).await;
12
13 sleep_with(Duration::from_secs(1), syscall).await;
14}
15
16pub async fn test_timeout(syscall: &dyn TimerDriver) {
17 let never = pending::<()>();
18 let dur = Duration::from_millis(5);
19
20 assert!(never.timeout_with(dur, syscall).await.is_none());
21}
22
23pub async fn run_timer_spec(syscall: &'static dyn TimerDriver) {
24 println!("Run timer spec testsuite");
25 println!("");
26
27 async_spec!(test_sleep, syscall);
28 async_spec!(test_timeout, syscall);
29
30 println!("");
31}