CI / test (push) Failing after 52s
It read the wall clock. When NTP moved a phone from 1970 to now, the frame loop's elapsed time overflowed and it slept for days. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
17 lines
670 B
MoonBit
17 lines
670 B
MoonBit
///|
|
|
/// The main loop sleeps for a difference of two `monotonic_ms`: on the wall clock, NTP setting the
|
|
/// time (1970 to now on a phone) froze the session for days. CLOCK_MONOTONIC can't be later than
|
|
/// /proc/uptime, which also counts suspended time; the wall clock is far past it.
|
|
test "monotonic_ms is not the wall clock" {
|
|
let before = @sys.monotonic_ms()
|
|
let text = @sys.read_proc_bytes("/proc/uptime")
|
|
let mut secs = 0UL
|
|
for c in text {
|
|
guard c is (b'0'..=b'9') else { break }
|
|
secs = secs * 10UL + (c - b'0').to_uint64()
|
|
}
|
|
assert_true(secs > 0UL)
|
|
assert_true(before <= (secs + 1UL) * 1000UL)
|
|
assert_true(@sys.monotonic_ms() >= before)
|
|
}
|