diff --git a/tests/suites/host_test.function b/tests/suites/host_test.function index 9e56ca3ed..b956c0c98 100644 --- a/tests/suites/host_test.function +++ b/tests/suites/host_test.function @@ -525,15 +525,6 @@ int execute_tests( int argc , const char ** argv ) mbedtls_memory_buffer_alloc_init( alloc_buf, sizeof( alloc_buf ) ); #endif - if( outcome_file_name != NULL ) - { - outcome_file = fopen( outcome_file_name, "a" ); - if( outcome_file == NULL ) - { - mbedtls_fprintf( stderr, "Unable to open outcome file. Continuing anyway.\n" ); - } - } - /* * The C standard doesn't guarantee that all-bits-0 is the representation * of a NULL pointer. We do however use that in our code for initializing @@ -555,6 +546,15 @@ int execute_tests( int argc , const char ** argv ) return( 1 ); } + if( outcome_file_name != NULL ) + { + outcome_file = fopen( outcome_file_name, "a" ); + if( outcome_file == NULL ) + { + mbedtls_fprintf( stderr, "Unable to open outcome file. Continuing anyway.\n" ); + } + } + while( arg_index < argc ) { next_arg = argv[arg_index]; @@ -607,6 +607,8 @@ int execute_tests( int argc , const char ** argv ) { mbedtls_fprintf( stderr, "Failed to open test file: %s\n", test_filename ); + if( outcome_file != NULL ) + fclose( outcome_file ); return( 1 ); }