From 4852bb823f247a8f0d5f180c5a9669b99677fc49 Mon Sep 17 00:00:00 2001 From: Jerry Yu Date: Tue, 18 Apr 2023 13:50:24 +0800 Subject: [PATCH] remove time delay tests See #1517. They often failed on the CI. Signed-off-by: Jerry Yu --- tests/suites/test_suite_platform.data | 6 --- tests/suites/test_suite_platform.function | 61 ----------------------- 2 files changed, 67 deletions(-) diff --git a/tests/suites/test_suite_platform.data b/tests/suites/test_suite_platform.data index 557b586eb6..4276b8fb77 100644 --- a/tests/suites/test_suite_platform.data +++ b/tests/suites/test_suite_platform.data @@ -4,9 +4,3 @@ time_get_milliseconds: Time: get seconds time_get_seconds: - -Time: delay milliseconds -time_delay_milliseconds:1000 - -Time: delay seconds -time_delay_seconds:1 diff --git a/tests/suites/test_suite_platform.function b/tests/suites/test_suite_platform.function index 2584d3dfc8..aadcc39c28 100644 --- a/tests/suites/test_suite_platform.function +++ b/tests/suites/test_suite_platform.function @@ -10,28 +10,6 @@ #if defined(MBEDTLS_HAVE_TIME) #include "mbedtls/platform_time.h" -#ifdef WIN32 -#include -#elif _POSIX_C_SOURCE >= 199309L -#include -#else -#include -#endif -void sleep_ms(int milliseconds) -{ -#ifdef WIN32 - Sleep(milliseconds); -#elif _POSIX_C_SOURCE >= 199309L - struct timespec ts; - ts.tv_sec = milliseconds / 1000; - ts.tv_nsec = (milliseconds % 1000) * 1000000; - nanosleep(&ts, NULL); -#else - usleep(milliseconds * 1000); -#endif -} -#endif - /* END_HEADER */ /* BEGIN_DEPENDENCIES */ @@ -59,42 +37,3 @@ void time_get_seconds() goto exit; } /* END_CASE */ - -/* BEGIN_CASE depends_on:MBEDTLS_HAVE_TIME */ -void time_delay_milliseconds(int delay_ms) -{ - mbedtls_ms_time_t current = mbedtls_ms_time(); - mbedtls_ms_time_t elapsed_ms; - - sleep_ms(delay_ms); - - elapsed_ms = mbedtls_ms_time() - current; - TEST_ASSERT(elapsed_ms >= delay_ms && elapsed_ms < 4000 + delay_ms); - /* This goto is added to avoid warnings from the generated code. */ - goto exit; -} -/* END_CASE */ - -/* BEGIN_CASE depends_on:MBEDTLS_HAVE_TIME */ -void time_delay_seconds(int delay_secs) -{ - mbedtls_time_t current = mbedtls_time(NULL); - mbedtls_time_t elapsed_secs; - - sleep_ms(delay_secs * 1000); - - elapsed_secs = mbedtls_time(NULL) - current; - - /* Built-in mbedtls_time function returns the number of seconds since the - * Epoch. That is affected by discontinuous jumps. And `nanosleep` use - * CLOCK_MONOTONIC(monotonically-increasing time source), That will cause - * negative elapsed time difference. - * - * Workaround it with 1 second tolerance. - */ - 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; -} -/* END_CASE */