blob: e294e362100e56fec254b6ff74e1792bf073a559 [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{{
66{expression_code}
Azim Khan1de892b2017-06-09 15:02:36 +010067#line {line_no} "suites/main_test.function"
Azim Khan191e9042017-06-09 12:39:00 +010068 {{
69 return( KEY_VALUE_MAPPING_NOT_FOUND );
70 }}
71 return( KEY_VALUE_MAPPING_FOUND );
72}}
Paul Bakker19343182013-08-16 13:31:10 +020073
Paul Bakker19343182013-08-16 13:31:10 +020074
Azim Khan191e9042017-06-09 12:39:00 +010075/**
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 */
86int dep_check( int dep_id )
87{{
88{dep_check_code}
Azim Khan1de892b2017-06-09 15:02:36 +010089#line {line_no} "suites/main_test.function"
Azim Khan191e9042017-06-09 12:39:00 +010090 {{
91 return( DEPENDENCY_NOT_SUPPORTED );
92 }}
93}}
Paul Bakker19343182013-08-16 13:31:10 +020094
SimonB8ca7bc42016-04-17 23:24:50 +010095
Azim Khan191e9042017-06-09 12:39:00 +010096/**
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 */
105typedef void (*TestWrapper_t)( void ** );
Simon Butcher65b1fa62016-05-23 23:18:26 +0100106
Azim Khan191e9042017-06-09 12:39:00 +0100107
108/**
109 * \brief Table of test function wrappers. Used by dispatch_test().
110 * This table is populated by script:
111 * {generator_script}
112 *
113 */
114TestWrapper_t test_funcs[] =
115{{
Azim Khan1de892b2017-06-09 15:02:36 +0100116{dispatch_code}
117#line {line_no} "suites/main_test.function"
Azim Khan191e9042017-06-09 12:39:00 +0100118}};
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 */
130int 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 Bakker19343182013-08-16 13:31:10 +0200148 return( ret );
Azim Khan191e9042017-06-09 12:39:00 +0100149}}
Paul Bakker19343182013-08-16 13:31:10 +0200150
SimonB152ea182016-02-15 23:27:28 +0000151
Azim Khan13c6bfb2017-06-15 14:45:56 +0100152/**
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 */
161int 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 Khan191e9042017-06-09 12:39:00 +0100181{platform_code}
182
Azim Khan1de892b2017-06-09 15:02:36 +0100183#line {line_no} "suites/main_test.function"
Azim Khan191e9042017-06-09 12:39:00 +0100184
SimonB152ea182016-02-15 23:27:28 +0000185/*----------------------------------------------------------------------------*/
186/* Main Test code */
187
SimonB15942102016-04-25 21:34:49 +0100188
Azim Khan191e9042017-06-09 12:39:00 +0100189/**
190 * \brief Program main. Invokes platform specific execute_tests().
Gilles Peskine964faeb2017-09-29 18:00:25 +0200191 *
Azim Khan191e9042017-06-09 12:39:00 +0100192 * \param argc Command line arguments count.
193 * \param argv Array of command line arguments.
194 *
195 * \return Exit code.
Gilles Peskine964faeb2017-09-29 18:00:25 +0200196 */
Azim Khan191e9042017-06-09 12:39:00 +0100197int main( int argc, const char *argv[] )
198{{
199 int ret = platform_setup();
Andrzej Kurekf13ca952018-04-18 04:14:31 -0400200 if( ret != 0 )
Azim Khan191e9042017-06-09 12:39:00 +0100201 {{
Andrzej Kurekf13ca952018-04-18 04:14:31 -0400202 mbedtls_fprintf( stderr,
203 "FATAL: Failed to initialize platform - error %d\n",
204 ret );
205 return( -1 );
Azim Khan191e9042017-06-09 12:39:00 +0100206 }}
207 ret = execute_tests( argc, argv );
Andrzej Kurek32a675f2018-04-13 06:16:04 -0400208 platform_teardown();
Azim Khan191e9042017-06-09 12:39:00 +0100209 return( ret );
210}}
211