mirror of
https://github.com/yuzu-emu/mbedtls.git
synced 2025-01-23 02:30:59 +00:00
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>
This commit is contained in:
parent
e60e2aeb74
commit
a5ab765832
|
@ -71,6 +71,7 @@ int mbedtls_test_platform_setup( void );
|
||||||
void mbedtls_test_platform_teardown( void );
|
void mbedtls_test_platform_teardown( void );
|
||||||
|
|
||||||
void mbedtls_test_fail( const char *test, int line_no, const char* filename );
|
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.
|
/** 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_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
|
* \brief This function decodes the hexadecimal representation of
|
||||||
|
|
|
@ -93,11 +93,6 @@ void mbedtls_test_fail( const char *test, int line_no, const char* filename )
|
||||||
mbedtls_test_info.filename = 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 )
|
void mbedtls_test_skip( const char *test, int line_no, const char* filename )
|
||||||
{
|
{
|
||||||
mbedtls_test_info.result = MBEDTLS_TEST_RESULT_SKIPPED;
|
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;
|
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,
|
int mbedtls_test_unhexify( unsigned char *obuf,
|
||||||
size_t obufmax,
|
size_t obufmax,
|
||||||
const char *ibuf,
|
const char *ibuf,
|
||||||
|
|
|
@ -601,7 +601,7 @@ int execute_tests( int argc , const char ** argv )
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Initialize the struct that holds information about the last test */
|
/* 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 */
|
/* Now begin to execute the tests in the testfiles */
|
||||||
for ( testfile_index = 0;
|
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 there are no unmet dependencies execute the test
|
||||||
if( unmet_dep_count == 0 )
|
if( unmet_dep_count == 0 )
|
||||||
{
|
{
|
||||||
mbedtls_test_info.result = MBEDTLS_TEST_RESULT_SUCCESS;
|
mbedtls_test_info_reset();
|
||||||
mbedtls_test_info.step = (unsigned long)( -1 );
|
|
||||||
|
|
||||||
#if defined(__unix__) || (defined(__APPLE__) && defined(__MACH__))
|
#if defined(__unix__) || (defined(__APPLE__) && defined(__MACH__))
|
||||||
/* Suppress all output from the library unless we're verbose
|
/* Suppress all output from the library unless we're verbose
|
||||||
|
|
|
@ -384,8 +384,7 @@ int execute_tests( int args, const char ** argv )
|
||||||
while ( 1 )
|
while ( 1 )
|
||||||
{
|
{
|
||||||
ret = 0;
|
ret = 0;
|
||||||
mbedtls_test_info.result = MBEDTLS_TEST_RESULT_SUCCESS;
|
mbedtls_test_info_reset();
|
||||||
mbedtls_test_info.step = (unsigned long)( -1 );
|
|
||||||
data_len = 0;
|
data_len = 0;
|
||||||
|
|
||||||
data = receive_data( &data_len );
|
data = receive_data( &data_len );
|
||||||
|
|
|
@ -614,7 +614,7 @@ void get_sequence_of( const data_t *input, int tag,
|
||||||
cur = &head;
|
cur = &head;
|
||||||
while( *rest )
|
while( *rest )
|
||||||
{
|
{
|
||||||
++mbedtls_test_info.step;
|
mbedtls_test_set_step( mbedtls_test_info.step + 1 );
|
||||||
TEST_ASSERT( cur != NULL );
|
TEST_ASSERT( cur != NULL );
|
||||||
TEST_EQUAL( cur->buf.tag, tag );
|
TEST_EQUAL( cur->buf.tag, tag );
|
||||||
n = strtoul( rest, (char **) &rest, 0 );
|
n = strtoul( rest, (char **) &rest, 0 );
|
||||||
|
|
Loading…
Reference in a new issue