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: |
| 6 | * {generator_script} |
| 7 | * |
| 8 | * Test file : {test_file} |
| 9 | * |
| 10 | * The following files were used to create this file. |
| 11 | * |
| 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} |
| 17 | * |
| 18 | * |
| 19 | * This file is part of mbed TLS (https://tls.mbed.org) |
| 20 | */ |
Paul Bakker | de56ca1 | 2013-09-15 17:05:21 +0200 | [diff] [blame] | 21 | |
Azim Khan | 191e904 | 2017-06-09 12:39:00 +0100 | [diff] [blame] | 22 | #if !defined(MBEDTLS_CONFIG_FILE) |
| 23 | #include <mbedtls/config.h> |
| 24 | #else |
| 25 | #include MBEDTLS_CONFIG_FILE |
| 26 | #endif |
Paul Bakker | 1934318 | 2013-08-16 13:31:10 +0200 | [diff] [blame] | 27 | |
SimonB | 152ea18 | 2016-02-15 23:27:28 +0000 | [diff] [blame] | 28 | |
| 29 | /*----------------------------------------------------------------------------*/ |
Azim Khan | 191e904 | 2017-06-09 12:39:00 +0100 | [diff] [blame] | 30 | /* Common helper code */ |
SimonB | 152ea18 | 2016-02-15 23:27:28 +0000 | [diff] [blame] | 31 | |
Azim Khan | 191e904 | 2017-06-09 12:39:00 +0100 | [diff] [blame] | 32 | {test_common_helpers} |
Paul Bakker | de56ca1 | 2013-09-15 17:05:21 +0200 | [diff] [blame] | 33 | |
Azim Khan | 1de892b | 2017-06-09 15:02:36 +0100 | [diff] [blame] | 34 | #line {line_no} "suites/main_test.function" |
Azim Khan | 191e904 | 2017-06-09 12:39:00 +0100 | [diff] [blame] | 35 | |
| 36 | |
| 37 | /*----------------------------------------------------------------------------*/ |
| 38 | /* Test Suite Code */ |
| 39 | |
| 40 | |
| 41 | #define TEST_SUITE_ACTIVE |
| 42 | |
Azim Khan | 191e904 | 2017-06-09 12:39:00 +0100 | [diff] [blame] | 43 | {functions_code} |
| 44 | |
Azim Khan | 1de892b | 2017-06-09 15:02:36 +0100 | [diff] [blame] | 45 | #line {line_no} "suites/main_test.function" |
SimonB | 1594210 | 2016-04-25 21:34:49 +0100 | [diff] [blame] | 46 | |
SimonB | 152ea18 | 2016-02-15 23:27:28 +0000 | [diff] [blame] | 47 | |
| 48 | /*----------------------------------------------------------------------------*/ |
| 49 | /* Test dispatch code */ |
| 50 | |
Paul Bakker | 1934318 | 2013-08-16 13:31:10 +0200 | [diff] [blame] | 51 | |
Azim Khan | 191e904 | 2017-06-09 12:39:00 +0100 | [diff] [blame] | 52 | /** |
| 53 | * \brief Evaluates an expression/macro into its literal integer value. |
| 54 | * For optimizing space for embedded targets each expression/macro |
| 55 | * is identified by a unique identifier instead of string literals. |
| 56 | * Identifiers and evaluation code is generated by script: |
| 57 | * {generator_script} |
| 58 | * |
| 59 | * \param exp_id Expression identifier. |
| 60 | * \param out_value Pointer to int to hold the integer. |
| 61 | * |
| 62 | * \return 0 if exp_id is found. 1 otherwise. |
| 63 | */ |
| 64 | int get_expression( int32_t exp_id, int32_t * out_value ) |
| 65 | {{ |
Azim Khan | b1c2d0f | 2017-07-07 17:14:02 +0100 | [diff] [blame] | 66 | int ret = KEY_VALUE_MAPPING_FOUND; |
| 67 | |
| 68 | (void) exp_id; |
| 69 | (void) out_value; |
| 70 | |
| 71 | switch( exp_id ) |
| 72 | {{ |
Azim Khan | 191e904 | 2017-06-09 12:39:00 +0100 | [diff] [blame] | 73 | {expression_code} |
Azim Khan | 1de892b | 2017-06-09 15:02:36 +0100 | [diff] [blame] | 74 | #line {line_no} "suites/main_test.function" |
Azim Khan | b1c2d0f | 2017-07-07 17:14:02 +0100 | [diff] [blame] | 75 | default: |
| 76 | {{ |
| 77 | ret = KEY_VALUE_MAPPING_NOT_FOUND; |
| 78 | }} |
| 79 | break; |
Azim Khan | 191e904 | 2017-06-09 12:39:00 +0100 | [diff] [blame] | 80 | }} |
Azim Khan | b1c2d0f | 2017-07-07 17:14:02 +0100 | [diff] [blame] | 81 | return( ret ); |
Azim Khan | 191e904 | 2017-06-09 12:39:00 +0100 | [diff] [blame] | 82 | }} |
Paul Bakker | 1934318 | 2013-08-16 13:31:10 +0200 | [diff] [blame] | 83 | |
Paul Bakker | 1934318 | 2013-08-16 13:31:10 +0200 | [diff] [blame] | 84 | |
Azim Khan | 191e904 | 2017-06-09 12:39:00 +0100 | [diff] [blame] | 85 | /** |
| 86 | * \brief Checks if the dependency i.e. the compile flag is set. |
| 87 | * For optimizing space for embedded targets each dependency |
| 88 | * is identified by a unique identifier instead of string literals. |
| 89 | * Identifiers and check code is generated by script: |
| 90 | * {generator_script} |
| 91 | * |
| 92 | * \param exp_id Dependency identifier. |
| 93 | * |
| 94 | * \return DEPENDENCY_SUPPORTED if set else DEPENDENCY_NOT_SUPPORTED |
| 95 | */ |
| 96 | int dep_check( int dep_id ) |
| 97 | {{ |
Azim Khan | b1c2d0f | 2017-07-07 17:14:02 +0100 | [diff] [blame] | 98 | int ret = DEPENDENCY_NOT_SUPPORTED; |
| 99 | |
| 100 | (void) dep_id; |
| 101 | |
| 102 | switch( dep_id ) |
| 103 | {{ |
Azim Khan | 191e904 | 2017-06-09 12:39:00 +0100 | [diff] [blame] | 104 | {dep_check_code} |
Azim Khan | 1de892b | 2017-06-09 15:02:36 +0100 | [diff] [blame] | 105 | #line {line_no} "suites/main_test.function" |
Azim Khan | b1c2d0f | 2017-07-07 17:14:02 +0100 | [diff] [blame] | 106 | default: |
| 107 | break; |
Azim Khan | 191e904 | 2017-06-09 12:39:00 +0100 | [diff] [blame] | 108 | }} |
Azim Khan | b1c2d0f | 2017-07-07 17:14:02 +0100 | [diff] [blame] | 109 | return( ret ); |
Azim Khan | 191e904 | 2017-06-09 12:39:00 +0100 | [diff] [blame] | 110 | }} |
Paul Bakker | 1934318 | 2013-08-16 13:31:10 +0200 | [diff] [blame] | 111 | |
SimonB | 8ca7bc4 | 2016-04-17 23:24:50 +0100 | [diff] [blame] | 112 | |
Azim Khan | 191e904 | 2017-06-09 12:39:00 +0100 | [diff] [blame] | 113 | /** |
| 114 | * \brief Function pointer type for test function wrappers. |
| 115 | * |
| 116 | * |
| 117 | * \param void ** Pointer to void pointers. Represents an array of test |
| 118 | * function parameters. |
| 119 | * |
| 120 | * \return void |
| 121 | */ |
| 122 | typedef void (*TestWrapper_t)( void ** ); |
Simon Butcher | 65b1fa6 | 2016-05-23 23:18:26 +0100 | [diff] [blame] | 123 | |
Azim Khan | 191e904 | 2017-06-09 12:39:00 +0100 | [diff] [blame] | 124 | |
| 125 | /** |
| 126 | * \brief Table of test function wrappers. Used by dispatch_test(). |
| 127 | * This table is populated by script: |
| 128 | * {generator_script} |
| 129 | * |
| 130 | */ |
| 131 | TestWrapper_t test_funcs[] = |
| 132 | {{ |
Mohammad Azim Khan | b73159d | 2018-06-13 16:31:26 +0100 | [diff] [blame^] | 133 | {dispatch_code} |
Azim Khan | 1de892b | 2017-06-09 15:02:36 +0100 | [diff] [blame] | 134 | #line {line_no} "suites/main_test.function" |
Azim Khan | 191e904 | 2017-06-09 12:39:00 +0100 | [diff] [blame] | 135 | }}; |
| 136 | |
| 137 | |
| 138 | /** |
| 139 | * \brief Dispatches test functions based on function index. |
| 140 | * |
| 141 | * \param exp_id Test function index. |
| 142 | * |
| 143 | * \return DISPATCH_TEST_SUCCESS if found |
| 144 | * DISPATCH_TEST_FN_NOT_FOUND if not found |
| 145 | * DISPATCH_UNSUPPORTED_SUITE if not compile time enabled. |
| 146 | */ |
| 147 | int dispatch_test( int func_idx, void ** params ) |
| 148 | {{ |
| 149 | int ret = DISPATCH_TEST_SUCCESS; |
| 150 | TestWrapper_t fp = NULL; |
| 151 | |
| 152 | if ( func_idx < (int)( sizeof(test_funcs)/sizeof( TestWrapper_t ) ) ) |
| 153 | {{ |
| 154 | fp = test_funcs[func_idx]; |
| 155 | if ( fp ) |
| 156 | fp( params ); |
| 157 | else |
| 158 | ret = ( DISPATCH_UNSUPPORTED_SUITE ); |
| 159 | }} |
| 160 | else |
| 161 | {{ |
| 162 | ret = ( DISPATCH_TEST_FN_NOT_FOUND ); |
| 163 | }} |
| 164 | |
Paul Bakker | 1934318 | 2013-08-16 13:31:10 +0200 | [diff] [blame] | 165 | return( ret ); |
Azim Khan | 191e904 | 2017-06-09 12:39:00 +0100 | [diff] [blame] | 166 | }} |
Paul Bakker | 1934318 | 2013-08-16 13:31:10 +0200 | [diff] [blame] | 167 | |
SimonB | 152ea18 | 2016-02-15 23:27:28 +0000 | [diff] [blame] | 168 | |
Azim Khan | 13c6bfb | 2017-06-15 14:45:56 +0100 | [diff] [blame] | 169 | /** |
| 170 | * \brief Checks if test function is supported |
| 171 | * |
| 172 | * \param exp_id Test function index. |
| 173 | * |
| 174 | * \return DISPATCH_TEST_SUCCESS if found |
| 175 | * DISPATCH_TEST_FN_NOT_FOUND if not found |
| 176 | * DISPATCH_UNSUPPORTED_SUITE if not compile time enabled. |
| 177 | */ |
| 178 | int check_test( int func_idx ) |
| 179 | {{ |
| 180 | int ret = DISPATCH_TEST_SUCCESS; |
| 181 | TestWrapper_t fp = NULL; |
| 182 | |
| 183 | if ( func_idx < (int)( sizeof(test_funcs)/sizeof( TestWrapper_t ) ) ) |
| 184 | {{ |
| 185 | fp = test_funcs[func_idx]; |
| 186 | if ( fp == NULL ) |
| 187 | ret = ( DISPATCH_UNSUPPORTED_SUITE ); |
| 188 | }} |
| 189 | else |
| 190 | {{ |
| 191 | ret = ( DISPATCH_TEST_FN_NOT_FOUND ); |
| 192 | }} |
| 193 | |
| 194 | return( ret ); |
| 195 | }} |
| 196 | |
| 197 | |
Azim Khan | 191e904 | 2017-06-09 12:39:00 +0100 | [diff] [blame] | 198 | {platform_code} |
| 199 | |
Azim Khan | 1de892b | 2017-06-09 15:02:36 +0100 | [diff] [blame] | 200 | #line {line_no} "suites/main_test.function" |
Azim Khan | 191e904 | 2017-06-09 12:39:00 +0100 | [diff] [blame] | 201 | |
SimonB | 152ea18 | 2016-02-15 23:27:28 +0000 | [diff] [blame] | 202 | /*----------------------------------------------------------------------------*/ |
| 203 | /* Main Test code */ |
| 204 | |
SimonB | 1594210 | 2016-04-25 21:34:49 +0100 | [diff] [blame] | 205 | |
Azim Khan | 191e904 | 2017-06-09 12:39:00 +0100 | [diff] [blame] | 206 | /** |
| 207 | * \brief Program main. Invokes platform specific execute_tests(). |
Gilles Peskine | 964faeb | 2017-09-29 18:00:25 +0200 | [diff] [blame] | 208 | * |
Azim Khan | 191e904 | 2017-06-09 12:39:00 +0100 | [diff] [blame] | 209 | * \param argc Command line arguments count. |
| 210 | * \param argv Array of command line arguments. |
| 211 | * |
| 212 | * \return Exit code. |
Gilles Peskine | 964faeb | 2017-09-29 18:00:25 +0200 | [diff] [blame] | 213 | */ |
Azim Khan | 191e904 | 2017-06-09 12:39:00 +0100 | [diff] [blame] | 214 | int main( int argc, const char *argv[] ) |
| 215 | {{ |
| 216 | int ret = platform_setup(); |
Andrzej Kurek | f13ca95 | 2018-04-18 04:14:31 -0400 | [diff] [blame] | 217 | if( ret != 0 ) |
Azim Khan | 191e904 | 2017-06-09 12:39:00 +0100 | [diff] [blame] | 218 | {{ |
Andrzej Kurek | f13ca95 | 2018-04-18 04:14:31 -0400 | [diff] [blame] | 219 | mbedtls_fprintf( stderr, |
| 220 | "FATAL: Failed to initialize platform - error %d\n", |
| 221 | ret ); |
| 222 | return( -1 ); |
Azim Khan | 191e904 | 2017-06-09 12:39:00 +0100 | [diff] [blame] | 223 | }} |
| 224 | ret = execute_tests( argc, argv ); |
Andrzej Kurek | 32a675f | 2018-04-13 06:16:04 -0400 | [diff] [blame] | 225 | platform_teardown(); |
Azim Khan | 191e904 | 2017-06-09 12:39:00 +0100 | [diff] [blame] | 226 | return( ret ); |
| 227 | }} |
| 228 | |