Fix for x86_64 build fail
[platform/upstream/connectedhomeip.git] / third_party / mbedtls / repo / tests / suites / test_suite_timing.function
1 /* BEGIN_HEADER */
2
3 /* This test module exercises the timing module. Since, depending on the
4  * underlying operating system, the timing 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 #include "mbedtls/timing.h"
11
12 /* END_HEADER */
13
14 /* BEGIN_DEPENDENCIES
15  * depends_on:MBEDTLS_TIMING_C
16  * END_DEPENDENCIES
17  */
18
19 /* BEGIN_CASE */
20 void timing_hardclock( )
21 {
22     (void) mbedtls_timing_hardclock();
23     /* This goto is added to avoid warnings from the generated code. */
24     goto exit;
25 }
26 /* END_CASE */
27
28 /* BEGIN_CASE */
29 void timing_get_timer( )
30 {
31     struct mbedtls_timing_hr_time time;
32     (void) mbedtls_timing_get_timer( &time, 1 );
33     (void) mbedtls_timing_get_timer( &time, 0 );
34     /* This goto is added to avoid warnings from the generated code. */
35     goto exit;
36 }
37 /* END_CASE */
38
39 /* BEGIN_CASE */
40 void timing_set_alarm( int seconds )
41 {
42     if( seconds == 0 )
43     {
44         mbedtls_set_alarm( seconds );
45         TEST_ASSERT( mbedtls_timing_alarmed == 1 );
46     }
47     else
48     {
49         mbedtls_set_alarm( seconds );
50         TEST_ASSERT( mbedtls_timing_alarmed == 0 ||
51                      mbedtls_timing_alarmed == 1 );
52     }
53 }
54 /* END_CASE */
55
56 /* BEGIN_CASE */
57 void timing_delay( int fin_ms )
58 {
59     mbedtls_timing_delay_context ctx;
60     int result;
61     if( fin_ms == 0 )
62     {
63         mbedtls_timing_set_delay( &ctx, 0, 0 );
64         result = mbedtls_timing_get_delay( &ctx );
65         TEST_ASSERT( result == -1 );
66     }
67     else
68     {
69         mbedtls_timing_set_delay( &ctx, fin_ms / 2, fin_ms );
70         result = mbedtls_timing_get_delay( &ctx );
71         TEST_ASSERT( result >= 0 && result <= 2 );
72     }
73 }
74 /* END_CASE */