Skip to content

Commit 2ccc11f

Browse files
committed
tests-mbed_drivers-rtc: Add one second tolerance in functional tests.
Currently test assumes that 1 sec is long enough to set RTC time and read same time which has been set. In some cases extra time for synchronisation between clock domains is needed and after setting/reading operations the read value might be different than one which has been set (+1 sec). Additionally in some cases when lp ticker is based on RTC, the RTC implementation may use mechanism to trace elapsed seconds without modifying RTC registers. In such case it is possible that second will change immediately after setting time. Add 1 sec tolerance (min possible) for such checks.
1 parent 8bddb6b commit 2ccc11f

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

TESTS/mbed_drivers/rtc/main.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,7 @@ void test_attach_RTC_stub_funtions()
144144
TEST_ASSERT_EQUAL(false, rtc_init_called);
145145

146146
/* Check if time has been successfully set and retrieved. */
147-
TEST_ASSERT_EQUAL(CUSTOM_TIME_1, seconds);
147+
TEST_ASSERT_UINT32_WITHIN(RTC_DELTA, CUSTOM_TIME_1, seconds);
148148
}
149149

150150
/* This test verifies if attach_rtc provides availability to
@@ -183,7 +183,7 @@ void test_attach_RTC_org_funtions()
183183
TEST_ASSERT_EQUAL(false, rtc_init_called);
184184

185185
/* Check if time has been successfully set and retrieved. */
186-
TEST_ASSERT_EQUAL(CUSTOM_TIME_1, seconds);
186+
TEST_ASSERT_UINT32_WITHIN(RTC_DELTA, CUSTOM_TIME_1, seconds);
187187
}
188188

189189
/* This test verifies if time() function returns
@@ -430,7 +430,7 @@ void test_functional_set()
430430
set_time(timeValue);
431431

432432
/* Get current time and verify that new value has been set. */
433-
TEST_ASSERT_EQUAL(timeValue, time(NULL));
433+
TEST_ASSERT_UINT32_WITHIN(1, timeValue, time(NULL));
434434
}
435435

436436
/* This test verifies if RTC counts seconds.

0 commit comments

Comments
 (0)