summaryrefslogtreecommitdiffstats
path: root/third_party/rust/nix/test/test_time.rs
diff options
context:
space:
mode:
Diffstat (limited to 'third_party/rust/nix/test/test_time.rs')
-rw-r--r--third_party/rust/nix/test/test_time.rs49
1 files changed, 28 insertions, 21 deletions
diff --git a/third_party/rust/nix/test/test_time.rs b/third_party/rust/nix/test/test_time.rs
index 5f76e61a2d..64c8161dbf 100644
--- a/third_party/rust/nix/test/test_time.rs
+++ b/third_party/rust/nix/test/test_time.rs
@@ -1,10 +1,4 @@
-#[cfg(any(
- target_os = "freebsd",
- target_os = "dragonfly",
- target_os = "linux",
- target_os = "android",
- target_os = "emscripten",
-))]
+#[cfg(any(freebsdlike, linux_android, target_os = "emscripten"))]
use nix::time::clock_getcpuclockid;
use nix::time::{clock_gettime, ClockId};
@@ -19,13 +13,7 @@ pub fn test_clock_gettime() {
clock_gettime(ClockId::CLOCK_REALTIME).expect("assertion failed");
}
-#[cfg(any(
- target_os = "freebsd",
- target_os = "dragonfly",
- target_os = "linux",
- target_os = "android",
- target_os = "emscripten",
-))]
+#[cfg(any(freebsdlike, linux_android, target_os = "emscripten"))]
#[test]
pub fn test_clock_getcpuclockid() {
let clock_id = clock_getcpuclockid(nix::unistd::Pid::this()).unwrap();
@@ -43,13 +31,7 @@ pub fn test_clock_id_now() {
ClockId::CLOCK_REALTIME.now().unwrap();
}
-#[cfg(any(
- target_os = "freebsd",
- target_os = "dragonfly",
- target_os = "linux",
- target_os = "android",
- target_os = "emscripten",
-))]
+#[cfg(any(freebsdlike, linux_android, target_os = "emscripten"))]
#[test]
pub fn test_clock_id_pid_cpu_clock_id() {
ClockId::pid_cpu_clock_id(nix::unistd::Pid::this())
@@ -57,3 +39,28 @@ pub fn test_clock_id_pid_cpu_clock_id() {
.unwrap()
.unwrap();
}
+
+#[cfg(any(
+ linux_android,
+ solarish,
+ freebsdlike,
+ target_os = "netbsd",
+ target_os = "hurd",
+ target_os = "aix"
+))]
+#[test]
+pub fn test_clock_nanosleep() {
+ use nix::{
+ sys::time::{TimeSpec, TimeValLike},
+ time::{clock_nanosleep, ClockNanosleepFlags},
+ };
+
+ let sleep_time = TimeSpec::microseconds(1);
+ let res = clock_nanosleep(
+ ClockId::CLOCK_MONOTONIC,
+ ClockNanosleepFlags::empty(),
+ &sleep_time,
+ );
+ let expected = TimeSpec::microseconds(0);
+ assert_eq!(res, Ok(expected));
+}