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