From fe285f53e6f5ce8a23a2ea7cbf8ae851d56d9b52 Mon Sep 17 00:00:00 2001 From: Chris Jones Date: Mon, 8 Feb 2021 12:32:41 +0000 Subject: [PATCH] Make mbedtls_test_err_add_check fail tests Previously an error message was printed and then the test manually exited via `mbedtls_exit( 1 )`. This commit includes a rebase onto: 540320bf7b5de6d3dbd78abb3e5527674189d09c so that `mbedtls_test_fail` can be used instead to properly fail tests (and report them as such). Signed-off-by: Chris Jones --- tests/src/helpers.c | 22 +++++++--------------- 1 file changed, 7 insertions(+), 15 deletions(-) diff --git a/tests/src/helpers.c b/tests/src/helpers.c index 9c981de672..8319e9004a 100644 --- a/tests/src/helpers.c +++ b/tests/src/helpers.c @@ -289,33 +289,25 @@ void mbedtls_test_err_add_check( int high, int low, { if ( high > -0x1000 ) { - mbedtls_fprintf( stderr, "\n'high' is not a high-level error code - " - "%s:%d\n", file, line ); - mbedtls_exit( 1 ); + mbedtls_test_fail( "'high' is not a high-level error code", + line, file ); } else if ( high < -0x7F80 ) { - mbedtls_fprintf( stderr, "\n'high' is greater than 16-bits - " - "%s:%d\n", file, line ); - mbedtls_exit( 1 ); + mbedtls_test_fail( "'high' is greater than 16-bits", line, file ); } else if ( ( high & 0x7F ) != 0 ) { - mbedtls_fprintf( stderr, "\n'high' contains a low-level error code - " - "%s:%d\n", file, line ); - mbedtls_exit( 1 ); + mbedtls_test_fail( "'high' contains a low-level error code", + line, file ); } else if ( low < -0x007F ) { - mbedtls_fprintf( stderr, "\n'low' is greater than 8-bits - " - "%s:%d\n", file, line ); - mbedtls_exit( 1 ); + mbedtls_test_fail( "'low' is greater than 8-bits", line, file ); } else if ( low > 0 ) { - mbedtls_fprintf( stderr, "\n'low' is zero or greater - " - "%s:%d\n", file, line ); - mbedtls_exit( 1 ); + mbedtls_test_fail( "'low' is zero or greater", line, file ); } } #endif /* MBEDTLS_TEST_HOOKS */