Azim Khan | 1de892b | 2017-06-09 15:02:36 +0100 | [diff] [blame] | 1 | #line 2 "suites/main_test.function" |
Azim Khan | 191e904 | 2017-06-09 12:39:00 +0100 | [diff] [blame] | 2 | /* |
| 3 | * *** THIS FILE HAS BEEN MACHINE GENERATED *** |
| 4 | * |
| 5 | * This file has been machine generated using the script: |
Mohammad Azim Khan | 5cb7017 | 2018-07-19 11:32:30 +0100 | [diff] [blame] | 6 | * $generator_script |
Azim Khan | 191e904 | 2017-06-09 12:39:00 +0100 | [diff] [blame] | 7 | * |
Mohammad Azim Khan | 5cb7017 | 2018-07-19 11:32:30 +0100 | [diff] [blame] | 8 | * Test file : $test_file |
Azim Khan | 191e904 | 2017-06-09 12:39:00 +0100 | [diff] [blame] | 9 | * |
| 10 | * The following files were used to create this file. |
| 11 | * |
Mohammad Azim Khan | 5cb7017 | 2018-07-19 11:32:30 +0100 | [diff] [blame] | 12 | * Main code file : $test_main_file |
| 13 | * Platform code file : $test_platform_file |
| 14 | * Helper file : $test_common_helper_file |
| 15 | * Test suite file : $test_case_file |
| 16 | * Test suite data : $test_case_data_file |
Azim Khan | 191e904 | 2017-06-09 12:39:00 +0100 | [diff] [blame] | 17 | * |
Azim Khan | 191e904 | 2017-06-09 12:39:00 +0100 | [diff] [blame] | 18 | */ |
Paul Bakker | de56ca1 | 2013-09-15 17:05:21 +0200 | [diff] [blame] | 19 | |
Gilles Peskine | 31f88a2 | 2020-04-14 19:39:56 +0200 | [diff] [blame] | 20 | #if defined(__unix__) || (defined(__APPLE__) && defined(__MACH__)) |
| 21 | #if !defined(_POSIX_C_SOURCE) |
nia | 1c0c837 | 2020-06-11 12:03:45 +0100 | [diff] [blame] | 22 | #define _POSIX_C_SOURCE 200112L // for fileno() from <stdio.h> |
Gilles Peskine | 31f88a2 | 2020-04-14 19:39:56 +0200 | [diff] [blame] | 23 | #endif |
| 24 | #endif |
| 25 | |
Azim Khan | 191e904 | 2017-06-09 12:39:00 +0100 | [diff] [blame] | 26 | #if !defined(MBEDTLS_CONFIG_FILE) |
| 27 | #include <mbedtls/config.h> |
| 28 | #else |
| 29 | #include MBEDTLS_CONFIG_FILE |
| 30 | #endif |
Paul Bakker | 1934318 | 2013-08-16 13:31:10 +0200 | [diff] [blame] | 31 | |
Hanno Becker | 1cfc5dd | 2018-11-12 13:18:45 +0000 | [diff] [blame] | 32 | #if defined(MBEDTLS_USE_PSA_CRYPTO) |
| 33 | #include "psa/crypto.h" |
| 34 | #endif /* MBEDTLS_USE_PSA_CRYPTO */ |
SimonB | 152ea18 | 2016-02-15 23:27:28 +0000 | [diff] [blame] | 35 | |
Gilles Peskine | 2ff02c3 | 2019-11-29 12:17:21 +0100 | [diff] [blame] | 36 | /* Test code may use deprecated identifiers only if the preprocessor symbol |
| 37 | * MBEDTLS_TEST_DEPRECATED is defined. When building tests, set |
| 38 | * MBEDTLS_TEST_DEPRECATED explicitly if MBEDTLS_DEPRECATED_WARNING is |
| 39 | * enabled but the corresponding warnings are not treated as errors. |
| 40 | */ |
Gilles Peskine | 841b14b | 2019-11-26 17:37:37 +0100 | [diff] [blame] | 41 | #if !defined(MBEDTLS_DEPRECATED_REMOVED) && !defined(MBEDTLS_DEPRECATED_WARNING) |
| 42 | #define MBEDTLS_TEST_DEPRECATED |
| 43 | #endif |
| 44 | |
SimonB | 152ea18 | 2016-02-15 23:27:28 +0000 | [diff] [blame] | 45 | /*----------------------------------------------------------------------------*/ |
Azim Khan | 191e904 | 2017-06-09 12:39:00 +0100 | [diff] [blame] | 46 | /* Common helper code */ |
SimonB | 152ea18 | 2016-02-15 23:27:28 +0000 | [diff] [blame] | 47 | |
Mohammad Azim Khan | 5cb7017 | 2018-07-19 11:32:30 +0100 | [diff] [blame] | 48 | $test_common_helpers |
Paul Bakker | de56ca1 | 2013-09-15 17:05:21 +0200 | [diff] [blame] | 49 | |
Mohammad Azim Khan | 5cb7017 | 2018-07-19 11:32:30 +0100 | [diff] [blame] | 50 | #line $line_no "suites/main_test.function" |
Azim Khan | 191e904 | 2017-06-09 12:39:00 +0100 | [diff] [blame] | 51 | |
| 52 | |
| 53 | /*----------------------------------------------------------------------------*/ |
| 54 | /* Test Suite Code */ |
| 55 | |
| 56 | |
| 57 | #define TEST_SUITE_ACTIVE |
| 58 | |
Mohammad Azim Khan | 5cb7017 | 2018-07-19 11:32:30 +0100 | [diff] [blame] | 59 | $functions_code |
Azim Khan | 191e904 | 2017-06-09 12:39:00 +0100 | [diff] [blame] | 60 | |
Mohammad Azim Khan | 5cb7017 | 2018-07-19 11:32:30 +0100 | [diff] [blame] | 61 | #line $line_no "suites/main_test.function" |
SimonB | 1594210 | 2016-04-25 21:34:49 +0100 | [diff] [blame] | 62 | |
SimonB | 152ea18 | 2016-02-15 23:27:28 +0000 | [diff] [blame] | 63 | |
| 64 | /*----------------------------------------------------------------------------*/ |
| 65 | /* Test dispatch code */ |
| 66 | |
Paul Bakker | 1934318 | 2013-08-16 13:31:10 +0200 | [diff] [blame] | 67 | |
Azim Khan | 191e904 | 2017-06-09 12:39:00 +0100 | [diff] [blame] | 68 | /** |
| 69 | * \brief Evaluates an expression/macro into its literal integer value. |
| 70 | * For optimizing space for embedded targets each expression/macro |
| 71 | * is identified by a unique identifier instead of string literals. |
| 72 | * Identifiers and evaluation code is generated by script: |
Mohammad Azim Khan | 5cb7017 | 2018-07-19 11:32:30 +0100 | [diff] [blame] | 73 | * $generator_script |
Azim Khan | 191e904 | 2017-06-09 12:39:00 +0100 | [diff] [blame] | 74 | * |
| 75 | * \param exp_id Expression identifier. |
| 76 | * \param out_value Pointer to int to hold the integer. |
| 77 | * |
| 78 | * \return 0 if exp_id is found. 1 otherwise. |
| 79 | */ |
| 80 | int get_expression( int32_t exp_id, int32_t * out_value ) |
Mohammad Azim Khan | 5cb7017 | 2018-07-19 11:32:30 +0100 | [diff] [blame] | 81 | { |
Azim Khan | b1c2d0f | 2017-07-07 17:14:02 +0100 | [diff] [blame] | 82 | int ret = KEY_VALUE_MAPPING_FOUND; |
| 83 | |
| 84 | (void) exp_id; |
| 85 | (void) out_value; |
| 86 | |
| 87 | switch( exp_id ) |
Mohammad Azim Khan | 5cb7017 | 2018-07-19 11:32:30 +0100 | [diff] [blame] | 88 | { |
| 89 | $expression_code |
| 90 | #line $line_no "suites/main_test.function" |
Azim Khan | b1c2d0f | 2017-07-07 17:14:02 +0100 | [diff] [blame] | 91 | default: |
Mohammad Azim Khan | 5cb7017 | 2018-07-19 11:32:30 +0100 | [diff] [blame] | 92 | { |
Azim Khan | b1c2d0f | 2017-07-07 17:14:02 +0100 | [diff] [blame] | 93 | ret = KEY_VALUE_MAPPING_NOT_FOUND; |
Mohammad Azim Khan | 5cb7017 | 2018-07-19 11:32:30 +0100 | [diff] [blame] | 94 | } |
Azim Khan | b1c2d0f | 2017-07-07 17:14:02 +0100 | [diff] [blame] | 95 | break; |
Mohammad Azim Khan | 5cb7017 | 2018-07-19 11:32:30 +0100 | [diff] [blame] | 96 | } |
Azim Khan | b1c2d0f | 2017-07-07 17:14:02 +0100 | [diff] [blame] | 97 | return( ret ); |
Mohammad Azim Khan | 5cb7017 | 2018-07-19 11:32:30 +0100 | [diff] [blame] | 98 | } |
Paul Bakker | 1934318 | 2013-08-16 13:31:10 +0200 | [diff] [blame] | 99 | |
Paul Bakker | 1934318 | 2013-08-16 13:31:10 +0200 | [diff] [blame] | 100 | |
Azim Khan | 191e904 | 2017-06-09 12:39:00 +0100 | [diff] [blame] | 101 | /** |
| 102 | * \brief Checks if the dependency i.e. the compile flag is set. |
| 103 | * For optimizing space for embedded targets each dependency |
| 104 | * is identified by a unique identifier instead of string literals. |
| 105 | * Identifiers and check code is generated by script: |
Mohammad Azim Khan | 5cb7017 | 2018-07-19 11:32:30 +0100 | [diff] [blame] | 106 | * $generator_script |
Azim Khan | 191e904 | 2017-06-09 12:39:00 +0100 | [diff] [blame] | 107 | * |
Gilles Peskine | 5a7702e | 2021-02-23 13:40:19 +0100 | [diff] [blame^] | 108 | * \param dep_id Dependency identifier. |
Azim Khan | 191e904 | 2017-06-09 12:39:00 +0100 | [diff] [blame] | 109 | * |
| 110 | * \return DEPENDENCY_SUPPORTED if set else DEPENDENCY_NOT_SUPPORTED |
| 111 | */ |
| 112 | int dep_check( int dep_id ) |
Mohammad Azim Khan | 5cb7017 | 2018-07-19 11:32:30 +0100 | [diff] [blame] | 113 | { |
Azim Khan | b1c2d0f | 2017-07-07 17:14:02 +0100 | [diff] [blame] | 114 | int ret = DEPENDENCY_NOT_SUPPORTED; |
| 115 | |
| 116 | (void) dep_id; |
| 117 | |
| 118 | switch( dep_id ) |
Mohammad Azim Khan | 5cb7017 | 2018-07-19 11:32:30 +0100 | [diff] [blame] | 119 | { |
| 120 | $dep_check_code |
| 121 | #line $line_no "suites/main_test.function" |
Azim Khan | b1c2d0f | 2017-07-07 17:14:02 +0100 | [diff] [blame] | 122 | default: |
| 123 | break; |
Mohammad Azim Khan | 5cb7017 | 2018-07-19 11:32:30 +0100 | [diff] [blame] | 124 | } |
Azim Khan | b1c2d0f | 2017-07-07 17:14:02 +0100 | [diff] [blame] | 125 | return( ret ); |
Mohammad Azim Khan | 5cb7017 | 2018-07-19 11:32:30 +0100 | [diff] [blame] | 126 | } |
Paul Bakker | 1934318 | 2013-08-16 13:31:10 +0200 | [diff] [blame] | 127 | |
SimonB | 8ca7bc4 | 2016-04-17 23:24:50 +0100 | [diff] [blame] | 128 | |
Azim Khan | 191e904 | 2017-06-09 12:39:00 +0100 | [diff] [blame] | 129 | /** |
| 130 | * \brief Function pointer type for test function wrappers. |
| 131 | * |
Gilles Peskine | 5a7702e | 2021-02-23 13:40:19 +0100 | [diff] [blame^] | 132 | * A test function wrapper decodes the parameters and passes them to the |
| 133 | * underlying test function. Both the wrapper and the underlying function |
| 134 | * return void. Test wrappers assume that they are passed a suitable |
| 135 | * parameter array and do not perform any error detection. |
Azim Khan | 191e904 | 2017-06-09 12:39:00 +0100 | [diff] [blame] | 136 | * |
Gilles Peskine | 5a7702e | 2021-02-23 13:40:19 +0100 | [diff] [blame^] | 137 | * \param param_array The array of parameters. Each element is a `void *` |
| 138 | * which the wrapper casts to the correct type and |
| 139 | * dereferences. Each wrapper function hard-codes the |
| 140 | * number and types of the parameters. |
Azim Khan | 191e904 | 2017-06-09 12:39:00 +0100 | [diff] [blame] | 141 | */ |
Gilles Peskine | 5a7702e | 2021-02-23 13:40:19 +0100 | [diff] [blame^] | 142 | typedef void (*TestWrapper_t)( void **param_array ); |
Simon Butcher | 65b1fa6 | 2016-05-23 23:18:26 +0100 | [diff] [blame] | 143 | |
Azim Khan | 191e904 | 2017-06-09 12:39:00 +0100 | [diff] [blame] | 144 | |
| 145 | /** |
| 146 | * \brief Table of test function wrappers. Used by dispatch_test(). |
| 147 | * This table is populated by script: |
Mohammad Azim Khan | 5cb7017 | 2018-07-19 11:32:30 +0100 | [diff] [blame] | 148 | * $generator_script |
Azim Khan | 191e904 | 2017-06-09 12:39:00 +0100 | [diff] [blame] | 149 | * |
| 150 | */ |
| 151 | TestWrapper_t test_funcs[] = |
Mohammad Azim Khan | 5cb7017 | 2018-07-19 11:32:30 +0100 | [diff] [blame] | 152 | { |
| 153 | $dispatch_code |
| 154 | #line $line_no "suites/main_test.function" |
| 155 | }; |
Azim Khan | 191e904 | 2017-06-09 12:39:00 +0100 | [diff] [blame] | 156 | |
Andrzej Kurek | c470b6b | 2019-01-31 08:20:20 -0500 | [diff] [blame] | 157 | /** |
| 158 | * \brief Execute the test function. |
| 159 | * |
| 160 | * This is a wrapper function around the test function execution |
| 161 | * to allow the setjmp() call used to catch any calls to the |
| 162 | * parameter failure callback, to be used. Calls to setjmp() |
| 163 | * can invalidate the state of any local auto variables. |
| 164 | * |
Gilles Peskine | 5a7702e | 2021-02-23 13:40:19 +0100 | [diff] [blame^] | 165 | * \param fp Function pointer to the test function. |
| 166 | * \param params Parameters to pass to the #TestWrapper_t wrapper function. |
Andrzej Kurek | c470b6b | 2019-01-31 08:20:20 -0500 | [diff] [blame] | 167 | * |
| 168 | */ |
| 169 | void execute_function_ptr(TestWrapper_t fp, void **params) |
| 170 | { |
Gilles Peskine | 76175ba | 2020-11-24 18:39:12 +0100 | [diff] [blame] | 171 | #if defined(MBEDTLS_PSA_CRYPTO_EXTERNAL_RNG) |
| 172 | mbedtls_test_enable_insecure_external_rng( ); |
| 173 | #endif |
| 174 | |
Andrzej Kurek | c470b6b | 2019-01-31 08:20:20 -0500 | [diff] [blame] | 175 | #if defined(MBEDTLS_CHECK_PARAMS) |
Ronald Cron | 4e66587 | 2020-06-30 17:44:27 +0200 | [diff] [blame] | 176 | mbedtls_test_param_failed_location_record_t location_record; |
| 177 | |
Ronald Cron | 579fd28 | 2020-07-01 15:17:05 +0200 | [diff] [blame] | 178 | if ( setjmp( mbedtls_test_param_failed_get_state_buf( ) ) == 0 ) |
Andrzej Kurek | c470b6b | 2019-01-31 08:20:20 -0500 | [diff] [blame] | 179 | { |
| 180 | fp( params ); |
| 181 | } |
| 182 | else |
| 183 | { |
| 184 | /* Unexpected parameter validation error */ |
Ronald Cron | 4e66587 | 2020-06-30 17:44:27 +0200 | [diff] [blame] | 185 | mbedtls_test_param_failed_get_location_record( &location_record ); |
Chris Jones | 9634bb1 | 2021-01-20 15:56:42 +0000 | [diff] [blame] | 186 | mbedtls_test_fail( location_record.failure_condition, |
| 187 | location_record.line, |
| 188 | location_record.file ); |
Andrzej Kurek | c470b6b | 2019-01-31 08:20:20 -0500 | [diff] [blame] | 189 | } |
| 190 | |
Ronald Cron | 579fd28 | 2020-07-01 15:17:05 +0200 | [diff] [blame] | 191 | mbedtls_test_param_failed_reset_state( ); |
Andrzej Kurek | c470b6b | 2019-01-31 08:20:20 -0500 | [diff] [blame] | 192 | #else |
| 193 | fp( params ); |
| 194 | #endif |
Gilles Peskine | 2a4c598 | 2021-01-29 21:18:09 +0100 | [diff] [blame] | 195 | |
| 196 | #if defined(MBEDTLS_TEST_MUTEX_USAGE) |
| 197 | mbedtls_test_mutex_usage_check( ); |
| 198 | #endif /* MBEDTLS_TEST_MUTEX_USAGE */ |
Andrzej Kurek | c470b6b | 2019-01-31 08:20:20 -0500 | [diff] [blame] | 199 | } |
Azim Khan | 191e904 | 2017-06-09 12:39:00 +0100 | [diff] [blame] | 200 | |
| 201 | /** |
Andrzej Kurek | c470b6b | 2019-01-31 08:20:20 -0500 | [diff] [blame] | 202 | * \brief Dispatches test functions based on function index. |
Azim Khan | 191e904 | 2017-06-09 12:39:00 +0100 | [diff] [blame] | 203 | * |
Gilles Peskine | 5a7702e | 2021-02-23 13:40:19 +0100 | [diff] [blame^] | 204 | * \param func_idx Test function index. |
| 205 | * \param params The array of parameters to pass to the test function. |
| 206 | * It will be decoded by the #TestWrapper_t wrapper function. |
Azim Khan | 191e904 | 2017-06-09 12:39:00 +0100 | [diff] [blame] | 207 | * |
| 208 | * \return DISPATCH_TEST_SUCCESS if found |
| 209 | * DISPATCH_TEST_FN_NOT_FOUND if not found |
| 210 | * DISPATCH_UNSUPPORTED_SUITE if not compile time enabled. |
| 211 | */ |
k-stachowiak | 03954f2 | 2019-09-16 10:23:10 +0200 | [diff] [blame] | 212 | int dispatch_test( size_t func_idx, void ** params ) |
Mohammad Azim Khan | 5cb7017 | 2018-07-19 11:32:30 +0100 | [diff] [blame] | 213 | { |
Azim Khan | 191e904 | 2017-06-09 12:39:00 +0100 | [diff] [blame] | 214 | int ret = DISPATCH_TEST_SUCCESS; |
| 215 | TestWrapper_t fp = NULL; |
| 216 | |
Mohammad Azim Khan | d2d0112 | 2018-07-18 17:48:37 +0100 | [diff] [blame] | 217 | if ( func_idx < (int)( sizeof( test_funcs ) / sizeof( TestWrapper_t ) ) ) |
Mohammad Azim Khan | 5cb7017 | 2018-07-19 11:32:30 +0100 | [diff] [blame] | 218 | { |
Azim Khan | 191e904 | 2017-06-09 12:39:00 +0100 | [diff] [blame] | 219 | fp = test_funcs[func_idx]; |
| 220 | if ( fp ) |
Andrzej Kurek | c470b6b | 2019-01-31 08:20:20 -0500 | [diff] [blame] | 221 | execute_function_ptr(fp, params); |
Azim Khan | 191e904 | 2017-06-09 12:39:00 +0100 | [diff] [blame] | 222 | else |
Mohammad Azim Khan | 5cb7017 | 2018-07-19 11:32:30 +0100 | [diff] [blame] | 223 | ret = DISPATCH_UNSUPPORTED_SUITE; |
| 224 | } |
Azim Khan | 191e904 | 2017-06-09 12:39:00 +0100 | [diff] [blame] | 225 | else |
Mohammad Azim Khan | 5cb7017 | 2018-07-19 11:32:30 +0100 | [diff] [blame] | 226 | { |
| 227 | ret = DISPATCH_TEST_FN_NOT_FOUND; |
| 228 | } |
Azim Khan | 191e904 | 2017-06-09 12:39:00 +0100 | [diff] [blame] | 229 | |
Paul Bakker | 1934318 | 2013-08-16 13:31:10 +0200 | [diff] [blame] | 230 | return( ret ); |
Mohammad Azim Khan | 5cb7017 | 2018-07-19 11:32:30 +0100 | [diff] [blame] | 231 | } |
Paul Bakker | 1934318 | 2013-08-16 13:31:10 +0200 | [diff] [blame] | 232 | |
SimonB | 152ea18 | 2016-02-15 23:27:28 +0000 | [diff] [blame] | 233 | |
Azim Khan | 13c6bfb | 2017-06-15 14:45:56 +0100 | [diff] [blame] | 234 | /** |
Gilles Peskine | 5a7702e | 2021-02-23 13:40:19 +0100 | [diff] [blame^] | 235 | * \brief Checks if test function is supported in this build-time |
| 236 | * configuration. |
Azim Khan | 13c6bfb | 2017-06-15 14:45:56 +0100 | [diff] [blame] | 237 | * |
Gilles Peskine | 5a7702e | 2021-02-23 13:40:19 +0100 | [diff] [blame^] | 238 | * \param func_idx Test function index. |
Azim Khan | 13c6bfb | 2017-06-15 14:45:56 +0100 | [diff] [blame] | 239 | * |
| 240 | * \return DISPATCH_TEST_SUCCESS if found |
| 241 | * DISPATCH_TEST_FN_NOT_FOUND if not found |
| 242 | * DISPATCH_UNSUPPORTED_SUITE if not compile time enabled. |
| 243 | */ |
k-stachowiak | 03954f2 | 2019-09-16 10:23:10 +0200 | [diff] [blame] | 244 | int check_test( size_t func_idx ) |
Mohammad Azim Khan | 5cb7017 | 2018-07-19 11:32:30 +0100 | [diff] [blame] | 245 | { |
Azim Khan | 13c6bfb | 2017-06-15 14:45:56 +0100 | [diff] [blame] | 246 | int ret = DISPATCH_TEST_SUCCESS; |
| 247 | TestWrapper_t fp = NULL; |
| 248 | |
| 249 | if ( func_idx < (int)( sizeof(test_funcs)/sizeof( TestWrapper_t ) ) ) |
Mohammad Azim Khan | 5cb7017 | 2018-07-19 11:32:30 +0100 | [diff] [blame] | 250 | { |
Azim Khan | 13c6bfb | 2017-06-15 14:45:56 +0100 | [diff] [blame] | 251 | fp = test_funcs[func_idx]; |
| 252 | if ( fp == NULL ) |
Mohammad Azim Khan | 5cb7017 | 2018-07-19 11:32:30 +0100 | [diff] [blame] | 253 | ret = DISPATCH_UNSUPPORTED_SUITE; |
| 254 | } |
Azim Khan | 13c6bfb | 2017-06-15 14:45:56 +0100 | [diff] [blame] | 255 | else |
Mohammad Azim Khan | 5cb7017 | 2018-07-19 11:32:30 +0100 | [diff] [blame] | 256 | { |
| 257 | ret = DISPATCH_TEST_FN_NOT_FOUND; |
| 258 | } |
Azim Khan | 13c6bfb | 2017-06-15 14:45:56 +0100 | [diff] [blame] | 259 | |
| 260 | return( ret ); |
Mohammad Azim Khan | 5cb7017 | 2018-07-19 11:32:30 +0100 | [diff] [blame] | 261 | } |
Azim Khan | 13c6bfb | 2017-06-15 14:45:56 +0100 | [diff] [blame] | 262 | |
| 263 | |
Mohammad Azim Khan | 5cb7017 | 2018-07-19 11:32:30 +0100 | [diff] [blame] | 264 | $platform_code |
Azim Khan | 191e904 | 2017-06-09 12:39:00 +0100 | [diff] [blame] | 265 | |
Mohammad Azim Khan | 5cb7017 | 2018-07-19 11:32:30 +0100 | [diff] [blame] | 266 | #line $line_no "suites/main_test.function" |
Azim Khan | 191e904 | 2017-06-09 12:39:00 +0100 | [diff] [blame] | 267 | |
SimonB | 152ea18 | 2016-02-15 23:27:28 +0000 | [diff] [blame] | 268 | /*----------------------------------------------------------------------------*/ |
| 269 | /* Main Test code */ |
| 270 | |
SimonB | 1594210 | 2016-04-25 21:34:49 +0100 | [diff] [blame] | 271 | |
Azim Khan | 191e904 | 2017-06-09 12:39:00 +0100 | [diff] [blame] | 272 | /** |
| 273 | * \brief Program main. Invokes platform specific execute_tests(). |
Gilles Peskine | 964faeb | 2017-09-29 18:00:25 +0200 | [diff] [blame] | 274 | * |
Azim Khan | 191e904 | 2017-06-09 12:39:00 +0100 | [diff] [blame] | 275 | * \param argc Command line arguments count. |
| 276 | * \param argv Array of command line arguments. |
| 277 | * |
| 278 | * \return Exit code. |
Gilles Peskine | 964faeb | 2017-09-29 18:00:25 +0200 | [diff] [blame] | 279 | */ |
Azim Khan | 191e904 | 2017-06-09 12:39:00 +0100 | [diff] [blame] | 280 | int main( int argc, const char *argv[] ) |
Mohammad Azim Khan | 5cb7017 | 2018-07-19 11:32:30 +0100 | [diff] [blame] | 281 | { |
Ronald Cron | e9c09f1 | 2020-06-08 16:44:58 +0200 | [diff] [blame] | 282 | int ret = mbedtls_test_platform_setup(); |
Andrzej Kurek | f13ca95 | 2018-04-18 04:14:31 -0400 | [diff] [blame] | 283 | if( ret != 0 ) |
Mohammad Azim Khan | 5cb7017 | 2018-07-19 11:32:30 +0100 | [diff] [blame] | 284 | { |
Andrzej Kurek | f13ca95 | 2018-04-18 04:14:31 -0400 | [diff] [blame] | 285 | mbedtls_fprintf( stderr, |
| 286 | "FATAL: Failed to initialize platform - error %d\n", |
| 287 | ret ); |
| 288 | return( -1 ); |
Mohammad Azim Khan | 5cb7017 | 2018-07-19 11:32:30 +0100 | [diff] [blame] | 289 | } |
Hanno Becker | 1cfc5dd | 2018-11-12 13:18:45 +0000 | [diff] [blame] | 290 | |
Azim Khan | 191e904 | 2017-06-09 12:39:00 +0100 | [diff] [blame] | 291 | ret = execute_tests( argc, argv ); |
Ronald Cron | e9c09f1 | 2020-06-08 16:44:58 +0200 | [diff] [blame] | 292 | mbedtls_test_platform_teardown(); |
Azim Khan | 191e904 | 2017-06-09 12:39:00 +0100 | [diff] [blame] | 293 | return( ret ); |
Mohammad Azim Khan | 5cb7017 | 2018-07-19 11:32:30 +0100 | [diff] [blame] | 294 | } |