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 | {{ |
| 66 | {expression_code} |
Azim Khan | 1de892b | 2017-06-09 15:02:36 +0100 | [diff] [blame] | 67 | #line {line_no} "suites/main_test.function" |
Azim Khan | 191e904 | 2017-06-09 12:39:00 +0100 | [diff] [blame] | 68 | {{ |
| 69 | return( KEY_VALUE_MAPPING_NOT_FOUND ); |
| 70 | }} |
| 71 | return( KEY_VALUE_MAPPING_FOUND ); |
| 72 | }} |
Paul Bakker | 1934318 | 2013-08-16 13:31:10 +0200 | [diff] [blame] | 73 | |
Paul Bakker | 1934318 | 2013-08-16 13:31:10 +0200 | [diff] [blame] | 74 | |
Azim Khan | 191e904 | 2017-06-09 12:39:00 +0100 | [diff] [blame] | 75 | /** |
| 76 | * \brief Checks if the dependency i.e. the compile flag is set. |
| 77 | * For optimizing space for embedded targets each dependency |
| 78 | * is identified by a unique identifier instead of string literals. |
| 79 | * Identifiers and check code is generated by script: |
| 80 | * {generator_script} |
| 81 | * |
| 82 | * \param exp_id Dependency identifier. |
| 83 | * |
| 84 | * \return DEPENDENCY_SUPPORTED if set else DEPENDENCY_NOT_SUPPORTED |
| 85 | */ |
| 86 | int dep_check( int dep_id ) |
| 87 | {{ |
| 88 | {dep_check_code} |
Azim Khan | 1de892b | 2017-06-09 15:02:36 +0100 | [diff] [blame] | 89 | #line {line_no} "suites/main_test.function" |
Azim Khan | 191e904 | 2017-06-09 12:39:00 +0100 | [diff] [blame] | 90 | {{ |
| 91 | return( DEPENDENCY_NOT_SUPPORTED ); |
| 92 | }} |
| 93 | }} |
Paul Bakker | 1934318 | 2013-08-16 13:31:10 +0200 | [diff] [blame] | 94 | |
SimonB | 8ca7bc4 | 2016-04-17 23:24:50 +0100 | [diff] [blame] | 95 | |
Azim Khan | 191e904 | 2017-06-09 12:39:00 +0100 | [diff] [blame] | 96 | /** |
| 97 | * \brief Function pointer type for test function wrappers. |
| 98 | * |
| 99 | * |
| 100 | * \param void ** Pointer to void pointers. Represents an array of test |
| 101 | * function parameters. |
| 102 | * |
| 103 | * \return void |
| 104 | */ |
| 105 | typedef void (*TestWrapper_t)( void ** ); |
Simon Butcher | 65b1fa6 | 2016-05-23 23:18:26 +0100 | [diff] [blame] | 106 | |
Azim Khan | 191e904 | 2017-06-09 12:39:00 +0100 | [diff] [blame] | 107 | |
| 108 | /** |
| 109 | * \brief Table of test function wrappers. Used by dispatch_test(). |
| 110 | * This table is populated by script: |
| 111 | * {generator_script} |
| 112 | * |
| 113 | */ |
| 114 | TestWrapper_t test_funcs[] = |
| 115 | {{ |
Azim Khan | 1de892b | 2017-06-09 15:02:36 +0100 | [diff] [blame] | 116 | {dispatch_code} |
| 117 | #line {line_no} "suites/main_test.function" |
Azim Khan | 191e904 | 2017-06-09 12:39:00 +0100 | [diff] [blame] | 118 | }}; |
| 119 | |
| 120 | |
| 121 | /** |
| 122 | * \brief Dispatches test functions based on function index. |
| 123 | * |
| 124 | * \param exp_id Test function index. |
| 125 | * |
| 126 | * \return DISPATCH_TEST_SUCCESS if found |
| 127 | * DISPATCH_TEST_FN_NOT_FOUND if not found |
| 128 | * DISPATCH_UNSUPPORTED_SUITE if not compile time enabled. |
| 129 | */ |
| 130 | int dispatch_test( int func_idx, void ** params ) |
| 131 | {{ |
| 132 | int ret = DISPATCH_TEST_SUCCESS; |
| 133 | TestWrapper_t fp = NULL; |
| 134 | |
| 135 | if ( func_idx < (int)( sizeof(test_funcs)/sizeof( TestWrapper_t ) ) ) |
| 136 | {{ |
| 137 | fp = test_funcs[func_idx]; |
| 138 | if ( fp ) |
| 139 | fp( params ); |
| 140 | else |
| 141 | ret = ( DISPATCH_UNSUPPORTED_SUITE ); |
| 142 | }} |
| 143 | else |
| 144 | {{ |
| 145 | ret = ( DISPATCH_TEST_FN_NOT_FOUND ); |
| 146 | }} |
| 147 | |
Paul Bakker | 1934318 | 2013-08-16 13:31:10 +0200 | [diff] [blame] | 148 | return( ret ); |
Azim Khan | 191e904 | 2017-06-09 12:39:00 +0100 | [diff] [blame] | 149 | }} |
Paul Bakker | 1934318 | 2013-08-16 13:31:10 +0200 | [diff] [blame] | 150 | |
SimonB | 152ea18 | 2016-02-15 23:27:28 +0000 | [diff] [blame] | 151 | |
Azim Khan | 13c6bfb | 2017-06-15 14:45:56 +0100 | [diff] [blame^] | 152 | /** |
| 153 | * \brief Checks if test function is supported |
| 154 | * |
| 155 | * \param exp_id Test function index. |
| 156 | * |
| 157 | * \return DISPATCH_TEST_SUCCESS if found |
| 158 | * DISPATCH_TEST_FN_NOT_FOUND if not found |
| 159 | * DISPATCH_UNSUPPORTED_SUITE if not compile time enabled. |
| 160 | */ |
| 161 | int check_test( int func_idx ) |
| 162 | {{ |
| 163 | int ret = DISPATCH_TEST_SUCCESS; |
| 164 | TestWrapper_t fp = NULL; |
| 165 | |
| 166 | if ( func_idx < (int)( sizeof(test_funcs)/sizeof( TestWrapper_t ) ) ) |
| 167 | {{ |
| 168 | fp = test_funcs[func_idx]; |
| 169 | if ( fp == NULL ) |
| 170 | ret = ( DISPATCH_UNSUPPORTED_SUITE ); |
| 171 | }} |
| 172 | else |
| 173 | {{ |
| 174 | ret = ( DISPATCH_TEST_FN_NOT_FOUND ); |
| 175 | }} |
| 176 | |
| 177 | return( ret ); |
| 178 | }} |
| 179 | |
| 180 | |
Azim Khan | 191e904 | 2017-06-09 12:39:00 +0100 | [diff] [blame] | 181 | {platform_code} |
| 182 | |
Azim Khan | 1de892b | 2017-06-09 15:02:36 +0100 | [diff] [blame] | 183 | #line {line_no} "suites/main_test.function" |
Azim Khan | 191e904 | 2017-06-09 12:39:00 +0100 | [diff] [blame] | 184 | |
SimonB | 152ea18 | 2016-02-15 23:27:28 +0000 | [diff] [blame] | 185 | /*----------------------------------------------------------------------------*/ |
| 186 | /* Main Test code */ |
| 187 | |
SimonB | 1594210 | 2016-04-25 21:34:49 +0100 | [diff] [blame] | 188 | |
Azim Khan | 191e904 | 2017-06-09 12:39:00 +0100 | [diff] [blame] | 189 | /** |
| 190 | * \brief Program main. Invokes platform specific execute_tests(). |
Gilles Peskine | 964faeb | 2017-09-29 18:00:25 +0200 | [diff] [blame] | 191 | * |
Azim Khan | 191e904 | 2017-06-09 12:39:00 +0100 | [diff] [blame] | 192 | * \param argc Command line arguments count. |
| 193 | * \param argv Array of command line arguments. |
| 194 | * |
| 195 | * \return Exit code. |
Gilles Peskine | 964faeb | 2017-09-29 18:00:25 +0200 | [diff] [blame] | 196 | */ |
Azim Khan | 191e904 | 2017-06-09 12:39:00 +0100 | [diff] [blame] | 197 | int main( int argc, const char *argv[] ) |
| 198 | {{ |
| 199 | int ret = platform_setup(); |
Andrzej Kurek | f13ca95 | 2018-04-18 04:14:31 -0400 | [diff] [blame] | 200 | if( ret != 0 ) |
Azim Khan | 191e904 | 2017-06-09 12:39:00 +0100 | [diff] [blame] | 201 | {{ |
Andrzej Kurek | f13ca95 | 2018-04-18 04:14:31 -0400 | [diff] [blame] | 202 | mbedtls_fprintf( stderr, |
| 203 | "FATAL: Failed to initialize platform - error %d\n", |
| 204 | ret ); |
| 205 | return( -1 ); |
Azim Khan | 191e904 | 2017-06-09 12:39:00 +0100 | [diff] [blame] | 206 | }} |
| 207 | ret = execute_tests( argc, argv ); |
Andrzej Kurek | 32a675f | 2018-04-13 06:16:04 -0400 | [diff] [blame] | 208 | platform_teardown(); |
Azim Khan | 191e904 | 2017-06-09 12:39:00 +0100 | [diff] [blame] | 209 | return( ret ); |
| 210 | }} |
| 211 | |