1 #![expect(unsafe_op_in_unsafe_fn, reason = "old code, not worth updating yet")] 2 test_clock_time_get()3unsafe fn test_clock_time_get() { 4 // Test that clock_time_get succeeds. Even in environments where it's not 5 // desirable to expose high-precision timers, it should still succeed. 6 // clock_res_get is where information about precision can be provided. 7 wasip1::clock_time_get(wasip1::CLOCKID_MONOTONIC, 1).expect("precision 1 should work"); 8 9 let first_time = 10 wasip1::clock_time_get(wasip1::CLOCKID_MONOTONIC, 0).expect("precision 0 should work"); 11 12 let time = 13 wasip1::clock_time_get(wasip1::CLOCKID_MONOTONIC, 0).expect("re-fetch time should work"); 14 assert!(first_time <= time, "CLOCK_MONOTONIC should be monotonic"); 15 } 16 main()17fn main() { 18 // Run the tests. 19 unsafe { test_clock_time_get() } 20 } 21