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