From c9c3e62b3ed28dd18775fb3d733a086a98196031 Mon Sep 17 00:00:00 2001 From: Jerry Yu Date: Tue, 11 Apr 2023 14:08:23 +0800 Subject: [PATCH] workaround the assert fail with tollerance Signed-off-by: Jerry Yu --- tests/suites/test_suite_platform.function | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/tests/suites/test_suite_platform.function b/tests/suites/test_suite_platform.function index 1d661b26a..f4e12bff3 100644 --- a/tests/suites/test_suite_platform.function +++ b/tests/suites/test_suite_platform.function @@ -84,7 +84,12 @@ void time_delay_seconds(int delay_secs) sleep_ms(delay_secs * 1000); elapsed_secs = mbedtls_time(NULL) - current; - TEST_ASSERT(elapsed_secs >= delay_secs); + + /* Built-in mbedtls_time function returns the number of seconds since the + * Epoch. That is affected by discontinuous jumps and cause test fail. + * Workaround it with 1 seconds tollerance. + */ + TEST_ASSERT(elapsed_secs >= delay_secs - 1); TEST_ASSERT(elapsed_secs < 4 + delay_secs); /* This goto is added to avoid warnings from the generated code. */ goto exit;