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:
540320bf7b so that `mbedtls_test_fail` can
be used instead to properly fail tests (and report them as such).

Signed-off-by: Chris Jones <christopher.jones@arm.com>
This commit is contained in:
Chris Jones 2021-02-08 12:32:41 +00:00
parent d86ad60aa5
commit fe285f53e6

View file

@ -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 */