clock_gettime: don't assume more than 1 second since the origin of time

With e.g. `CLOCK_BOOTTIME`, it's plausible that less than 1 second has
passed since the boot reference time.

Only assert that the returned time is nonzero (because all-bits-zero is
highly implausible as an actual clock value, but likely indicates that the
intended value was not copied out correctly).

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
This commit is contained in:
Gilles Peskine
2026-03-02 19:22:24 +01:00
parent b17d0f3028
commit 2393fddd60

View File

@@ -52,7 +52,7 @@ void clock_gettime_available(int clockid)
memset(&ts, 0, sizeof(ts));
int ret = clock_gettime(clockid, &ts);
TEST_ASSERT_ERRNO(ret == 0);
TEST_LE_S(1, ts.tv_sec);
TEST_ASSERT(ts.tv_sec != 0 || ts.tv_nsec != 0);
}
/* END_CASE */