1
0
mirror of https://github.com/Mbed-TLS/mbedtls.git synced 2025-12-18 17:14:12 +03:00

Merge pull request #4054 from chris-jones-arm/move-testing-functions

Move test infrastructure from `tests/suites/helpers.function` into `tests/src/helpers.c`
This commit is contained in:
Ronald Cron
2021-02-03 19:01:54 +01:00
committed by GitHub
11 changed files with 163 additions and 110 deletions

View File

@@ -44,6 +44,8 @@ static param_failed_ctx_t param_failed_ctx;
static mbedtls_platform_context platform_ctx;
#endif
mbedtls_test_info_t mbedtls_test_info;
/*----------------------------------------------------------------------------*/
/* Helper Functions */
@@ -77,6 +79,42 @@ static int ascii2uc(const char c, unsigned char *uc)
return( 0 );
}
void mbedtls_test_fail( const char *test, int line_no, const char* filename )
{
if( mbedtls_test_info.result == MBEDTLS_TEST_RESULT_FAILED )
{
/* We've already recorded the test as having failed. Don't
* overwrite any previous information about the failure. */
return;
}
mbedtls_test_info.result = MBEDTLS_TEST_RESULT_FAILED;
mbedtls_test_info.test = test;
mbedtls_test_info.line_no = line_no;
mbedtls_test_info.filename = 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.test = test;
mbedtls_test_info.line_no = line_no;
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,