Add mbedtls_ prefix to all public names in helpers.h

Adds the `mbedtls_` prefix to `test_result_t` and `test_info` and updates
any references to them. This is to follow the naming convention as these are
now declared in a public namespace.

Signed-off-by: Chris Jones <christopher.jones@arm.com>
This commit is contained in:
Chris Jones 2021-01-20 17:51:47 +00:00
parent 9634bb10d9
commit e60e2aeb74
5 changed files with 40 additions and 38 deletions

View File

@ -51,21 +51,21 @@
typedef enum typedef enum
{ {
TEST_RESULT_SUCCESS = 0, MBEDTLS_TEST_RESULT_SUCCESS = 0,
TEST_RESULT_FAILED, MBEDTLS_TEST_RESULT_FAILED,
TEST_RESULT_SKIPPED MBEDTLS_TEST_RESULT_SKIPPED
} test_result_t; } mbedtls_test_result_t;
typedef struct typedef struct
{ {
test_result_t result; mbedtls_test_result_t result;
const char *test; const char *test;
const char *filename; const char *filename;
int line_no; int line_no;
unsigned long step; unsigned long step;
} }
test_info_t; mbedtls_test_info_t;
extern test_info_t test_info; extern mbedtls_test_info_t mbedtls_test_info;
int mbedtls_test_platform_setup( void ); int mbedtls_test_platform_setup( void );
void mbedtls_test_platform_teardown( void ); void mbedtls_test_platform_teardown( void );

View File

