mirror of
https://github.com/yuzu-emu/mbedtls.git
synced 2024-12-23 23:25:29 +00:00
Report step number when a test case fails
Allow test code to declare a "step number". Report the current step number when a test fails.
This commit is contained in:
parent
18c7b9fdaa
commit
5605591cc1
|
@ -393,6 +393,7 @@ static struct
|
|||
const char *test;
|
||||
const char *filename;
|
||||
int line_no;
|
||||
unsigned long step;
|
||||
}
|
||||
test_info;
|
||||
|
||||
|
@ -423,6 +424,19 @@ jmp_buf jmp_tmp;
|
|||
/*----------------------------------------------------------------------------*/
|
||||
/* Helper Functions */
|
||||
|
||||
/** Set the test step number for failure reports.
|
||||
*
|
||||
* Call this function to display "step NNN" in addition to the line number
|
||||
* and file name if a test fails. Typically the "step number" is the index
|
||||
* of a for loop but it can be whatever you want.
|
||||
*
|
||||
* \param step The step number to report.
|
||||
*/
|
||||
void test_set_step( unsigned long step )
|
||||
{
|
||||
test_info.step = step;
|
||||
}
|
||||
|
||||
void test_fail( const char *test, int line_no, const char* filename )
|
||||
{
|
||||
test_info.result = TEST_RESULT_FAILED;
|
||||
|
|
|
@ -548,6 +548,7 @@ int execute_tests( int argc , const char ** argv )
|
|||
{
|
||||
test_info.result = TEST_RESULT_SUCCESS;
|
||||
test_info.paramfail_test_state = PARAMFAIL_TESTSTATE_IDLE;
|
||||
test_info.step = (unsigned long)( -1 );
|
||||
|
||||
#if defined(__unix__) || (defined(__APPLE__) && defined(__MACH__))
|
||||
/* Suppress all output from the library unless we're verbose
|
||||
|
@ -624,9 +625,15 @@ int execute_tests( int argc , const char ** argv )
|
|||
{
|
||||
total_errors++;
|
||||
mbedtls_fprintf( stdout, "FAILED\n" );
|
||||
mbedtls_fprintf( stdout, " %s\n at line %d, %s\n",
|
||||
test_info.test, test_info.line_no,
|
||||
test_info.filename );
|
||||
mbedtls_fprintf( stdout, " %s\n at ",
|
||||
test_info.test );
|
||||
if( test_info.step != (unsigned long)( -1 ) )
|
||||
{
|
||||
mbedtls_fprintf( stdout, "step %lu, ",
|
||||
test_info.step );
|
||||
}
|
||||
mbedtls_fprintf( stdout, "line %d, %s",
|
||||
test_info.line_no, test_info.filename );
|
||||
}
|
||||
fflush( stdout );
|
||||
}
|
||||
|
|
|
@ -375,6 +375,7 @@ int execute_tests( int args, const char ** argv )
|
|||
{
|
||||
ret = 0;
|
||||
test_info.result = TEST_RESULT_SUCCESS;
|
||||
test_info.step = (unsigned long)( -1 );
|
||||
data_len = 0;
|
||||
|
||||
data = receive_data( &data_len );
|
||||
|
|
Loading…
Reference in a new issue