blob: fa8a0afeefb8febabd4cbe64f07840c7015948d6 [file] [log] [blame]
Azim Khan1de892b2017-06-09 15:02:36 +01001#line 2 "suites/main_test.function"
Azim Khan191e9042017-06-09 12:39:00 +01002/*
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 Bakkerde56ca12013-09-15 17:05:21 +020021
Azim Khan191e9042017-06-09 12:39:00 +010022#if !defined(MBEDTLS_CONFIG_FILE)
23#include <mbedtls/config.h>
24#else
25#include MBEDTLS_CONFIG_FILE
26#endif
Paul Bakker19343182013-08-16 13:31:10 +020027
SimonB152ea182016-02-15 23:27:28 +000028
29/*----------------------------------------------------------------------------*/
Azim Khan191e9042017-06-09 12:39:00 +010030/* Common helper code */
SimonB152ea182016-02-15 23:27:28 +000031
Azim Khan191e9042017-06-09 12:39:00 +010032{test_common_helpers}
Paul Bakkerde56ca12013-09-15 17:05:21 +020033
Azim Khan1de892b2017-06-09 15:02:36 +010034#line {line_no} "suites/main_test.function"
Azim Khan191e9042017-06-09 12:39:00 +010035
36
37/*----------------------------------------------------------------------------*/
38/* Test Suite Code */
39
40
41#define TEST_SUITE_ACTIVE
42
Azim Khan191e9042017-06-09 12:39:00 +010043{functions_code}
44
Azim Khan1de892b2017-06-09 15:02:36 +010045#line {line_no} "suites/main_test.function"
SimonB15942102016-04-25 21:34:49 +010046
SimonB152ea182016-02-15 23:27:28 +000047
48/*----------------------------------------------------------------------------*/
49/* Test dispatch code */
50
Paul Bakker19343182013-08-16 13:31:10 +020051
Azim Khan191e9042017-06-09 12:39:00 +010052/**
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 */
64int get_expression( int32_t exp_id, int32_t * out_value )
65{{
Azim Khanb1c2d0f2017-07-07 17:14:02 +010066 int ret = KEY_VALUE_MAPPING_FOUND;
67
68 (void) exp_id;
69 (void) out_value;
70
71 switch( exp_id )
72 {{
Azim Khan191e9042017-06-09 12:39:00 +010073{expression_code}
Azim Khan1de892b2017-06-09 15:02:36 +010074#line {line_no} "suites/main_test.function"
Azim Khanb1c2d0f2017-07-07 17:14:02 +010075 default:
76 {{
77 ret = KEY_VALUE_MAPPING_NOT_FOUND;
78 }}
79 break;
Azim Khan191e9042017-06-09 12:39:00 +010080 }}
Azim Khanb1c2d0f2017-07-07 17:14:02 +010081 return( ret );
Azim Khan191e9042017-06-09 12:39:00 +010082}}
Paul Bakker19343182013-08-16 13:31:10 +020083
Paul Bakker19343182013-08-16 13:31:10 +020084
Azim Khan191e9042017-06-09 12:39:00 +010085/**
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 */
96int dep_check( int dep_id )
97{{
Azim Khanb1c2d0f2017-07-07 17:14:02 +010098 int ret = DEPENDENCY_NOT_SUPPORTED;
99
100 (void) dep_id;
101
102 switch( dep_id )
103 {{
Azim Khan191e9042017-06-09 12:39:00 +0100104{dep_check_code}
Azim Khan1de892b2017-06-09 15:02:36 +0100105#line {line_no} "suites/main_test.function"
Azim Khanb1c2d0f2017-07-07 17:14:02 +0100106 default:
107 break;
Azim Khan191e9042017-06-09 12:39:00 +0100108 }}
Azim Khanb1c2d0f2017-07-07 17:14:02 +0100109 return( ret );
Azim Khan191e9042017-06-09 12:39:00 +0100110}}
Paul Bakker19343182013-08-16 13:31:10 +0200111
SimonB8ca7bc42016-04-17 23:24:50 +0100112
Azim Khan191e9042017-06-09 12:39:00 +0100113/**
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 */
122typedef void (*TestWrapper_t)( void ** );
Simon Butcher65b1fa62016-05-23 23:18:26 +0100123
Azim Khan191e9042017-06-09 12:39:00 +0100124
125/**
126 * \brief Table of test function wrappers. Used by dispatch_test().
127 * This table is populated by script:
128 * {generator_script}
129 *
130 */
131TestWrapper_t test_funcs[] =
132{{
Mohammad Azim Khanb73159d2018-06-13 16:31:26 +0100133{dispatch_code}
Azim Khan1de892b2017-06-09 15:02:36 +0100134#line {line_no} "suites/main_test.function"
Azim Khan191e9042017-06-09 12:39:00 +0100135}};
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 */
147int 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 Bakker19343182013-08-16 13:31:10 +0200165 return( ret );
Azim Khan191e9042017-06-09 12:39:00 +0100166}}
Paul Bakker19343182013-08-16 13:31:10 +0200167
SimonB152ea182016-02-15 23:27:28 +0000168
Azim Khan13c6bfb2017-06-15 14:45:56 +0100169/**
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 */
178int 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 Khan191e9042017-06-09 12:39:00 +0100198{platform_code}
199
Azim Khan1de892b2017-06-09 15:02:36 +0100200#line {line_no} "suites/main_test.function"
Azim Khan191e9042017-06-09 12:39:00 +0100201
SimonB152ea182016-02-15 23:27:28 +0000202/*----------------------------------------------------------------------------*/
203/* Main Test code */
204
SimonB15942102016-04-25 21:34:49 +0100205
Azim Khan191e9042017-06-09 12:39:00 +0100206/**
207 * \brief Program main. Invokes platform specific execute_tests().
Gilles Peskine964faeb2017-09-29 18:00:25 +0200208 *
Azim Khan191e9042017-06-09 12:39:00 +0100209 * \param argc Command line arguments count.
210 * \param argv Array of command line arguments.
211 *
212 * \return Exit code.
Gilles Peskine964faeb2017-09-29 18:00:25 +0200213 */
Azim Khan191e9042017-06-09 12:39:00 +0100214int main( int argc, const char *argv[] )
215{{
216 int ret = platform_setup();
Andrzej Kurekf13ca952018-04-18 04:14:31 -0400217 if( ret != 0 )
Azim Khan191e9042017-06-09 12:39:00 +0100218 {{
Andrzej Kurekf13ca952018-04-18 04:14:31 -0400219 mbedtls_fprintf( stderr,
220 "FATAL: Failed to initialize platform - error %d\n",
221 ret );
222 return( -1 );
Azim Khan191e9042017-06-09 12:39:00 +0100223 }}
224 ret = execute_tests( argc, argv );
Andrzej Kurek32a675f2018-04-13 06:16:04 -0400225 platform_teardown();
Azim Khan191e9042017-06-09 12:39:00 +0100226 return( ret );
227}}
228