@ -44,7 +44,7 @@ static param_failed_ctx_t param_failed_ctx;
static mbedtls_platform_context platform_ctx; static mbedtls_platform_context platform_ctx;
#endif #endif
test_info_t test_info; mbedtls_test_info_t mbedtls_test_info;
/*----------------------------------------------------------------------------*/ /*----------------------------------------------------------------------------*/
/* Helper Functions */ /* Helper Functions */
@ -81,29 +81,29 @@ static int ascii2uc(const char c, unsigned char *uc)
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 )
{ {
if( test_info.result == TEST_RESULT_FAILED ) if( mbedtls_test_info.result == MBEDTLS_TEST_RESULT_FAILED )
{ {
/* We've already recorded the test as having failed. Don't /* We've already recorded the test as having failed. Don't
* overwrite any previous information about the failure. */ * overwrite any previous information about the failure. */
return; return;
} }
test_info.result = TEST_RESULT_FAILED; mbedtls_test_info.result = MBEDTLS_TEST_RESULT_FAILED;
test_info.test = test; mbedtls_test_info.test = test;
test_info.line_no = line_no; mbedtls_test_info.line_no = line_no;
test_info.filename = filename; mbedtls_test_info.filename = filename;
} }
void mbedtls_test_set_step( unsigned long step ) void mbedtls_test_set_step( unsigned long step )
{ {
test_info.step = 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 )
{ {
test_info.result = TEST_RESULT_SKIPPED; mbedtls_test_info.result = MBEDTLS_TEST_RESULT_SKIPPED;
test_info.test = test; mbedtls_test_info.test = test;
test_info.line_no = line_no; mbedtls_test_info.line_no = line_no;
test_info.filename = filename; mbedtls_test_info.filename = filename;
} }
int mbedtls_test_unhexify( unsigned char *obuf, int mbedtls_test_unhexify( unsigned char *obuf,

View File

@ -428,15 +428,15 @@ static void write_outcome_entry( FILE *outcome_file,
* \param unmet_dependencies The array of unmet dependencies. * \param unmet_dependencies The array of unmet dependencies.
* \param missing_unmet_dependencies Non-zero if there was a problem tracking * \param missing_unmet_dependencies Non-zero if there was a problem tracking
* all unmet dependencies, 0 otherwise. * all unmet dependencies, 0 otherwise.
* \param ret The test dispatch status (DISPATCH_xxx). * \param ret The test dispatch status (DISPATCH_xxx).
* \param test_info A pointer to the test info structure. * \param mbedtls_test_info A pointer to the test info structure.
*/ */
static void write_outcome_result( FILE *outcome_file, static void write_outcome_result( FILE *outcome_file,
size_t unmet_dep_count, size_t unmet_dep_count,
int unmet_dependencies[], int unmet_dependencies[],
int missing_unmet_dependencies, int missing_unmet_dependencies,
int ret, int ret,
const test_info_t *info ) const mbedtls_test_info_t *info )
{ {
if( outcome_file == NULL ) if( outcome_file == NULL )
return; return;
@ -462,10 +462,10 @@ static void write_outcome_result( FILE *outcome_file,
} }
switch( info->result ) switch( info->result )
{ {
case TEST_RESULT_SUCCESS: case MBEDTLS_TEST_RESULT_SUCCESS:
mbedtls_fprintf( outcome_file, "PASS;" ); mbedtls_fprintf( outcome_file, "PASS;" );
break; break;
case TEST_RESULT_SKIPPED: case MBEDTLS_TEST_RESULT_SKIPPED:
mbedtls_fprintf( outcome_file, "SKIP;Runtime skip" ); mbedtls_fprintf( outcome_file, "SKIP;Runtime skip" );
break; break;
default: default:
@ -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( &test_info, 0, sizeof( test_info ) ); memset( &mbedtls_test_info, 0, sizeof( mbedtls_test_info ) );
/* 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;
@ -638,7 +638,8 @@ int execute_tests( int argc , const char ** argv )
if( ( ret = get_line( file, buf, sizeof(buf) ) ) != 0 ) if( ( ret = get_line( file, buf, sizeof(buf) ) ) != 0 )
break; break;
mbedtls_fprintf( stdout, "%s%.66s", mbedtls_fprintf( stdout, "%s%.66s",
test_info.result == TEST_RESULT_FAILED ? "\n" : "", buf ); mbedtls_test_info.result == MBEDTLS_TEST_RESULT_FAILED ?
"\n" : "", buf );
mbedtls_fprintf( stdout, " " ); mbedtls_fprintf( stdout, " " );
for( i = strlen( buf ) + 1; i < 67; i++ ) for( i = strlen( buf ) + 1; i < 67; i++ )
mbedtls_fprintf( stdout, "." ); mbedtls_fprintf( stdout, "." );
@ -682,8 +683,8 @@ 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 )
{ {
test_info.result = TEST_RESULT_SUCCESS; mbedtls_test_info.result = MBEDTLS_TEST_RESULT_SUCCESS;
test_info.step = (unsigned long)( -1 ); 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
@ -723,7 +724,7 @@ int execute_tests( int argc , const char ** argv )
write_outcome_result( outcome_file, write_outcome_result( outcome_file,
unmet_dep_count, unmet_dependencies, unmet_dep_count, unmet_dependencies,
missing_unmet_dependencies, missing_unmet_dependencies,
ret, &test_info ); ret, &mbedtls_test_info );
if( unmet_dep_count > 0 || ret == DISPATCH_UNSUPPORTED_SUITE ) if( unmet_dep_count > 0 || ret == DISPATCH_UNSUPPORTED_SUITE )
{ {
total_skipped++; total_skipped++;
@ -753,11 +754,11 @@ int execute_tests( int argc , const char ** argv )
} }
else if( ret == DISPATCH_TEST_SUCCESS ) else if( ret == DISPATCH_TEST_SUCCESS )
{ {
if( test_info.result == TEST_RESULT_SUCCESS ) if( mbedtls_test_info.result == MBEDTLS_TEST_RESULT_SUCCESS )
{ {
mbedtls_fprintf( stdout, "PASS\n" ); mbedtls_fprintf( stdout, "PASS\n" );
} }
else if( test_info.result == TEST_RESULT_SKIPPED ) else if( mbedtls_test_info.result == MBEDTLS_TEST_RESULT_SKIPPED )
{ {
mbedtls_fprintf( stdout, "----\n" ); mbedtls_fprintf( stdout, "----\n" );
total_skipped++; total_skipped++;
@ -767,14 +768,15 @@ int execute_tests( int argc , const char ** argv )
total_errors++; total_errors++;
mbedtls_fprintf( stdout, "FAILED\n" ); mbedtls_fprintf( stdout, "FAILED\n" );
mbedtls_fprintf( stdout, " %s\n at ", mbedtls_fprintf( stdout, " %s\n at ",
test_info.test ); mbedtls_test_info.test );
if( test_info.step != (unsigned long)( -1 ) ) if( mbedtls_test_info.step != (unsigned long)( -1 ) )
{ {
mbedtls_fprintf( stdout, "step %lu, ", mbedtls_fprintf( stdout, "step %lu, ",
test_info.step ); mbedtls_test_info.step );
} }
mbedtls_fprintf( stdout, "line %d, %s", mbedtls_fprintf( stdout, "line %d, %s",
test_info.line_no, test_info.filename ); mbedtls_test_info.line_no,
mbedtls_test_info.filename );
} }
fflush( stdout ); fflush( stdout );
} }

View File

@ -384,8 +384,8 @@ int execute_tests( int args, const char ** argv )
while ( 1 ) while ( 1 )
{ {
ret = 0; ret = 0;
test_info.result = TEST_RESULT_SUCCESS; mbedtls_test_info.result = MBEDTLS_TEST_RESULT_SUCCESS;
test_info.step = (unsigned long)( -1 ); mbedtls_test_info.step = (unsigned long)( -1 );
data_len = 0; data_len = 0;
data = receive_data( &data_len ); data = receive_data( &data_len );
@ -443,7 +443,7 @@ int execute_tests( int args, const char ** argv )
if ( ret ) if ( ret )
send_failure( ret ); send_failure( ret );
else else
send_status( test_info.result ); send_status( mbedtls_test_info.result );
} }
return( 0 ); return( 0 );
} }

View File

@ -614,7 +614,7 @@ void get_sequence_of( const data_t *input, int tag,
cur = &head; cur = &head;
while( *rest ) while( *rest )
{ {
++test_info.step; ++mbedtls_test_info.step;
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 );