Paul Bakker | de56ca1 | 2013-09-15 17:05:21 +0200 | [diff] [blame] | 1 | SUITE_PRE_DEP |
| 2 | #define TEST_SUITE_ACTIVE |
| 3 | |
Paul Bakker | 1934318 | 2013-08-16 13:31:10 +0200 | [diff] [blame] | 4 | int verify_string( char **str ) |
| 5 | { |
| 6 | if( (*str)[0] != '"' || |
| 7 | (*str)[strlen( *str ) - 1] != '"' ) |
| 8 | { |
Manuel Pégourié-Gonnard | 2cf5a7c | 2015-04-08 12:49:31 +0200 | [diff] [blame] | 9 | mbedtls_printf( "Expected string (with \"\") for parameter and got: %s\n", *str ); |
Paul Bakker | 1934318 | 2013-08-16 13:31:10 +0200 | [diff] [blame] | 10 | return( -1 ); |
| 11 | } |
| 12 | |
| 13 | (*str)++; |
| 14 | (*str)[strlen( *str ) - 1] = '\0'; |
| 15 | |
| 16 | return( 0 ); |
| 17 | } |
| 18 | |
| 19 | int verify_int( char *str, int *value ) |
| 20 | { |
| 21 | size_t i; |
| 22 | int minus = 0; |
| 23 | int digits = 1; |
| 24 | int hex = 0; |
| 25 | |
| 26 | for( i = 0; i < strlen( str ); i++ ) |
| 27 | { |
| 28 | if( i == 0 && str[i] == '-' ) |
| 29 | { |
| 30 | minus = 1; |
| 31 | continue; |
| 32 | } |
| 33 | |
| 34 | if( ( ( minus && i == 2 ) || ( !minus && i == 1 ) ) && |
| 35 | str[i - 1] == '0' && str[i] == 'x' ) |
| 36 | { |
| 37 | hex = 1; |
| 38 | continue; |
| 39 | } |
| 40 | |
Manuel Pégourié-Gonnard | 725afd8 | 2014-02-01 11:54:28 +0100 | [diff] [blame] | 41 | if( ! ( ( str[i] >= '0' && str[i] <= '9' ) || |
| 42 | ( hex && ( ( str[i] >= 'a' && str[i] <= 'f' ) || |
| 43 | ( str[i] >= 'A' && str[i] <= 'F' ) ) ) ) ) |
Paul Bakker | 1934318 | 2013-08-16 13:31:10 +0200 | [diff] [blame] | 44 | { |
| 45 | digits = 0; |
| 46 | break; |
| 47 | } |
| 48 | } |
| 49 | |
| 50 | if( digits ) |
| 51 | { |
| 52 | if( hex ) |
| 53 | *value = strtol( str, NULL, 16 ); |
| 54 | else |
| 55 | *value = strtol( str, NULL, 10 ); |
| 56 | |
| 57 | return( 0 ); |
| 58 | } |
| 59 | |
| 60 | MAPPING_CODE |
| 61 | |
Manuel Pégourié-Gonnard | 2cf5a7c | 2015-04-08 12:49:31 +0200 | [diff] [blame] | 62 | mbedtls_printf( "Expected integer for parameter and got: %s\n", str ); |
SimonB | 8ca7bc4 | 2016-04-17 23:24:50 +0100 | [diff] [blame^] | 63 | return( KEY_VALUE_MAPPING_NOT_FOUND ); |
Paul Bakker | 1934318 | 2013-08-16 13:31:10 +0200 | [diff] [blame] | 64 | } |
| 65 | |
SimonB | 152ea18 | 2016-02-15 23:27:28 +0000 | [diff] [blame] | 66 | |
| 67 | /*----------------------------------------------------------------------------*/ |
| 68 | /* Test Case code */ |
| 69 | |
Paul Bakker | de56ca1 | 2013-09-15 17:05:21 +0200 | [diff] [blame] | 70 | FUNCTION_CODE |
| 71 | SUITE_POST_DEP |
| 72 | |
SimonB | 152ea18 | 2016-02-15 23:27:28 +0000 | [diff] [blame] | 73 | |
| 74 | /*----------------------------------------------------------------------------*/ |
| 75 | /* Test dispatch code */ |
| 76 | |
Paul Bakker | 1934318 | 2013-08-16 13:31:10 +0200 | [diff] [blame] | 77 | int dep_check( char *str ) |
| 78 | { |
| 79 | if( str == NULL ) |
| 80 | return( 1 ); |
| 81 | |
| 82 | DEP_CHECK_CODE |
| 83 | |
SimonB | 8ca7bc4 | 2016-04-17 23:24:50 +0100 | [diff] [blame^] | 84 | return( DEPENDENCY_NOT_SUPPORTED ); |
Paul Bakker | 1934318 | 2013-08-16 13:31:10 +0200 | [diff] [blame] | 85 | } |
| 86 | |
Paul Bakker | 1934318 | 2013-08-16 13:31:10 +0200 | [diff] [blame] | 87 | int dispatch_test(int cnt, char *params[50]) |
| 88 | { |
| 89 | int ret; |
Paul Bakker | b34fef2 | 2013-08-20 12:06:33 +0200 | [diff] [blame] | 90 | ((void) cnt); |
| 91 | ((void) params); |
Paul Bakker | 1934318 | 2013-08-16 13:31:10 +0200 | [diff] [blame] | 92 | |
Paul Bakker | b34fef2 | 2013-08-20 12:06:33 +0200 | [diff] [blame] | 93 | #if defined(TEST_SUITE_ACTIVE) |
SimonB | 8ca7bc4 | 2016-04-17 23:24:50 +0100 | [diff] [blame^] | 94 | ret = DISPATCH_TEST_SUCCESS; |
| 95 | |
Paul Bakker | 1934318 | 2013-08-16 13:31:10 +0200 | [diff] [blame] | 96 | DISPATCH_FUNCTION |
| 97 | { |
SimonB | 8ca7bc4 | 2016-04-17 23:24:50 +0100 | [diff] [blame^] | 98 | mbedtls_fprintf( stdout, |
| 99 | "FAILED\nSkipping unknown test function '%s'\n", |
| 100 | params[0] ); |
Paul Bakker | 1934318 | 2013-08-16 13:31:10 +0200 | [diff] [blame] | 101 | fflush( stdout ); |
SimonB | 8ca7bc4 | 2016-04-17 23:24:50 +0100 | [diff] [blame^] | 102 | ret = DISPATCH_TEST_FN_NOT_FOUND; |
Paul Bakker | 1934318 | 2013-08-16 13:31:10 +0200 | [diff] [blame] | 103 | } |
Paul Bakker | b34fef2 | 2013-08-20 12:06:33 +0200 | [diff] [blame] | 104 | #else |
SimonB | 8ca7bc4 | 2016-04-17 23:24:50 +0100 | [diff] [blame^] | 105 | ret = DISPATCH_UNSUPPORTED_SUITE; |
Paul Bakker | b34fef2 | 2013-08-20 12:06:33 +0200 | [diff] [blame] | 106 | #endif |
Paul Bakker | 1934318 | 2013-08-16 13:31:10 +0200 | [diff] [blame] | 107 | return( ret ); |
| 108 | } |
| 109 | |
SimonB | 152ea18 | 2016-02-15 23:27:28 +0000 | [diff] [blame] | 110 | |
| 111 | /*----------------------------------------------------------------------------*/ |
| 112 | /* Main Test code */ |
| 113 | |
SimonB | 8ca7bc4 | 2016-04-17 23:24:50 +0100 | [diff] [blame^] | 114 | #define USAGE \ |
| 115 | "Usage: %s [OPTIONS] files...\n\n" \ |
| 116 | " Command line arguments:\n" \ |
| 117 | " files... One or more test data file. If no file is specified\n" \ |
| 118 | " the followimg default test case is used:\n" \ |
| 119 | " %s\n\n" \ |
| 120 | " Options:\n" \ |
| 121 | " -v | --verbose Display full information about each test\n" \ |
| 122 | " -h | --help Display this information\n\n", \ |
| 123 | argv[0], \ |
| 124 | "TEST_FILENAME" |
| 125 | |
| 126 | |
Paul Bakker | 1934318 | 2013-08-16 13:31:10 +0200 | [diff] [blame] | 127 | int get_line( FILE *f, char *buf, size_t len ) |
| 128 | { |
| 129 | char *ret; |
| 130 | |
| 131 | ret = fgets( buf, len, f ); |
| 132 | if( ret == NULL ) |
| 133 | return( -1 ); |
| 134 | |
| 135 | if( strlen( buf ) && buf[strlen(buf) - 1] == '\n' ) |
| 136 | buf[strlen(buf) - 1] = '\0'; |
| 137 | if( strlen( buf ) && buf[strlen(buf) - 1] == '\r' ) |
| 138 | buf[strlen(buf) - 1] = '\0'; |
| 139 | |
| 140 | return( 0 ); |
| 141 | } |
| 142 | |
| 143 | int parse_arguments( char *buf, size_t len, char *params[50] ) |
| 144 | { |
| 145 | int cnt = 0, i; |
| 146 | char *cur = buf; |
| 147 | char *p = buf, *q; |
| 148 | |
| 149 | params[cnt++] = cur; |
| 150 | |
| 151 | while( *p != '\0' && p < buf + len ) |
| 152 | { |
| 153 | if( *p == '\\' ) |
| 154 | { |
Manuel Pégourié-Gonnard | 2d5f142 | 2014-01-22 16:01:17 +0100 | [diff] [blame] | 155 | p++; |
| 156 | p++; |
Paul Bakker | 1934318 | 2013-08-16 13:31:10 +0200 | [diff] [blame] | 157 | continue; |
| 158 | } |
| 159 | if( *p == ':' ) |
| 160 | { |
| 161 | if( p + 1 < buf + len ) |
| 162 | { |
| 163 | cur = p + 1; |
| 164 | params[cnt++] = cur; |
| 165 | } |
| 166 | *p = '\0'; |
| 167 | } |
| 168 | |
Manuel Pégourié-Gonnard | 2d5f142 | 2014-01-22 16:01:17 +0100 | [diff] [blame] | 169 | p++; |
Paul Bakker | 1934318 | 2013-08-16 13:31:10 +0200 | [diff] [blame] | 170 | } |
| 171 | |
SimonB | 0269dad | 2016-02-17 23:34:30 +0000 | [diff] [blame] | 172 | /* Replace newlines, question marks and colons in strings */ |
Paul Bakker | 1934318 | 2013-08-16 13:31:10 +0200 | [diff] [blame] | 173 | for( i = 0; i < cnt; i++ ) |
| 174 | { |
| 175 | p = params[i]; |
| 176 | q = params[i]; |
| 177 | |
| 178 | while( *p != '\0' ) |
| 179 | { |
| 180 | if( *p == '\\' && *(p + 1) == 'n' ) |
| 181 | { |
| 182 | p += 2; |
| 183 | *(q++) = '\n'; |
| 184 | } |
| 185 | else if( *p == '\\' && *(p + 1) == ':' ) |
| 186 | { |
| 187 | p += 2; |
| 188 | *(q++) = ':'; |
| 189 | } |
| 190 | else if( *p == '\\' && *(p + 1) == '?' ) |
| 191 | { |
| 192 | p += 2; |
| 193 | *(q++) = '?'; |
| 194 | } |
| 195 | else |
| 196 | *(q++) = *(p++); |
| 197 | } |
| 198 | *q = '\0'; |
| 199 | } |
| 200 | |
| 201 | return( cnt ); |
| 202 | } |
| 203 | |
Manuel Pégourié-Gonnard | 7b6dcbe | 2015-06-22 10:48:01 +0200 | [diff] [blame] | 204 | static int test_snprintf( size_t n, const char ref_buf[10], int ref_ret ) |
| 205 | { |
| 206 | int ret; |
| 207 | char buf[10] = "xxxxxxxxx"; |
Manuel Pégourié-Gonnard | 4b00f08 | 2015-06-26 11:24:32 +0200 | [diff] [blame] | 208 | const char ref[10] = "xxxxxxxxx"; |
Manuel Pégourié-Gonnard | 7b6dcbe | 2015-06-22 10:48:01 +0200 | [diff] [blame] | 209 | |
| 210 | ret = mbedtls_snprintf( buf, n, "%s", "123" ); |
| 211 | if( ret < 0 || (size_t) ret >= n ) |
| 212 | ret = -1; |
| 213 | |
Manuel Pégourié-Gonnard | 4b00f08 | 2015-06-26 11:24:32 +0200 | [diff] [blame] | 214 | if( strncmp( ref_buf, buf, sizeof( buf ) ) != 0 || |
| 215 | ref_ret != ret || |
| 216 | memcmp( buf + n, ref + n, sizeof( buf ) - n ) != 0 ) |
Manuel Pégourié-Gonnard | 7b6dcbe | 2015-06-22 10:48:01 +0200 | [diff] [blame] | 217 | { |
| 218 | return( 1 ); |
| 219 | } |
| 220 | |
| 221 | return( 0 ); |
| 222 | } |
| 223 | |
| 224 | static int run_test_snprintf( void ) |
| 225 | { |
| 226 | return( test_snprintf( 0, "xxxxxxxxx", -1 ) != 0 || |
Manuel Pégourié-Gonnard | 4b00f08 | 2015-06-26 11:24:32 +0200 | [diff] [blame] | 227 | test_snprintf( 1, "", -1 ) != 0 || |
| 228 | test_snprintf( 2, "1", -1 ) != 0 || |
| 229 | test_snprintf( 3, "12", -1 ) != 0 || |
| 230 | test_snprintf( 4, "123", 3 ) != 0 || |
| 231 | test_snprintf( 5, "123", 3 ) != 0 ); |
Manuel Pégourié-Gonnard | 7b6dcbe | 2015-06-22 10:48:01 +0200 | [diff] [blame] | 232 | } |
| 233 | |
Simon Butcher | aad787f | 2016-01-26 22:13:58 +0000 | [diff] [blame] | 234 | int main(int argc, const char *argv[]) |
Paul Bakker | 1934318 | 2013-08-16 13:31:10 +0200 | [diff] [blame] | 235 | { |
SimonB | 8ca7bc4 | 2016-04-17 23:24:50 +0100 | [diff] [blame^] | 236 | /* Local Configurations and options */ |
Simon Butcher | aad787f | 2016-01-26 22:13:58 +0000 | [diff] [blame] | 237 | const char *default_filename = "TEST_FILENAME"; |
| 238 | const char *test_filename = NULL; |
| 239 | const char **test_files = NULL; |
SimonB | 8ca7bc4 | 2016-04-17 23:24:50 +0100 | [diff] [blame^] | 240 | int testfile_count = 0; |
| 241 | int option_verbose = 0; |
| 242 | |
| 243 | /* Other Local variables */ |
| 244 | int arg_index = 1; |
| 245 | const char *next_arg; |
| 246 | int testfile_index, ret, i, cnt; |
| 247 | int total_errors = 0, total_tests = 0, total_skipped = 0; |
Paul Bakker | 1934318 | 2013-08-16 13:31:10 +0200 | [diff] [blame] | 248 | FILE *file; |
| 249 | char buf[5000]; |
| 250 | char *params[50]; |
Manuel Pégourié-Gonnard | d14acbc | 2015-05-29 11:26:37 +0200 | [diff] [blame] | 251 | void *pointer; |
Paul Bakker | 1934318 | 2013-08-16 13:31:10 +0200 | [diff] [blame] | 252 | |
Manuel Pégourié-Gonnard | 2cf5a7c | 2015-04-08 12:49:31 +0200 | [diff] [blame] | 253 | #if defined(MBEDTLS_MEMORY_BUFFER_ALLOC_C) && \ |
Manuel Pégourié-Gonnard | 765bb31 | 2014-11-27 11:55:27 +0100 | [diff] [blame] | 254 | !defined(TEST_SUITE_MEMORY_BUFFER_ALLOC) |
Paul Bakker | 1337aff | 2013-09-29 14:45:34 +0200 | [diff] [blame] | 255 | unsigned char alloc_buf[1000000]; |
Manuel Pégourié-Gonnard | 2cf5a7c | 2015-04-08 12:49:31 +0200 | [diff] [blame] | 256 | mbedtls_memory_buffer_alloc_init( alloc_buf, sizeof(alloc_buf) ); |
Paul Bakker | 1934318 | 2013-08-16 13:31:10 +0200 | [diff] [blame] | 257 | #endif |
| 258 | |
Manuel Pégourié-Gonnard | d14acbc | 2015-05-29 11:26:37 +0200 | [diff] [blame] | 259 | /* |
| 260 | * The C standard doesn't guarantee that all-bits-0 is the representation |
| 261 | * of a NULL pointer. We do however use that in our code for initializing |
| 262 | * structures, which should work on every modern platform. Let's be sure. |
| 263 | */ |
| 264 | memset( &pointer, 0, sizeof( void * ) ); |
| 265 | if( pointer != NULL ) |
| 266 | { |
| 267 | mbedtls_fprintf( stderr, "all-bits-zero is not a NULL pointer\n" ); |
| 268 | return( 1 ); |
| 269 | } |
| 270 | |
Manuel Pégourié-Gonnard | 7b6dcbe | 2015-06-22 10:48:01 +0200 | [diff] [blame] | 271 | /* |
| 272 | * Make sure we have a snprintf that correctly zero-terminates |
| 273 | */ |
| 274 | if( run_test_snprintf() != 0 ) |
| 275 | { |
| 276 | mbedtls_fprintf( stderr, "the snprintf implementation is broken\n" ); |
| 277 | return( 0 ); |
| 278 | } |
| 279 | |
SimonB | 8ca7bc4 | 2016-04-17 23:24:50 +0100 | [diff] [blame^] | 280 | while( arg_index < argc) |
| 281 | { |
| 282 | next_arg = argv[ arg_index ]; |
| 283 | |
| 284 | if( strcmp(next_arg, "--verbose" ) == 0 || |
| 285 | strcmp(next_arg, "-v" ) == 0 ) |
| 286 | { |
| 287 | option_verbose = 1; |
| 288 | } |
| 289 | else if( strcmp(next_arg, "--help" ) == 0 || |
| 290 | strcmp(next_arg, "-h" ) == 0 ) |
| 291 | { |
| 292 | mbedtls_fprintf( stdout, USAGE ); |
| 293 | mbedtls_exit( EXIT_SUCCESS ); |
| 294 | } |
| 295 | else |
| 296 | { |
| 297 | /* Not an option, therefore treat all further arguments as the file |
| 298 | * list. |
| 299 | */ |
| 300 | test_files = &argv[ arg_index ]; |
| 301 | testfile_count = argc - arg_index; |
| 302 | } |
| 303 | |
| 304 | arg_index++; |
| 305 | } |
| 306 | |
| 307 | /* If no files were specified, assume a default */ |
| 308 | if ( test_files == NULL || testfile_count == 0 ) |
Paul Bakker | 1934318 | 2013-08-16 13:31:10 +0200 | [diff] [blame] | 309 | { |
Simon Butcher | aad787f | 2016-01-26 22:13:58 +0000 | [diff] [blame] | 310 | test_files = &default_filename; |
| 311 | testfile_count = 1; |
| 312 | } |
Paul Bakker | 1934318 | 2013-08-16 13:31:10 +0200 | [diff] [blame] | 313 | |
SimonB | 8ca7bc4 | 2016-04-17 23:24:50 +0100 | [diff] [blame^] | 314 | /* Now begin to execute the tests in the testfiles */ |
Simon Butcher | aad787f | 2016-01-26 22:13:58 +0000 | [diff] [blame] | 315 | for ( testfile_index = 0; |
| 316 | testfile_index < testfile_count; |
| 317 | testfile_index++ ) |
Paul Bakker | 1934318 | 2013-08-16 13:31:10 +0200 | [diff] [blame] | 318 | { |
Simon Butcher | aad787f | 2016-01-26 22:13:58 +0000 | [diff] [blame] | 319 | test_filename = test_files[ testfile_index ]; |
Paul Bakker | 1934318 | 2013-08-16 13:31:10 +0200 | [diff] [blame] | 320 | |
Simon Butcher | aad787f | 2016-01-26 22:13:58 +0000 | [diff] [blame] | 321 | file = fopen( test_filename, "r" ); |
| 322 | if( file == NULL ) |
Paul Bakker | 1934318 | 2013-08-16 13:31:10 +0200 | [diff] [blame] | 323 | { |
Simon Butcher | aad787f | 2016-01-26 22:13:58 +0000 | [diff] [blame] | 324 | mbedtls_fprintf( stderr, "Failed to open test file: %s\n", |
| 325 | test_filename ); |
| 326 | return( 1 ); |
| 327 | } |
| 328 | |
| 329 | while( !feof( file ) ) |
| 330 | { |
SimonB | 8ca7bc4 | 2016-04-17 23:24:50 +0100 | [diff] [blame^] | 331 | int unmet_dep_count = 0; |
| 332 | char *unmet_dependencies[20]; |
Simon Butcher | aad787f | 2016-01-26 22:13:58 +0000 | [diff] [blame] | 333 | |
| 334 | if( ( ret = get_line( file, buf, sizeof(buf) ) ) != 0 ) |
| 335 | break; |
| 336 | mbedtls_fprintf( stdout, "%s%.66s", test_errors ? "\n" : "", buf ); |
| 337 | mbedtls_fprintf( stdout, " " ); |
| 338 | for( i = strlen( buf ) + 1; i < 67; i++ ) |
| 339 | mbedtls_fprintf( stdout, "." ); |
| 340 | mbedtls_fprintf( stdout, " " ); |
| 341 | fflush( stdout ); |
| 342 | |
| 343 | total_tests++; |
Paul Bakker | 1934318 | 2013-08-16 13:31:10 +0200 | [diff] [blame] | 344 | |
| 345 | if( ( ret = get_line( file, buf, sizeof(buf) ) ) != 0 ) |
| 346 | break; |
| 347 | cnt = parse_arguments( buf, strlen(buf), params ); |
Paul Bakker | 1934318 | 2013-08-16 13:31:10 +0200 | [diff] [blame] | 348 | |
Simon Butcher | aad787f | 2016-01-26 22:13:58 +0000 | [diff] [blame] | 349 | if( strcmp( params[0], "depends_on" ) == 0 ) |
| 350 | { |
| 351 | for( i = 1; i < cnt; i++ ) |
SimonB | 8ca7bc4 | 2016-04-17 23:24:50 +0100 | [diff] [blame^] | 352 | { |
| 353 | if( dep_check( params[i] ) != DEPENDENCY_SUPPORTED ) |
| 354 | { |
| 355 | unmet_dependencies[ i-1 ] = strdup(params[i]); |
| 356 | if( unmet_dependencies[ i-1 ] == NULL ) |
| 357 | { |
| 358 | mbedtls_printf("FATAL: Out of memory\n"); |
| 359 | mbedtls_exit( MBEDTLS_PLATFORM_STD_EXIT_FAILURE ); |
| 360 | } |
| 361 | unmet_dep_count++; |
| 362 | } |
| 363 | } |
Paul Bakker | 1934318 | 2013-08-16 13:31:10 +0200 | [diff] [blame] | 364 | |
Simon Butcher | aad787f | 2016-01-26 22:13:58 +0000 | [diff] [blame] | 365 | if( ( ret = get_line( file, buf, sizeof(buf) ) ) != 0 ) |
| 366 | break; |
| 367 | cnt = parse_arguments( buf, strlen(buf), params ); |
| 368 | } |
SimonB | 8ca7bc4 | 2016-04-17 23:24:50 +0100 | [diff] [blame^] | 369 | |
| 370 | // If there are no unmet dependencies execute the test |
| 371 | if( unmet_dep_count == 0 ) |
Simon Butcher | aad787f | 2016-01-26 22:13:58 +0000 | [diff] [blame] | 372 | { |
| 373 | test_errors = 0; |
| 374 | ret = dispatch_test( cnt, params ); |
| 375 | } |
| 376 | |
SimonB | 8ca7bc4 | 2016-04-17 23:24:50 +0100 | [diff] [blame^] | 377 | if( unmet_dep_count > 0 || ret == DISPATCH_UNSUPPORTED_SUITE ) |
Simon Butcher | aad787f | 2016-01-26 22:13:58 +0000 | [diff] [blame] | 378 | { |
| 379 | total_skipped++; |
| 380 | mbedtls_fprintf( stdout, "----\n" ); |
SimonB | 8ca7bc4 | 2016-04-17 23:24:50 +0100 | [diff] [blame^] | 381 | |
| 382 | if( 1 == option_verbose && ret == DISPATCH_UNSUPPORTED_SUITE ) |
| 383 | { |
| 384 | mbedtls_fprintf( stdout, " Test Suite not enabled" ); |
| 385 | } |
| 386 | |
| 387 | if( 1 == option_verbose && unmet_dep_count > 0 ) |
| 388 | { |
| 389 | mbedtls_fprintf( stdout, " Unmet dependencies: " ); |
| 390 | while( unmet_dep_count > 0) |
| 391 | { |
| 392 | mbedtls_fprintf(stdout, "%s ", |
| 393 | unmet_dependencies[unmet_dep_count - 1]); |
| 394 | free(unmet_dependencies[unmet_dep_count - 1]); |
| 395 | unmet_dep_count--; |
| 396 | } |
| 397 | mbedtls_fprintf( stdout, "\n" ); |
| 398 | } |
Simon Butcher | aad787f | 2016-01-26 22:13:58 +0000 | [diff] [blame] | 399 | fflush( stdout ); |
| 400 | } |
SimonB | 8ca7bc4 | 2016-04-17 23:24:50 +0100 | [diff] [blame^] | 401 | else if( ret == DISPATCH_TEST_SUCCESS && test_errors == 0 ) |
Simon Butcher | aad787f | 2016-01-26 22:13:58 +0000 | [diff] [blame] | 402 | { |
| 403 | mbedtls_fprintf( stdout, "PASS\n" ); |
| 404 | fflush( stdout ); |
| 405 | } |
SimonB | 8ca7bc4 | 2016-04-17 23:24:50 +0100 | [diff] [blame^] | 406 | else if( ret == DISPATCH_INVALID_TEST_DATA ) |
Simon Butcher | aad787f | 2016-01-26 22:13:58 +0000 | [diff] [blame] | 407 | { |
| 408 | mbedtls_fprintf( stderr, "FAILED: FATAL PARSE ERROR\n" ); |
| 409 | fclose(file); |
| 410 | mbedtls_exit( 2 ); |
| 411 | } |
| 412 | else |
| 413 | total_errors++; |
| 414 | |
| 415 | if( ( ret = get_line( file, buf, sizeof(buf) ) ) != 0 ) |
| 416 | break; |
| 417 | if( strlen(buf) != 0 ) |
| 418 | { |
| 419 | mbedtls_fprintf( stderr, "Should be empty %d\n", |
| 420 | (int) strlen(buf) ); |
| 421 | return( 1 ); |
| 422 | } |
Paul Bakker | 1934318 | 2013-08-16 13:31:10 +0200 | [diff] [blame] | 423 | } |
Simon Butcher | aad787f | 2016-01-26 22:13:58 +0000 | [diff] [blame] | 424 | fclose(file); |
Paul Bakker | 1934318 | 2013-08-16 13:31:10 +0200 | [diff] [blame] | 425 | } |
Paul Bakker | 1934318 | 2013-08-16 13:31:10 +0200 | [diff] [blame] | 426 | |
Manuel Pégourié-Gonnard | 2cf5a7c | 2015-04-08 12:49:31 +0200 | [diff] [blame] | 427 | mbedtls_fprintf( stdout, "\n----------------------------------------------------------------------------\n\n"); |
Paul Bakker | 1934318 | 2013-08-16 13:31:10 +0200 | [diff] [blame] | 428 | if( total_errors == 0 ) |
Manuel Pégourié-Gonnard | 2cf5a7c | 2015-04-08 12:49:31 +0200 | [diff] [blame] | 429 | mbedtls_fprintf( stdout, "PASSED" ); |
Paul Bakker | 1934318 | 2013-08-16 13:31:10 +0200 | [diff] [blame] | 430 | else |
Manuel Pégourié-Gonnard | 2cf5a7c | 2015-04-08 12:49:31 +0200 | [diff] [blame] | 431 | mbedtls_fprintf( stdout, "FAILED" ); |
Paul Bakker | 1934318 | 2013-08-16 13:31:10 +0200 | [diff] [blame] | 432 | |
Manuel Pégourié-Gonnard | 2cf5a7c | 2015-04-08 12:49:31 +0200 | [diff] [blame] | 433 | mbedtls_fprintf( stdout, " (%d / %d tests (%d skipped))\n", |
Paul Bakker | 1934318 | 2013-08-16 13:31:10 +0200 | [diff] [blame] | 434 | total_tests - total_errors, total_tests, total_skipped ); |
| 435 | |
Manuel Pégourié-Gonnard | 2cf5a7c | 2015-04-08 12:49:31 +0200 | [diff] [blame] | 436 | #if defined(MBEDTLS_MEMORY_BUFFER_ALLOC_C) && \ |
Manuel Pégourié-Gonnard | 765bb31 | 2014-11-27 11:55:27 +0100 | [diff] [blame] | 437 | !defined(TEST_SUITE_MEMORY_BUFFER_ALLOC) |
Manuel Pégourié-Gonnard | 2cf5a7c | 2015-04-08 12:49:31 +0200 | [diff] [blame] | 438 | #if defined(MBEDTLS_MEMORY_DEBUG) |
| 439 | mbedtls_memory_buffer_alloc_status(); |
Paul Bakker | 1934318 | 2013-08-16 13:31:10 +0200 | [diff] [blame] | 440 | #endif |
Manuel Pégourié-Gonnard | 2cf5a7c | 2015-04-08 12:49:31 +0200 | [diff] [blame] | 441 | mbedtls_memory_buffer_alloc_free(); |
Paul Bakker | 1337aff | 2013-09-29 14:45:34 +0200 | [diff] [blame] | 442 | #endif |
Paul Bakker | 1934318 | 2013-08-16 13:31:10 +0200 | [diff] [blame] | 443 | |
| 444 | return( total_errors != 0 ); |
| 445 | } |
| 446 | |