blob: fe49bdfd8056acc0dcd37b8a596bbb159c3f4f88 [file] [log] [blame]
SimonB15942102016-04-25 21:34:49 +01001#line 1 "main_test.function"
Paul Bakkerde56ca12013-09-15 17:05:21 +02002SUITE_PRE_DEP
3#define TEST_SUITE_ACTIVE
4
Paul Bakker19343182013-08-16 13:31:10 +02005int verify_string( char **str )
6{
7 if( (*str)[0] != '"' ||
8 (*str)[strlen( *str ) - 1] != '"' )
9 {
Simon Butcher25731362016-09-30 13:11:29 +010010 mbedtls_fprintf( stderr,
11 "Expected string (with \"\") for parameter and got: %s\n", *str );
Paul Bakker19343182013-08-16 13:31:10 +020012 return( -1 );
13 }
14
15 (*str)++;
16 (*str)[strlen( *str ) - 1] = '\0';
17
18 return( 0 );
19}
20
21int verify_int( char *str, int *value )
22{
23 size_t i;
24 int minus = 0;
25 int digits = 1;
26 int hex = 0;
27
28 for( i = 0; i < strlen( str ); i++ )
29 {
30 if( i == 0 && str[i] == '-' )
31 {
32 minus = 1;
33 continue;
34 }
35
36 if( ( ( minus && i == 2 ) || ( !minus && i == 1 ) ) &&
37 str[i - 1] == '0' && str[i] == 'x' )
38 {
39 hex = 1;
40 continue;
41 }
42
Manuel Pégourié-Gonnard725afd82014-02-01 11:54:28 +010043 if( ! ( ( str[i] >= '0' && str[i] <= '9' ) ||
44 ( hex && ( ( str[i] >= 'a' && str[i] <= 'f' ) ||
45 ( str[i] >= 'A' && str[i] <= 'F' ) ) ) ) )
Paul Bakker19343182013-08-16 13:31:10 +020046 {
47 digits = 0;
48 break;
49 }
50 }
51
52 if( digits )
53 {
54 if( hex )
55 *value = strtol( str, NULL, 16 );
56 else
57 *value = strtol( str, NULL, 10 );
58
59 return( 0 );
60 }
61
62MAPPING_CODE
63
Simon Butcher25731362016-09-30 13:11:29 +010064 mbedtls_fprintf( stderr,
65 "Expected integer for parameter and got: %s\n", str );
SimonB8ca7bc42016-04-17 23:24:50 +010066 return( KEY_VALUE_MAPPING_NOT_FOUND );
Paul Bakker19343182013-08-16 13:31:10 +020067}
68
SimonB152ea182016-02-15 23:27:28 +000069
70/*----------------------------------------------------------------------------*/
71/* Test Case code */
72
Paul Bakkerde56ca12013-09-15 17:05:21 +020073FUNCTION_CODE
74SUITE_POST_DEP
75
SimonB15942102016-04-25 21:34:49 +010076#line !LINE_NO! "main_test.function"
77
SimonB152ea182016-02-15 23:27:28 +000078
79/*----------------------------------------------------------------------------*/
80/* Test dispatch code */
81
Paul Bakker19343182013-08-16 13:31:10 +020082int dep_check( char *str )
83{
84 if( str == NULL )
85 return( 1 );
86
87DEP_CHECK_CODE
Simon Butcher65b1fa62016-05-23 23:18:26 +010088#line !LINE_NO! "main_test.function"
Paul Bakker19343182013-08-16 13:31:10 +020089
SimonB8ca7bc42016-04-17 23:24:50 +010090 return( DEPENDENCY_NOT_SUPPORTED );
Paul Bakker19343182013-08-16 13:31:10 +020091}
92
Paul Bakker19343182013-08-16 13:31:10 +020093int dispatch_test(int cnt, char *params[50])
94{
95 int ret;
Paul Bakkerb34fef22013-08-20 12:06:33 +020096 ((void) cnt);
97 ((void) params);
Paul Bakker19343182013-08-16 13:31:10 +020098
Paul Bakkerb34fef22013-08-20 12:06:33 +020099#if defined(TEST_SUITE_ACTIVE)
SimonB8ca7bc42016-04-17 23:24:50 +0100100 ret = DISPATCH_TEST_SUCCESS;
101
Simon Butcher65b1fa62016-05-23 23:18:26 +0100102 // Cast to void to avoid compiler warnings
103 (void)ret;
104
Paul Bakker19343182013-08-16 13:31:10 +0200105DISPATCH_FUNCTION
106 {
Simon Butcher65b1fa62016-05-23 23:18:26 +0100107#line !LINE_NO! "main_test.function"
SimonB8ca7bc42016-04-17 23:24:50 +0100108 mbedtls_fprintf( stdout,
109 "FAILED\nSkipping unknown test function '%s'\n",
110 params[0] );
Paul Bakker19343182013-08-16 13:31:10 +0200111 fflush( stdout );
SimonB8ca7bc42016-04-17 23:24:50 +0100112 ret = DISPATCH_TEST_FN_NOT_FOUND;
Paul Bakker19343182013-08-16 13:31:10 +0200113 }
Paul Bakkerb34fef22013-08-20 12:06:33 +0200114#else
SimonB8ca7bc42016-04-17 23:24:50 +0100115 ret = DISPATCH_UNSUPPORTED_SUITE;
Paul Bakkerb34fef22013-08-20 12:06:33 +0200116#endif
Paul Bakker19343182013-08-16 13:31:10 +0200117 return( ret );
118}
119
SimonB152ea182016-02-15 23:27:28 +0000120
121/*----------------------------------------------------------------------------*/
122/* Main Test code */
123
SimonB15942102016-04-25 21:34:49 +0100124#line !LINE_NO! "main_test.function"
125
SimonB8ca7bc42016-04-17 23:24:50 +0100126#define USAGE \
127 "Usage: %s [OPTIONS] files...\n\n" \
128 " Command line arguments:\n" \
129 " files... One or more test data file. If no file is specified\n" \
130 " the followimg default test case is used:\n" \
131 " %s\n\n" \
132 " Options:\n" \
133 " -v | --verbose Display full information about each test\n" \
134 " -h | --help Display this information\n\n", \
135 argv[0], \
SimonB15942102016-04-25 21:34:49 +0100136 "TESTCASE_FILENAME"
SimonB8ca7bc42016-04-17 23:24:50 +0100137
138
Paul Bakker19343182013-08-16 13:31:10 +0200139int get_line( FILE *f, char *buf, size_t len )
140{
141 char *ret;
142
143 ret = fgets( buf, len, f );
144 if( ret == NULL )
145 return( -1 );
146
147 if( strlen( buf ) && buf[strlen(buf) - 1] == '\n' )
148 buf[strlen(buf) - 1] = '\0';
149 if( strlen( buf ) && buf[strlen(buf) - 1] == '\r' )
150 buf[strlen(buf) - 1] = '\0';
151
152 return( 0 );
153}
154
155int parse_arguments( char *buf, size_t len, char *params[50] )
156{
157 int cnt = 0, i;
158 char *cur = buf;
159 char *p = buf, *q;
160
161 params[cnt++] = cur;
162
163 while( *p != '\0' && p < buf + len )
164 {
165 if( *p == '\\' )
166 {
Manuel Pégourié-Gonnard2d5f1422014-01-22 16:01:17 +0100167 p++;
168 p++;
Paul Bakker19343182013-08-16 13:31:10 +0200169 continue;
170 }
171 if( *p == ':' )
172 {
173 if( p + 1 < buf + len )
174 {
175 cur = p + 1;
176 params[cnt++] = cur;
177 }
178 *p = '\0';
179 }
180
Manuel Pégourié-Gonnard2d5f1422014-01-22 16:01:17 +0100181 p++;
Paul Bakker19343182013-08-16 13:31:10 +0200182 }
183
SimonB0269dad2016-02-17 23:34:30 +0000184 /* Replace newlines, question marks and colons in strings */
Paul Bakker19343182013-08-16 13:31:10 +0200185 for( i = 0; i < cnt; i++ )
186 {
187 p = params[i];
188 q = params[i];
189
190 while( *p != '\0' )
191 {
192 if( *p == '\\' && *(p + 1) == 'n' )
193 {
194 p += 2;
195 *(q++) = '\n';
196 }
197 else if( *p == '\\' && *(p + 1) == ':' )
198 {
199 p += 2;
200 *(q++) = ':';
201 }
202 else if( *p == '\\' && *(p + 1) == '?' )
203 {
204 p += 2;
205 *(q++) = '?';
206 }
207 else
208 *(q++) = *(p++);
209 }
210 *q = '\0';
211 }
212
213 return( cnt );
214}
215
Manuel Pégourié-Gonnard7b6dcbe2015-06-22 10:48:01 +0200216static int test_snprintf( size_t n, const char ref_buf[10], int ref_ret )
217{
218 int ret;
219 char buf[10] = "xxxxxxxxx";
Manuel Pégourié-Gonnard4b00f082015-06-26 11:24:32 +0200220 const char ref[10] = "xxxxxxxxx";
Manuel Pégourié-Gonnard7b6dcbe2015-06-22 10:48:01 +0200221
222 ret = mbedtls_snprintf( buf, n, "%s", "123" );
223 if( ret < 0 || (size_t) ret >= n )
224 ret = -1;
225
Manuel Pégourié-Gonnard4b00f082015-06-26 11:24:32 +0200226 if( strncmp( ref_buf, buf, sizeof( buf ) ) != 0 ||
227 ref_ret != ret ||
228 memcmp( buf + n, ref + n, sizeof( buf ) - n ) != 0 )
Manuel Pégourié-Gonnard7b6dcbe2015-06-22 10:48:01 +0200229 {
230 return( 1 );
231 }
232
233 return( 0 );
234}
235
236static int run_test_snprintf( void )
237{
238 return( test_snprintf( 0, "xxxxxxxxx", -1 ) != 0 ||
Manuel Pégourié-Gonnard4b00f082015-06-26 11:24:32 +0200239 test_snprintf( 1, "", -1 ) != 0 ||
240 test_snprintf( 2, "1", -1 ) != 0 ||
241 test_snprintf( 3, "12", -1 ) != 0 ||
242 test_snprintf( 4, "123", 3 ) != 0 ||
243 test_snprintf( 5, "123", 3 ) != 0 );
Manuel Pégourié-Gonnard7b6dcbe2015-06-22 10:48:01 +0200244}
245
Simon Butcheraad787f2016-01-26 22:13:58 +0000246int main(int argc, const char *argv[])
Paul Bakker19343182013-08-16 13:31:10 +0200247{
SimonB8ca7bc42016-04-17 23:24:50 +0100248 /* Local Configurations and options */
SimonB15942102016-04-25 21:34:49 +0100249 const char *default_filename = "TESTCASE_FILENAME";
Simon Butcheraad787f2016-01-26 22:13:58 +0000250 const char *test_filename = NULL;
251 const char **test_files = NULL;
SimonB8ca7bc42016-04-17 23:24:50 +0100252 int testfile_count = 0;
253 int option_verbose = 0;
254
255 /* Other Local variables */
256 int arg_index = 1;
257 const char *next_arg;
258 int testfile_index, ret, i, cnt;
259 int total_errors = 0, total_tests = 0, total_skipped = 0;
Paul Bakker19343182013-08-16 13:31:10 +0200260 FILE *file;
261 char buf[5000];
262 char *params[50];
Manuel Pégourié-Gonnardd14acbc2015-05-29 11:26:37 +0200263 void *pointer;
Andres AGea67eeb2016-11-02 10:17:00 +0000264#if defined(__unix__) || (defined(__APPLE__) && defined(__MACH__))
Simon Butchere0192962016-10-12 23:07:30 +0100265 int stdout_fd = -1;
Andres AGea67eeb2016-11-02 10:17:00 +0000266#endif /* __unix__ || __APPLE__ __MACH__ */
Paul Bakker19343182013-08-16 13:31:10 +0200267
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200268#if defined(MBEDTLS_MEMORY_BUFFER_ALLOC_C) && \
Manuel Pégourié-Gonnard765bb312014-11-27 11:55:27 +0100269 !defined(TEST_SUITE_MEMORY_BUFFER_ALLOC)
Paul Bakker1337aff2013-09-29 14:45:34 +0200270 unsigned char alloc_buf[1000000];
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200271 mbedtls_memory_buffer_alloc_init( alloc_buf, sizeof(alloc_buf) );
Paul Bakker19343182013-08-16 13:31:10 +0200272#endif
273
Manuel Pégourié-Gonnardd14acbc2015-05-29 11:26:37 +0200274 /*
275 * The C standard doesn't guarantee that all-bits-0 is the representation
276 * of a NULL pointer. We do however use that in our code for initializing
277 * structures, which should work on every modern platform. Let's be sure.
278 */
279 memset( &pointer, 0, sizeof( void * ) );
280 if( pointer != NULL )
281 {
282 mbedtls_fprintf( stderr, "all-bits-zero is not a NULL pointer\n" );
283 return( 1 );
284 }
285
Manuel Pégourié-Gonnard7b6dcbe2015-06-22 10:48:01 +0200286 /*
287 * Make sure we have a snprintf that correctly zero-terminates
288 */
289 if( run_test_snprintf() != 0 )
290 {
291 mbedtls_fprintf( stderr, "the snprintf implementation is broken\n" );
292 return( 0 );
293 }
294
SimonB8ca7bc42016-04-17 23:24:50 +0100295 while( arg_index < argc)
296 {
297 next_arg = argv[ arg_index ];
298
299 if( strcmp(next_arg, "--verbose" ) == 0 ||
300 strcmp(next_arg, "-v" ) == 0 )
301 {
302 option_verbose = 1;
303 }
304 else if( strcmp(next_arg, "--help" ) == 0 ||
305 strcmp(next_arg, "-h" ) == 0 )
306 {
307 mbedtls_fprintf( stdout, USAGE );
308 mbedtls_exit( EXIT_SUCCESS );
309 }
310 else
311 {
312 /* Not an option, therefore treat all further arguments as the file
313 * list.
314 */
315 test_files = &argv[ arg_index ];
316 testfile_count = argc - arg_index;
317 }
318
319 arg_index++;
320 }
321
322 /* If no files were specified, assume a default */
323 if ( test_files == NULL || testfile_count == 0 )
Paul Bakker19343182013-08-16 13:31:10 +0200324 {
Simon Butcheraad787f2016-01-26 22:13:58 +0000325 test_files = &default_filename;
326 testfile_count = 1;
327 }
Paul Bakker19343182013-08-16 13:31:10 +0200328
SimonB8ca7bc42016-04-17 23:24:50 +0100329 /* Now begin to execute the tests in the testfiles */
Simon Butcheraad787f2016-01-26 22:13:58 +0000330 for ( testfile_index = 0;
331 testfile_index < testfile_count;
332 testfile_index++ )
Paul Bakker19343182013-08-16 13:31:10 +0200333 {
Paul Bakker774180e2016-05-12 15:59:48 +0100334 int unmet_dep_count = 0;
335 char *unmet_dependencies[20];
336
Simon Butcheraad787f2016-01-26 22:13:58 +0000337 test_filename = test_files[ testfile_index ];
Paul Bakker19343182013-08-16 13:31:10 +0200338
Simon Butcheraad787f2016-01-26 22:13:58 +0000339 file = fopen( test_filename, "r" );
340 if( file == NULL )
Paul Bakker19343182013-08-16 13:31:10 +0200341 {
Simon Butcheraad787f2016-01-26 22:13:58 +0000342 mbedtls_fprintf( stderr, "Failed to open test file: %s\n",
343 test_filename );
344 return( 1 );
345 }
346
347 while( !feof( file ) )
348 {
Paul Bakker774180e2016-05-12 15:59:48 +0100349 if( unmet_dep_count > 0 )
350 {
Simon Butcher25731362016-09-30 13:11:29 +0100351 mbedtls_fprintf( stderr,
Janos Follath8ca53b52016-10-05 10:57:49 +0100352 "FATAL: Dep count larger than zero at start of loop\n" );
Paul Bakker774180e2016-05-12 15:59:48 +0100353 mbedtls_exit( MBEDTLS_EXIT_FAILURE );
354 }
355 unmet_dep_count = 0;
Simon Butcheraad787f2016-01-26 22:13:58 +0000356
357 if( ( ret = get_line( file, buf, sizeof(buf) ) ) != 0 )
358 break;
359 mbedtls_fprintf( stdout, "%s%.66s", test_errors ? "\n" : "", buf );
360 mbedtls_fprintf( stdout, " " );
361 for( i = strlen( buf ) + 1; i < 67; i++ )
362 mbedtls_fprintf( stdout, "." );
363 mbedtls_fprintf( stdout, " " );
364 fflush( stdout );
365
366 total_tests++;
Paul Bakker19343182013-08-16 13:31:10 +0200367
368 if( ( ret = get_line( file, buf, sizeof(buf) ) ) != 0 )
369 break;
370 cnt = parse_arguments( buf, strlen(buf), params );
Paul Bakker19343182013-08-16 13:31:10 +0200371
Simon Butcheraad787f2016-01-26 22:13:58 +0000372 if( strcmp( params[0], "depends_on" ) == 0 )
373 {
374 for( i = 1; i < cnt; i++ )
SimonB8ca7bc42016-04-17 23:24:50 +0100375 {
376 if( dep_check( params[i] ) != DEPENDENCY_SUPPORTED )
377 {
Paul Bakker26b60bf2016-05-12 15:55:37 +0100378 if( 0 == option_verbose )
379 {
380 /* Only one count is needed if not verbose */
381 unmet_dep_count++;
382 break;
383 }
384
Paul Bakkera30a72f2016-05-12 15:52:48 +0100385 unmet_dependencies[ unmet_dep_count ] = strdup(params[i]);
386 if( unmet_dependencies[ unmet_dep_count ] == NULL )
SimonB8ca7bc42016-04-17 23:24:50 +0100387 {
Janos Follath8ca53b52016-10-05 10:57:49 +0100388 mbedtls_fprintf( stderr, "FATAL: Out of memory\n" );
Janos Follath55abc212016-04-18 18:18:48 +0100389 mbedtls_exit( MBEDTLS_EXIT_FAILURE );
SimonB8ca7bc42016-04-17 23:24:50 +0100390 }
391 unmet_dep_count++;
392 }
393 }
Paul Bakker19343182013-08-16 13:31:10 +0200394
Simon Butcheraad787f2016-01-26 22:13:58 +0000395 if( ( ret = get_line( file, buf, sizeof(buf) ) ) != 0 )
396 break;
397 cnt = parse_arguments( buf, strlen(buf), params );
398 }
SimonB8ca7bc42016-04-17 23:24:50 +0100399
400 // If there are no unmet dependencies execute the test
401 if( unmet_dep_count == 0 )
Simon Butcheraad787f2016-01-26 22:13:58 +0000402 {
403 test_errors = 0;
Simon Butcher25731362016-09-30 13:11:29 +0100404
405#if defined(__unix__) || (defined(__APPLE__) && defined(__MACH__))
406 /* Suppress all output from the library unless we're verbose
407 * mode
408 */
409 if( !option_verbose )
410 {
Janos Follath8ca53b52016-10-05 10:57:49 +0100411 stdout_fd = redirect_output( &stdout, "/dev/null" );
412 if( stdout_fd == -1 )
Simon Butcher25731362016-09-30 13:11:29 +0100413 {
414 /* Redirection has failed with no stdout so exit */
Janos Follath8ca53b52016-10-05 10:57:49 +0100415 exit( 1 );
Simon Butcher25731362016-09-30 13:11:29 +0100416 }
417 }
418#endif /* __unix__ || __APPLE__ __MACH__ */
419
Simon Butcheraad787f2016-01-26 22:13:58 +0000420 ret = dispatch_test( cnt, params );
Simon Butcher25731362016-09-30 13:11:29 +0100421
422#if defined(__unix__) || (defined(__APPLE__) && defined(__MACH__))
Janos Follath8ca53b52016-10-05 10:57:49 +0100423 if( !option_verbose && restore_output( &stdout, stdout_fd ) )
Simon Butcher25731362016-09-30 13:11:29 +0100424 {
Simon Butcher25731362016-09-30 13:11:29 +0100425 /* Redirection has failed with no stdout so exit */
Janos Follath8ca53b52016-10-05 10:57:49 +0100426 exit( 1 );
Simon Butcher25731362016-09-30 13:11:29 +0100427 }
428#endif /* __unix__ || __APPLE__ __MACH__ */
429
Simon Butcheraad787f2016-01-26 22:13:58 +0000430 }
431
SimonB8ca7bc42016-04-17 23:24:50 +0100432 if( unmet_dep_count > 0 || ret == DISPATCH_UNSUPPORTED_SUITE )
Simon Butcheraad787f2016-01-26 22:13:58 +0000433 {
434 total_skipped++;
Hanno Becker910f6622017-07-23 10:23:24 +0100435 mbedtls_fprintf( stdout, "----" );
SimonB8ca7bc42016-04-17 23:24:50 +0100436
437 if( 1 == option_verbose && ret == DISPATCH_UNSUPPORTED_SUITE )
438 {
Hanno Becker910f6622017-07-23 10:23:24 +0100439 mbedtls_fprintf( stdout, "\n Test Suite not enabled" );
SimonB8ca7bc42016-04-17 23:24:50 +0100440 }
441
442 if( 1 == option_verbose && unmet_dep_count > 0 )
443 {
Hanno Becker910f6622017-07-23 10:23:24 +0100444 mbedtls_fprintf( stdout, "\n Unmet dependencies: " );
Paul Bakker774180e2016-05-12 15:59:48 +0100445 for( i = 0; i < unmet_dep_count; i++ )
SimonB8ca7bc42016-04-17 23:24:50 +0100446 {
447 mbedtls_fprintf(stdout, "%s ",
Paul Bakker774180e2016-05-12 15:59:48 +0100448 unmet_dependencies[i]);
449 free(unmet_dependencies[i]);
SimonB8ca7bc42016-04-17 23:24:50 +0100450 }
SimonB8ca7bc42016-04-17 23:24:50 +0100451 }
Hanno Becker910f6622017-07-23 10:23:24 +0100452 mbedtls_fprintf( stdout, "\n" );
Simon Butcheraad787f2016-01-26 22:13:58 +0000453 fflush( stdout );
Paul Bakker774180e2016-05-12 15:59:48 +0100454
455 unmet_dep_count = 0;
Simon Butcheraad787f2016-01-26 22:13:58 +0000456 }
SimonB8ca7bc42016-04-17 23:24:50 +0100457 else if( ret == DISPATCH_TEST_SUCCESS && test_errors == 0 )
Simon Butcheraad787f2016-01-26 22:13:58 +0000458 {
459 mbedtls_fprintf( stdout, "PASS\n" );
460 fflush( stdout );
461 }
SimonB8ca7bc42016-04-17 23:24:50 +0100462 else if( ret == DISPATCH_INVALID_TEST_DATA )
Simon Butcheraad787f2016-01-26 22:13:58 +0000463 {
464 mbedtls_fprintf( stderr, "FAILED: FATAL PARSE ERROR\n" );
465 fclose(file);
466 mbedtls_exit( 2 );
467 }
468 else
469 total_errors++;
470
471 if( ( ret = get_line( file, buf, sizeof(buf) ) ) != 0 )
472 break;
473 if( strlen(buf) != 0 )
474 {
475 mbedtls_fprintf( stderr, "Should be empty %d\n",
476 (int) strlen(buf) );
477 return( 1 );
478 }
Paul Bakker19343182013-08-16 13:31:10 +0200479 }
Simon Butcheraad787f2016-01-26 22:13:58 +0000480 fclose(file);
Paul Bakker774180e2016-05-12 15:59:48 +0100481
482 /* In case we encounter early end of file */
483 for( i = 0; i < unmet_dep_count; i++ )
484 free( unmet_dependencies[i] );
Paul Bakker19343182013-08-16 13:31:10 +0200485 }
Paul Bakker19343182013-08-16 13:31:10 +0200486
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200487 mbedtls_fprintf( stdout, "\n----------------------------------------------------------------------------\n\n");
Paul Bakker19343182013-08-16 13:31:10 +0200488 if( total_errors == 0 )
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200489 mbedtls_fprintf( stdout, "PASSED" );
Paul Bakker19343182013-08-16 13:31:10 +0200490 else
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200491 mbedtls_fprintf( stdout, "FAILED" );
Paul Bakker19343182013-08-16 13:31:10 +0200492
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200493 mbedtls_fprintf( stdout, " (%d / %d tests (%d skipped))\n",
Paul Bakker19343182013-08-16 13:31:10 +0200494 total_tests - total_errors, total_tests, total_skipped );
495
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200496#if defined(MBEDTLS_MEMORY_BUFFER_ALLOC_C) && \
Manuel Pégourié-Gonnard765bb312014-11-27 11:55:27 +0100497 !defined(TEST_SUITE_MEMORY_BUFFER_ALLOC)
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200498#if defined(MBEDTLS_MEMORY_DEBUG)
499 mbedtls_memory_buffer_alloc_status();
Paul Bakker19343182013-08-16 13:31:10 +0200500#endif
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200501 mbedtls_memory_buffer_alloc_free();
Paul Bakker1337aff2013-09-29 14:45:34 +0200502#endif
Paul Bakker19343182013-08-16 13:31:10 +0200503
Simon Butchere0192962016-10-12 23:07:30 +0100504#if defined(__unix__) || (defined(__APPLE__) && defined(__MACH__))
505 if( stdout_fd != -1 )
506 close_output( stdout );
507#endif /* __unix__ || __APPLE__ __MACH__ */
508
Paul Bakker19343182013-08-16 13:31:10 +0200509 return( total_errors != 0 );
510}
511