diff --git a/tests/include/test/helpers.h b/tests/include/test/helpers.h index 2ca85d479..258c6bae4 100644 --- a/tests/include/test/helpers.h +++ b/tests/include/test/helpers.h @@ -71,6 +71,7 @@ int mbedtls_test_platform_setup( void ); void mbedtls_test_platform_teardown( void ); void mbedtls_test_fail( const char *test, int line_no, const char* filename ); +void mbedtls_test_skip( const char *test, int line_no, const char* filename ); /** Set the test step number for failure reports. * @@ -82,7 +83,7 @@ void mbedtls_test_fail( const char *test, int line_no, const char* filename ); */ void mbedtls_test_set_step( unsigned long step ); -void mbedtls_test_skip( const char *test, int line_no, const char* filename ); +void mbedtls_test_info_reset( void ); /** * \brief This function decodes the hexadecimal representation of diff --git a/tests/src/helpers.c b/tests/src/helpers.c index 9bfd7e047..e323275e5 100644 --- a/tests/src/helpers.c +++ b/tests/src/helpers.c @@ -93,11 +93,6 @@ void mbedtls_test_fail( const char *test, int line_no, const char* filename ) mbedtls_test_info.filename = filename; } -void mbedtls_test_set_step( unsigned long step ) -{ - mbedtls_test_info.step = step; -} - void mbedtls_test_skip( const char *test, int line_no, const char* filename ) { mbedtls_test_info.result = MBEDTLS_TEST_RESULT_SKIPPED; @@ -106,6 +101,20 @@ void mbedtls_test_skip( const char *test, int line_no, const char* filename ) mbedtls_test_info.filename = filename; } +void mbedtls_test_set_step( unsigned long step ) +{ + mbedtls_test_info.step = step; +} + +void mbedtls_test_info_reset( void ) +{ + mbedtls_test_info.result = MBEDTLS_TEST_RESULT_SUCCESS; + mbedtls_test_info.step = (unsigned long)( -1 ); + mbedtls_test_info.test = 0; + mbedtls_test_info.line_no = 0; + mbedtls_test_info.filename = 0; +} + int mbedtls_test_unhexify( unsigned char *obuf, size_t obufmax, const char *ibuf, diff --git a/tests/suites/host_test.function b/tests/suites/host_test.function index b5581b551..f3454086c 100644 --- a/tests/suites/host_test.function +++ b/tests/suites/host_test.function @@ -601,7 +601,7 @@ int execute_tests( int argc , const char ** argv ) } /* Initialize the struct that holds information about the last test */ - memset( &mbedtls_test_info, 0, sizeof( mbedtls_test_info ) ); + mbedtls_test_info_reset(); /* Now begin to execute the tests in the testfiles */ for ( testfile_index = 0; @@ -683,8 +683,7 @@ int execute_tests( int argc , const char ** argv ) // If there are no unmet dependencies execute the test if( unmet_dep_count == 0 ) { - mbedtls_test_info.result = MBEDTLS_TEST_RESULT_SUCCESS; - mbedtls_test_info.step = (unsigned long)( -1 ); + mbedtls_test_info_reset(); #if defined(__unix__) || (defined(__APPLE__) && defined(__MACH__)) /* Suppress all output from the library unless we're verbose diff --git a/tests/suites/target_test.function b/tests/suites/target_test.function index 7866dcfb3..8afe70eaf 100644 --- a/tests/suites/target_test.function +++ b/tests/suites/target_test.function @@ -384,8 +384,7 @@ int execute_tests( int args, const char ** argv ) while ( 1 ) { ret = 0; - mbedtls_test_info.result = MBEDTLS_TEST_RESULT_SUCCESS; - mbedtls_test_info.step = (unsigned long)( -1 ); + mbedtls_test_info_reset(); data_len = 0; data = receive_data( &data_len ); diff --git a/tests/suites/test_suite_asn1parse.function b/tests/suites/test_suite_asn1parse.function index 75c3fd40c..21b3ab610 100644 --- a/tests/suites/test_suite_asn1parse.function +++ b/tests/suites/test_suite_asn1parse.function @@ -614,7 +614,7 @@ void get_sequence_of( const data_t *input, int tag, cur = &head; while( *rest ) { - ++mbedtls_test_info.step; + mbedtls_test_set_step( mbedtls_test_info.step + 1 ); TEST_ASSERT( cur != NULL ); TEST_EQUAL( cur->buf.tag, tag ); n = strtoul( rest, (char **) &rest, 0 );