blob: 0dcab7d6953771faa8faf526c387815d1836b31d [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
43{function_headers}
44
45{functions_code}
46
Azim Khan1de892b2017-06-09 15:02:36 +010047#line {line_no} "suites/main_test.function"
SimonB15942102016-04-25 21:34:49 +010048
SimonB152ea182016-02-15 23:27:28 +000049
50/*----------------------------------------------------------------------------*/
51/* Test dispatch code */
52
Paul Bakker19343182013-08-16 13:31:10 +020053
Azim Khan191e9042017-06-09 12:39:00 +010054/**
55 * \brief Evaluates an expression/macro into its literal integer value.
56 * For optimizing space for embedded targets each expression/macro
57 * is identified by a unique identifier instead of string literals.
58 * Identifiers and evaluation code is generated by script:
59 * {generator_script}
60 *
61 * \param exp_id Expression identifier.
62 * \param out_value Pointer to int to hold the integer.
63 *
64 * \return 0 if exp_id is found. 1 otherwise.
65 */
66int get_expression( int32_t exp_id, int32_t * out_value )
67{{
68{expression_code}
Azim Khan1de892b2017-06-09 15:02:36 +010069#line {line_no} "suites/main_test.function"
Azim Khan191e9042017-06-09 12:39:00 +010070 {{
71 return( KEY_VALUE_MAPPING_NOT_FOUND );
72 }}
73 return( KEY_VALUE_MAPPING_FOUND );
74}}
Paul Bakker19343182013-08-16 13:31:10 +020075
Paul Bakker19343182013-08-16 13:31:10 +020076
Azim Khan191e9042017-06-09 12:39:00 +010077/**
78 * \brief Checks if the dependency i.e. the compile flag is set.
79 * For optimizing space for embedded targets each dependency
80 * is identified by a unique identifier instead of string literals.
81 * Identifiers and check code is generated by script:
82 * {generator_script}
83 *
84 * \param exp_id Dependency identifier.
85 *
86 * \return DEPENDENCY_SUPPORTED if set else DEPENDENCY_NOT_SUPPORTED
87 */
88int dep_check( int dep_id )
89{{
90{dep_check_code}
Azim Khan1de892b2017-06-09 15:02:36 +010091#line {line_no} "suites/main_test.function"
Azim Khan191e9042017-06-09 12:39:00 +010092 {{
93 return( DEPENDENCY_NOT_SUPPORTED );
94 }}
95}}
Paul Bakker19343182013-08-16 13:31:10 +020096
SimonB8ca7bc42016-04-17 23:24:50 +010097
Azim Khan191e9042017-06-09 12:39:00 +010098/**
99 * \brief Function pointer type for test function wrappers.
100 *
101 *
102 * \param void ** Pointer to void pointers. Represents an array of test
103 * function parameters.
104 *
105 * \return void
106 */
107typedef void (*TestWrapper_t)( void ** );
Simon Butcher65b1fa62016-05-23 23:18:26 +0100108
Azim Khan191e9042017-06-09 12:39:00 +0100109
110/**
111 * \brief Table of test function wrappers. Used by dispatch_test().
112 * This table is populated by script:
113 * {generator_script}
114 *
115 */
116TestWrapper_t test_funcs[] =
117{{
Azim Khan1de892b2017-06-09 15:02:36 +0100118{dispatch_code}
119#line {line_no} "suites/main_test.function"
Azim Khan191e9042017-06-09 12:39:00 +0100120}};
121
122
123/**
124 * \brief Dispatches test functions based on function index.
125 *
126 * \param exp_id Test function index.
127 *
128 * \return DISPATCH_TEST_SUCCESS if found
129 * DISPATCH_TEST_FN_NOT_FOUND if not found
130 * DISPATCH_UNSUPPORTED_SUITE if not compile time enabled.
131 */
132int dispatch_test( int func_idx, void ** params )
133{{
134 int ret = DISPATCH_TEST_SUCCESS;
135 TestWrapper_t fp = NULL;
136
137 if ( func_idx < (int)( sizeof(test_funcs)/sizeof( TestWrapper_t ) ) )
138 {{
139 fp = test_funcs[func_idx];
140 if ( fp )
141 fp( params );
142 else
143 ret = ( DISPATCH_UNSUPPORTED_SUITE );
144 }}
145 else
146 {{
147 ret = ( DISPATCH_TEST_FN_NOT_FOUND );
148 }}
149
Paul Bakker19343182013-08-16 13:31:10 +0200150 return( ret );
Azim Khan191e9042017-06-09 12:39:00 +0100151}}
Paul Bakker19343182013-08-16 13:31:10 +0200152
SimonB152ea182016-02-15 23:27:28 +0000153
Azim Khan191e9042017-06-09 12:39:00 +0100154{platform_code}
155
Azim Khan1de892b2017-06-09 15:02:36 +0100156#line {line_no} "suites/main_test.function"
Azim Khan191e9042017-06-09 12:39:00 +0100157
SimonB152ea182016-02-15 23:27:28 +0000158/*----------------------------------------------------------------------------*/
159/* Main Test code */
160
SimonB15942102016-04-25 21:34:49 +0100161
Azim Khan191e9042017-06-09 12:39:00 +0100162/**
163 * \brief Program main. Invokes platform specific execute_tests().
Gilles Peskine964faeb2017-09-29 18:00:25 +0200164 *
Azim Khan191e9042017-06-09 12:39:00 +0100165 * \param argc Command line arguments count.
166 * \param argv Array of command line arguments.
167 *
168 * \return Exit code.
Gilles Peskine964faeb2017-09-29 18:00:25 +0200169 */
Azim Khan191e9042017-06-09 12:39:00 +0100170int main( int argc, const char *argv[] )
171{{
172 int ret = platform_setup();
Andrzej Kurekf13ca952018-04-18 04:14:31 -0400173 if( ret != 0 )
Azim Khan191e9042017-06-09 12:39:00 +0100174 {{
Andrzej Kurekf13ca952018-04-18 04:14:31 -0400175 mbedtls_fprintf( stderr,
176 "FATAL: Failed to initialize platform - error %d\n",
177 ret );
178 return( -1 );
Azim Khan191e9042017-06-09 12:39:00 +0100179 }}
180 ret = execute_tests( argc, argv );
Andrzej Kurek32a675f2018-04-13 06:16:04 -0400181 platform_teardown();
Azim Khan191e9042017-06-09 12:39:00 +0100182 return( ret );
183}}
184