summaryrefslogtreecommitdiffstats
path: root/vendor/rustix/tests/time
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--vendor/rustix/tests/time/dynamic_clocks.rs22
-rw-r--r--vendor/rustix/tests/time/main.rs14
-rw-r--r--vendor/rustix/tests/time/monotonic.rs45
-rw-r--r--vendor/rustix/tests/time/timerfd.rs75
-rw-r--r--vendor/rustix/tests/time/timespec.rs26
-rw-r--r--vendor/rustix/tests/time/y2038.rs77
6 files changed, 0 insertions, 259 deletions
diff --git a/vendor/rustix/tests/time/dynamic_clocks.rs b/vendor/rustix/tests/time/dynamic_clocks.rs
deleted file mode 100644
index a7e1e6792..000000000
--- a/vendor/rustix/tests/time/dynamic_clocks.rs
+++ /dev/null
@@ -1,22 +0,0 @@
-#![cfg(not(any(target_os = "redox", target_os = "wasi")))]
-
-use rustix::fd::AsFd;
-use rustix::time::{clock_gettime_dynamic, ClockId, DynamicClockId};
-
-#[test]
-fn test_known_clocks() {
- clock_gettime_dynamic(DynamicClockId::Known(ClockId::Realtime)).unwrap();
- clock_gettime_dynamic(DynamicClockId::Known(ClockId::Monotonic)).unwrap();
-}
-
-#[test]
-fn test_dynamic_clocks() {
- let file = std::fs::File::open("Cargo.toml").unwrap();
- clock_gettime_dynamic(DynamicClockId::Dynamic(file.as_fd())).unwrap_err();
-}
-
-#[cfg(any(target_os = "android", target_os = "linux"))]
-#[test]
-fn test_conditional_clocks() {
- let _ = clock_gettime_dynamic(DynamicClockId::Tai);
-}
diff --git a/vendor/rustix/tests/time/main.rs b/vendor/rustix/tests/time/main.rs
deleted file mode 100644
index 43283bca2..000000000
--- a/vendor/rustix/tests/time/main.rs
+++ /dev/null
@@ -1,14 +0,0 @@
-//! Tests for [`rustix::time`].
-
-#![cfg(feature = "time")]
-#![cfg(not(windows))]
-#![cfg_attr(target_os = "wasi", feature(wasi_ext))]
-#![cfg_attr(io_lifetimes_use_std, feature(io_safety))]
-
-mod dynamic_clocks;
-#[cfg(not(any(target_os = "redox", target_os = "wasi")))]
-mod monotonic;
-#[cfg(any(target_os = "android", target_os = "linux"))]
-mod timerfd;
-mod timespec;
-mod y2038;
diff --git a/vendor/rustix/tests/time/monotonic.rs b/vendor/rustix/tests/time/monotonic.rs
deleted file mode 100644
index 89470f2b4..000000000
--- a/vendor/rustix/tests/time/monotonic.rs
+++ /dev/null
@@ -1,45 +0,0 @@
-#[cfg(feature = "thread")]
-use rustix::thread::nanosleep;
-use rustix::time::{clock_gettime, ClockId, Timespec};
-
-/// Attempt to test that the monotonic clock is monotonic. Time may or may not
-/// advance, but it shouldn't regress.
-#[test]
-fn test_monotonic_clock() {
- let a = clock_gettime(ClockId::Monotonic);
- let b = clock_gettime(ClockId::Monotonic);
- if b.tv_sec == a.tv_sec {
- assert!(b.tv_nsec >= a.tv_nsec);
- } else {
- assert!(b.tv_sec > a.tv_sec);
- }
-}
-
-/// With the "thread" feature, we can sleep so that we're guaranteed that time
-/// has advanced.
-#[cfg(feature = "thread")]
-#[test]
-fn test_monotonic_clock_with_sleep_1s() {
- let a = clock_gettime(ClockId::Monotonic);
- let _rem = nanosleep(&Timespec {
- tv_sec: 1,
- tv_nsec: 0,
- });
- let b = clock_gettime(ClockId::Monotonic);
- assert!(b.tv_sec > a.tv_sec);
-}
-
-/// With the "thread" feature, we can sleep so that we're guaranteed that time
-/// has advanced.
-#[cfg(feature = "thread")]
-#[test]
-fn test_monotonic_clock_with_sleep_1ms() {
- let a = clock_gettime(ClockId::Monotonic);
- let _rem = nanosleep(&Timespec {
- tv_sec: 0,
- tv_nsec: 1_000_000,
- });
- let b = clock_gettime(ClockId::Monotonic);
- assert!(b.tv_sec >= a.tv_sec);
- assert!(b.tv_sec != a.tv_sec || b.tv_nsec > a.tv_nsec);
-}
diff --git a/vendor/rustix/tests/time/timerfd.rs b/vendor/rustix/tests/time/timerfd.rs
deleted file mode 100644
index 6ad4dd72e..000000000
--- a/vendor/rustix/tests/time/timerfd.rs
+++ /dev/null
@@ -1,75 +0,0 @@
-use rustix::time::{
- timerfd_create, timerfd_gettime, timerfd_settime, Itimerspec, TimerfdClockId, TimerfdFlags,
- TimerfdTimerFlags, Timespec,
-};
-
-#[test]
-fn test_timerfd() {
- let fd = timerfd_create(TimerfdClockId::Monotonic, TimerfdFlags::CLOEXEC).unwrap();
-
- let set = Itimerspec {
- it_interval: Timespec {
- tv_sec: 0,
- tv_nsec: 0,
- },
- it_value: Timespec {
- tv_sec: 1,
- tv_nsec: 2,
- },
- };
- let _old: Itimerspec = timerfd_settime(&fd, TimerfdTimerFlags::ABSTIME, &set).unwrap();
-
- // Wait for the timer to expire.
- let mut buf = [0_u8; 8];
- assert_eq!(rustix::io::read(&fd, &mut buf), Ok(8));
- assert!(u64::from_ne_bytes(buf) >= 1);
-
- let new = timerfd_gettime(&fd).unwrap();
-
- // The timer counts down.
- assert_eq!(set.it_interval.tv_sec, new.it_interval.tv_sec);
- assert_eq!(set.it_interval.tv_nsec, new.it_interval.tv_nsec);
- assert!(new.it_value.tv_sec <= set.it_value.tv_sec);
- assert!(
- new.it_value.tv_nsec < set.it_value.tv_nsec || new.it_value.tv_sec < set.it_value.tv_sec
- );
-}
-
-/// Similar, but set an interval for a repeated timer. Don't check that the
-/// times are monotonic because that would race with the timer repeating.
-#[test]
-fn test_timerfd_with_interval() {
- let fd = timerfd_create(TimerfdClockId::Monotonic, TimerfdFlags::CLOEXEC).unwrap();
-
- let set = Itimerspec {
- it_interval: Timespec {
- tv_sec: 0,
- tv_nsec: 6,
- },
- it_value: Timespec {
- tv_sec: 1,
- tv_nsec: 7,
- },
- };
- let _old: Itimerspec = timerfd_settime(&fd, TimerfdTimerFlags::ABSTIME, &set).unwrap();
-
- // Wait for the timer to expire.
- let mut buf = [0_u8; 8];
- assert_eq!(rustix::io::read(&fd, &mut buf), Ok(8));
- assert!(u64::from_ne_bytes(buf) >= 1);
-
- let new = timerfd_gettime(&fd).unwrap();
-
- assert_eq!(set.it_interval.tv_sec, new.it_interval.tv_sec);
- assert_eq!(set.it_interval.tv_nsec, new.it_interval.tv_nsec);
-
- // Wait for the timer to expire again.
- let mut buf = [0_u8; 8];
- assert_eq!(rustix::io::read(&fd, &mut buf), Ok(8));
- assert!(u64::from_ne_bytes(buf) >= 1);
-
- let new = timerfd_gettime(&fd).unwrap();
-
- assert_eq!(set.it_interval.tv_sec, new.it_interval.tv_sec);
- assert_eq!(set.it_interval.tv_nsec, new.it_interval.tv_nsec);
-}
diff --git a/vendor/rustix/tests/time/timespec.rs b/vendor/rustix/tests/time/timespec.rs
deleted file mode 100644
index 6d892dcfe..000000000
--- a/vendor/rustix/tests/time/timespec.rs
+++ /dev/null
@@ -1,26 +0,0 @@
-#[test]
-fn test_timespec_layout() {
- #[cfg(not(target_os = "redox"))]
- use rustix::fs::{UTIME_NOW, UTIME_OMIT};
- use rustix::time::{Nsecs, Secs, Timespec};
-
- let tv_sec: Secs = 0;
- let tv_nsec: Nsecs = 0;
- let _ = Timespec { tv_sec, tv_nsec };
-
- #[cfg(not(target_os = "redox"))]
- let _ = Timespec {
- tv_sec,
- tv_nsec: UTIME_NOW,
- };
- #[cfg(not(target_os = "redox"))]
- let _ = Timespec {
- tv_sec,
- tv_nsec: UTIME_OMIT,
- };
- let _ = Timespec { tv_sec, tv_nsec: 0 };
- let _ = Timespec {
- tv_sec,
- tv_nsec: 999_999_999,
- };
-}
diff --git a/vendor/rustix/tests/time/y2038.rs b/vendor/rustix/tests/time/y2038.rs
deleted file mode 100644
index 45a073d19..000000000
--- a/vendor/rustix/tests/time/y2038.rs
+++ /dev/null
@@ -1,77 +0,0 @@
-/// Test that `Timespec` and `Secs` support a 64-bit number of seconds,
-/// avoiding the y2038 bug.
-///
-/// The Rust Musl target and libc crate are currently using Musl 1.1. It is
-/// expected to update to Musl 1.2 at some point, at which point it'll gain a
-/// 64-bit `time_t`.
-///
-/// 32-bit Android is [not y2038 compatible]. In theory we could use
-/// `libc::syscall` and call the new syscalls ourselves, however that doesn't
-/// seem worth the effort on a platform that will likely never support add
-/// such support itself.
-///
-/// [not y2038 compatible]: https://android.googlesource.com/platform/bionic/+/refs/heads/master/docs/32-bit-abi.md#is-32_bit-on-lp32-y2038
-#[cfg(not(all(target_env = "musl", target_pointer_width = "32")))]
-#[cfg(not(all(target_os = "android", target_pointer_width = "32")))]
-#[cfg(not(all(target_os = "emscripten", target_pointer_width = "32")))]
-#[test]
-fn test_y2038() {
- use rustix::time::{Secs, Timespec};
-
- let tv_sec: i64 = 0;
- let _ = Timespec { tv_sec, tv_nsec: 0 };
- let _: Secs = tv_sec;
-
- #[cfg(any(target_os = "android", target_os = "fuchsia", target_os = "linux"))]
- {
- use rustix::time::Itimerspec;
-
- let _ = Itimerspec {
- it_interval: Timespec { tv_sec, tv_nsec: 0 },
- it_value: Timespec { tv_sec, tv_nsec: 0 },
- };
- }
-}
-
-#[cfg(any(target_os = "android", target_os = "fuchsia", target_os = "linux"))]
-#[test]
-fn test_y2038_with_timerfd() {
- use rustix::time::{
- timerfd_create, timerfd_gettime, timerfd_settime, Itimerspec, TimerfdClockId, TimerfdFlags,
- TimerfdTimerFlags, Timespec,
- };
-
- let fd = timerfd_create(TimerfdClockId::Monotonic, TimerfdFlags::CLOEXEC).unwrap();
-
- let set = Itimerspec {
- it_interval: Timespec {
- tv_sec: (1_u64 << 32) as _,
- tv_nsec: 20,
- },
- it_value: Timespec {
- tv_sec: (1_u64 << 32) as _,
- tv_nsec: 21,
- },
- };
- let _old: Itimerspec = match timerfd_settime(&fd, TimerfdTimerFlags::ABSTIME, &set) {
- Ok(i) => i,
-
- // On 32-bit and mips64 platforms, accept `EOVERFLOW`, meaning that
- // y2038 support in `timerfd` APIs is not available on this platform
- // or this version of the platform.
- #[cfg(any(target_pointer_width = "32", target_arch = "mips64"))]
- Err(rustix::io::Errno::OVERFLOW) => return,
-
- Err(e) => panic!("unexpected error: {:?}", e),
- };
-
- let new = timerfd_gettime(&fd).unwrap();
-
- // The timer counts down.
- assert_eq!(set.it_interval.tv_sec, new.it_interval.tv_sec);
- assert_eq!(set.it_interval.tv_nsec, new.it_interval.tv_nsec);
- assert!(new.it_value.tv_sec <= set.it_value.tv_sec);
- assert!(
- new.it_value.tv_nsec < set.it_value.tv_nsec || new.it_value.tv_sec < set.it_value.tv_sec
- );
-}