Skip to content

Commit ec96009

Browse files
committed
drivers: tests: rtc: relax y2k test seconds check
When testing y2k rollover, the seconds value can easily be off by one since there is no guarantee that the RTC will be exactly on the second boundary. Relax the check to allow for a one second difference. Signed-off-by: Benjamin Cabé <[email protected]>
1 parent 850a3b3 commit ec96009

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

tests/drivers/rtc/rtc_api/src/test_y2k.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,5 +67,9 @@ ZTEST(rtc_api, test_y2k)
6767
rtm[Y2K].tm_wday);
6868
zassert_equal(rtm[Y2K].tm_hour, 0, "wrong hour: %d", rtm[Y2K].tm_hour);
6969
zassert_equal(rtm[Y2K].tm_min, 0, "wrong minute: %d", rtm[Y2K].tm_min);
70-
zassert_equal(rtm[Y2K].tm_sec, SECONDS_AFTER, "wrong second: %d", rtm[Y2K].tm_sec);
70+
/* We're testing Y2K rollover, not precise timing. Seconds should be small but exact value
71+
* doesn't matter
72+
*/
73+
zassert_true(rtm[Y2K].tm_sec <= SECONDS_AFTER + 1, "seconds out of valid range: %d",
74+
rtm[Y2K].tm_sec);
7175
}

0 commit comments

Comments
 (0)