blob: 2ba919ce0796dcb4b773702a7789a7520ebfd1fb [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:
Mohammad Azim Khan5cb70172018-07-19 11:32:30 +01006 * $generator_script
Azim Khan191e9042017-06-09 12:39:00 +01007 *
Mohammad Azim Khan5cb70172018-07-19 11:32:30 +01008 * Test file : $test_file
Azim Khan191e9042017-06-09 12:39:00 +01009 *
10 * The following files were used to create this file.
11 *
Mohammad Azim Khan5cb70172018-07-19 11:32:30 +010012 * 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
Azim Khan191e9042017-06-09 12:39:00 +010017 *
18 *
Mohammad Azim Khand2d01122018-07-18 17:48:37 +010019 * This file is part of Mbed TLS (https://tls.mbed.org)
Azim Khan191e9042017-06-09 12:39:00 +010020 */
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
Mohammad Azim Khan5cb70172018-07-19 11:32:30 +010032$test_common_helpers
Paul Bakkerde56ca12013-09-15 17:05:21 +020033
Mohammad Azim Khan5cb70172018-07-19 11:32:30 +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
Mohammad Azim Khan5cb70172018-07-19 11:32:30 +010043$functions_code
Azim Khan191e9042017-06-09 12:39:00 +010044
Mohammad Azim Khan5cb70172018-07-19 11:32:30 +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:
Mohammad Azim Khan5cb70172018-07-19 11:32:30 +010057 * $generator_script
Azim Khan191e9042017-06-09 12:39:00 +010058 *
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 )
Mohammad Azim Khan5cb70172018-07-19 11:32:30 +010065{
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 )
Mohammad Azim Khan5cb70172018-07-19 11:32:30 +010072 {
73$expression_code
74#line $line_no "suites/main_test.function"
Azim Khanb1c2d0f2017-07-07 17:14:02 +010075 default:
Mohammad Azim Khan5cb70172018-07-19 11:32:30 +010076 {
Azim Khanb1c2d0f2017-07-07 17:14:02 +010077 ret = KEY_VALUE_MAPPING_NOT_FOUND;
Mohammad Azim Khan5cb70172018-07-19 11:32:30 +010078 }
Azim Khanb1c2d0f2017-07-07 17:14:02 +010079 break;
Mohammad Azim Khan5cb70172018-07-19 11:32:30 +010080 }
Azim Khanb1c2d0f2017-07-07 17:14:02 +010081 return( ret );
Mohammad Azim Khan5cb70172018-07-19 11:32:30 +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:
Mohammad Azim Khan5cb70172018-07-19 11:32:30 +010090 * $generator_script
Azim Khan191e9042017-06-09 12:39:00 +010091 *
92 * \param exp_id Dependency identifier.
93 *
94 * \return DEPENDENCY_SUPPORTED if set else DEPENDENCY_NOT_SUPPORTED
95 */
96int dep_check( int dep_id )
Mohammad Azim Khan5cb70172018-07-19 11:32:30 +010097{
Azim Khanb1c2d0f2017-07-07 17:14:02 +010098 int ret = DEPENDENCY_NOT_SUPPORTED;
99
100 (void) dep_id;
101
102 switch( dep_id )
Mohammad Azim Khan5cb70172018-07-19 11:32:30 +0100103 {
104$dep_check_code
105#line $line_no "suites/main_test.function"
Azim Khanb1c2d0f2017-07-07 17:14:02 +0100106 default:
107 break;
Mohammad Azim Khan5cb70172018-07-19 11:32:30 +0100108 }
Azim Khanb1c2d0f2017-07-07 17:14:02 +0100109 return( ret );
Mohammad Azim Khan5cb70172018-07-19 11:32:30 +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:
Mohammad Azim Khan5cb70172018-07-19 11:32:30 +0100128 * $generator_script
Azim Khan191e9042017-06-09 12:39:00 +0100129 *
130 */
131TestWrapper_t test_funcs[] =
Mohammad Azim Khan5cb70172018-07-19 11:32:30 +0100132{
133$dispatch_code
134#line $line_no "suites/main_test.function"
135};
Azim Khan191e9042017-06-09 12:39:00 +0100136
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 )
Mohammad Azim Khan5cb70172018-07-19 11:32:30 +0100148{
Azim Khan191e9042017-06-09 12:39:00 +0100149 int ret = DISPATCH_TEST_SUCCESS;
150 TestWrapper_t fp = NULL;
151
Mohammad Azim Khand2d01122018-07-18 17:48:37 +0100152 if ( func_idx < (int)( sizeof( test_funcs ) / sizeof( TestWrapper_t ) ) )
Mohammad Azim Khan5cb70172018-07-19 11:32:30 +0100153 {
Azim Khan191e9042017-06-09 12:39:00 +0100154 fp = test_funcs[func_idx];
155 if ( fp )
156 fp( params );
157 else
Mohammad Azim Khan5cb70172018-07-19 11:32:30 +0100158 ret = DISPATCH_UNSUPPORTED_SUITE;
159 }
Azim Khan191e9042017-06-09 12:39:00 +0100160 else
Mohammad Azim Khan5cb70172018-07-19 11:32:30 +0100161 {
162 ret = DISPATCH_TEST_FN_NOT_FOUND;
163 }
Azim Khan191e9042017-06-09 12:39:00 +0100164
Paul Bakker19343182013-08-16 13:31:10 +0200165 return( ret );
Mohammad Azim Khan5cb70172018-07-19 11:32:30 +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 )
Mohammad Azim Khan5cb70172018-07-19 11:32:30 +0100179{
Azim Khan13c6bfb2017-06-15 14:45:56 +0100180 int ret = DISPATCH_TEST_SUCCESS;
181 TestWrapper_t fp = NULL;
182
183 if ( func_idx < (int)( sizeof(test_funcs)/sizeof( TestWrapper_t ) ) )
Mohammad Azim Khan5cb70172018-07-19 11:32:30 +0100184 {
Azim Khan13c6bfb2017-06-15 14:45:56 +0100185 fp = test_funcs[func_idx];
186 if ( fp == NULL )
Mohammad Azim Khan5cb70172018-07-19 11:32:30 +0100187 ret = DISPATCH_UNSUPPORTED_SUITE;
188 }
Azim Khan13c6bfb2017-06-15 14:45:56 +0100189 else
Mohammad Azim Khan5cb70172018-07-19 11:32:30 +0100190 {
191 ret = DISPATCH_TEST_FN_NOT_FOUND;
192 }
Azim Khan13c6bfb2017-06-15 14:45:56 +0100193
194 return( ret );
Mohammad Azim Khan5cb70172018-07-19 11:32:30 +0100195}
Azim Khan13c6bfb2017-06-15 14:45:56 +0100196
197
Mohammad Azim Khan5cb70172018-07-19 11:32:30 +0100198$platform_code
Azim Khan191e9042017-06-09 12:39:00 +0100199
Mohammad Azim Khan5cb70172018-07-19 11:32:30 +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[] )
Mohammad Azim Khan5cb70172018-07-19 11:32:30 +0100215{
Azim Khan191e9042017-06-09 12:39:00 +0100216 int ret = platform_setup();
Andrzej Kurekf13ca952018-04-18 04:14:31 -0400217 if( ret != 0 )
Mohammad Azim Khan5cb70172018-07-19 11:32:30 +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 );
Mohammad Azim Khan5cb70172018-07-19 11:32:30 +0100223 }
Azim Khan191e9042017-06-09 12:39:00 +0100224 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 );
Mohammad Azim Khan5cb70172018-07-19 11:32:30 +0100227}
Azim Khan191e9042017-06-09 12:39:00 +0100228