Remove direct writing to `test_info` from `*.function`
Add a new function `mbedtls_test_info_reset()` to remove direct writes to
`mbedtls_test_info`. This change still allows values to be read directly
however all writes are now done inside of `helpers.c`.
Also slightly reordered code to make it easier to read.
Signed-off-by: Chris Jones <christopher.jones@arm.com>
diff --git a/tests/suites/host_test.function b/tests/suites/host_test.function
index b5581b5..f345408 100644
--- a/tests/suites/host_test.function
+++ b/tests/suites/host_test.function
@@ -601,7 +601,7 @@
}
/* 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 @@
// 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 7866dcf..8afe70e 100644
--- a/tests/suites/target_test.function
+++ b/tests/suites/target_test.function
@@ -384,8 +384,7 @@
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 75c3fd4..21b3ab6 100644
--- a/tests/suites/test_suite_asn1parse.function
+++ b/tests/suites/test_suite_asn1parse.function
@@ -614,7 +614,7 @@
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 );