| 1 | #[cfg (any( |
| 2 | target_os = "freebsd" , |
| 3 | target_os = "dragonfly" , |
| 4 | target_os = "linux" , |
| 5 | target_os = "android" , |
| 6 | target_os = "emscripten" , |
| 7 | ))] |
| 8 | use nix::time::clock_getcpuclockid; |
| 9 | use nix::time::{clock_gettime, ClockId}; |
| 10 | |
| 11 | #[cfg (not(target_os = "redox" ))] |
| 12 | #[test] |
| 13 | pub fn test_clock_getres() { |
| 14 | nix::time::clock_getres(ClockId::CLOCK_REALTIME).expect("assertion failed" ); |
| 15 | } |
| 16 | |
| 17 | #[test] |
| 18 | pub fn test_clock_gettime() { |
| 19 | clock_gettime(ClockId::CLOCK_REALTIME).expect("assertion failed" ); |
| 20 | } |
| 21 | |
| 22 | #[cfg (any( |
| 23 | target_os = "freebsd" , |
| 24 | target_os = "dragonfly" , |
| 25 | target_os = "linux" , |
| 26 | target_os = "android" , |
| 27 | target_os = "emscripten" , |
| 28 | ))] |
| 29 | #[test] |
| 30 | pub fn test_clock_getcpuclockid() { |
| 31 | let clock_id = clock_getcpuclockid(nix::unistd::Pid::this()).unwrap(); |
| 32 | clock_gettime(clock_id).unwrap(); |
| 33 | } |
| 34 | |
| 35 | #[cfg (not(target_os = "redox" ))] |
| 36 | #[test] |
| 37 | pub fn test_clock_id_res() { |
| 38 | ClockId::CLOCK_REALTIME.res().unwrap(); |
| 39 | } |
| 40 | |
| 41 | #[test] |
| 42 | pub fn test_clock_id_now() { |
| 43 | ClockId::CLOCK_REALTIME.now().unwrap(); |
| 44 | } |
| 45 | |
| 46 | #[cfg (any( |
| 47 | target_os = "freebsd" , |
| 48 | target_os = "dragonfly" , |
| 49 | target_os = "linux" , |
| 50 | target_os = "android" , |
| 51 | target_os = "emscripten" , |
| 52 | ))] |
| 53 | #[test] |
| 54 | pub fn test_clock_id_pid_cpu_clock_id() { |
| 55 | ClockId::pid_cpu_clock_id(nix::unistd::Pid::this()) |
| 56 | .map(ClockId::now) |
| 57 | .unwrap() |
| 58 | .unwrap(); |
| 59 | } |
| 60 | |