• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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]
test_clock_getres()13 pub fn test_clock_getres() {
14     assert!(nix::time::clock_getres(ClockId::CLOCK_REALTIME).is_ok());
15 }
16 
17 #[test]
test_clock_gettime()18 pub fn test_clock_gettime() {
19     assert!(clock_gettime(ClockId::CLOCK_REALTIME).is_ok());
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]
test_clock_getcpuclockid()30 pub fn test_clock_getcpuclockid() {
31     let clock_id = clock_getcpuclockid(nix::unistd::Pid::this()).unwrap();
32     assert!(clock_gettime(clock_id).is_ok());
33 }
34 
35 #[cfg(not(target_os = "redox"))]
36 #[test]
test_clock_id_res()37 pub fn test_clock_id_res() {
38     assert!(ClockId::CLOCK_REALTIME.res().is_ok());
39 }
40 
41 #[test]
test_clock_id_now()42 pub fn test_clock_id_now() {
43     assert!(ClockId::CLOCK_REALTIME.now().is_ok());
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]
test_clock_id_pid_cpu_clock_id()54 pub fn test_clock_id_pid_cpu_clock_id() {
55     assert!(ClockId::pid_cpu_clock_id(nix::unistd::Pid::this())
56         .map(ClockId::now)
57         .is_ok());
58 }
59