From 9a12df022e5c6c808b786afbd3d3d8d2019880f1 Mon Sep 17 00:00:00 2001 From: Jerry Yu Date: Fri, 3 Mar 2023 12:55:16 +0800 Subject: [PATCH] Add tests for time rountine Signed-off-by: Jerry Yu --- tests/suites/test_suite_platform.data | 6 ++++ tests/suites/test_suite_platform.function | 38 +++++++++++++++++++++++ 2 files changed, 44 insertions(+) create mode 100644 tests/suites/test_suite_platform.data create mode 100644 tests/suites/test_suite_platform.function diff --git a/tests/suites/test_suite_platform.data b/tests/suites/test_suite_platform.data new file mode 100644 index 0000000000..4276b8fb77 --- /dev/null +++ b/tests/suites/test_suite_platform.data @@ -0,0 +1,6 @@ + +Time: get milliseconds +time_get_milliseconds: + +Time: get seconds +time_get_seconds: diff --git a/tests/suites/test_suite_platform.function b/tests/suites/test_suite_platform.function new file mode 100644 index 0000000000..dad464ba2d --- /dev/null +++ b/tests/suites/test_suite_platform.function @@ -0,0 +1,38 @@ +/* BEGIN_HEADER */ + +/* This test module exercises the platform_* module. Since, depending on the + * underlying operating system, the time routines are not always reliable, + * this suite only performs very basic sanity checks of the timing API. + */ + +#include + +#if defined(MBEDTLS_HAVE_TIME) +#include "mbedtls/platform_time.h" +#endif + +/* END_HEADER */ + +/* BEGIN_DEPENDENCIES + * END_DEPENDENCIES + */ + +/* BEGIN_CASE depends_on:MBEDTLS_HAVE_TIME */ +void time_get_milliseconds() +{ + mbedtls_ms_time_t current = mbedtls_ms_time(); + (void) current; + /* This goto is added to avoid warnings from the generated code. */ + goto exit; +} +/* END_CASE */ + +/* BEGIN_CASE depends_on:MBEDTLS_HAVE_TIME */ +void time_get_seconds() +{ + mbedtls_time_t current = mbedtls_time(NULL); + (void) current; + /* This goto is added to avoid warnings from the generated code. */ + goto exit; +} +/* END_CASE */