Jerry Yu | 9a12df0 | 2023-03-03 12:55:16 +0800 | [diff] [blame] | 1 | /* BEGIN_HEADER */ |
| 2 | |
| 3 | /* This test module exercises the platform_* module. Since, depending on the |
| 4 | * underlying operating system, the time routines are not always reliable, |
| 5 | * this suite only performs very basic sanity checks of the timing API. |
| 6 | */ |
| 7 | |
| 8 | #include <limits.h> |
| 9 | |
| 10 | #if defined(MBEDTLS_HAVE_TIME) |
| 11 | #include "mbedtls/platform_time.h" |
Jerry Yu | c5b48a6 | 2023-03-13 14:28:06 +0800 | [diff] [blame] | 12 | |
Jerry Yu | 9a12df0 | 2023-03-03 12:55:16 +0800 | [diff] [blame] | 13 | /* END_HEADER */ |
| 14 | |
Jerry Yu | c5b48a6 | 2023-03-13 14:28:06 +0800 | [diff] [blame] | 15 | /* BEGIN_DEPENDENCIES */ |
| 16 | |
| 17 | /* END_DEPENDENCIES */ |
| 18 | |
| 19 | |
Jerry Yu | 9a12df0 | 2023-03-03 12:55:16 +0800 | [diff] [blame] | 20 | |
| 21 | /* BEGIN_CASE depends_on:MBEDTLS_HAVE_TIME */ |
| 22 | void time_get_milliseconds() |
| 23 | { |
Jerry Yu | e7ea823 | 2023-03-14 17:33:42 +0800 | [diff] [blame] | 24 | mbedtls_ms_time_t current = mbedtls_ms_time(); |
Jerry Yu | 9a12df0 | 2023-03-03 12:55:16 +0800 | [diff] [blame] | 25 | (void) current; |
| 26 | /* This goto is added to avoid warnings from the generated code. */ |
| 27 | goto exit; |
| 28 | } |
| 29 | /* END_CASE */ |
| 30 | |
| 31 | /* BEGIN_CASE depends_on:MBEDTLS_HAVE_TIME */ |
| 32 | void time_get_seconds() |
| 33 | { |
Jerry Yu | e7ea823 | 2023-03-14 17:33:42 +0800 | [diff] [blame] | 34 | mbedtls_time_t current = mbedtls_time(NULL); |
Jerry Yu | 9a12df0 | 2023-03-03 12:55:16 +0800 | [diff] [blame] | 35 | (void) current; |
| 36 | /* This goto is added to avoid warnings from the generated code. */ |
| 37 | goto exit; |
| 38 | } |
| 39 | /* END_CASE */ |