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