From d9be65277d84dd2ebcd66976d80984f0310a9def Mon Sep 17 00:00:00 2001 From: TRodziewicz Date: Mon, 5 Jul 2021 15:16:00 +0200 Subject: [PATCH] Corrections to the new functions names and error message wording Signed-off-by: TRodziewicz --- include/mbedtls/error.h | 2 +- include/mbedtls/mbedtls_config.h | 2 +- library/psa_crypto.c | 4 ++-- library/psa_crypto_slot_management.c | 4 ++-- scripts/data_files/error.fmt | 2 +- tests/include/test/helpers.h | 2 +- tests/src/helpers.c | 4 ++-- tests/suites/main_test.function | 6 +++++- 8 files changed, 15 insertions(+), 11 deletions(-) diff --git a/include/mbedtls/error.h b/include/mbedtls/error.h index d2d31a82a..49a641614 100644 --- a/include/mbedtls/error.h +++ b/include/mbedtls/error.h @@ -129,7 +129,7 @@ extern "C" { * Only used when invasive testing is enabled via MBEDTLS_TEST_HOOKS. */ extern void (*mbedtls_test_hook_error_add)( int, int, const char *, int ); -extern void (*mbedtls_test_hook_value)( int test, const char * file, int line ); +extern void (*mbedtls_test_hook_assert_test)( int test, const char * file, int line ); #endif /** diff --git a/include/mbedtls/mbedtls_config.h b/include/mbedtls/mbedtls_config.h index 1ab0aded1..a60db7e93 100644 --- a/include/mbedtls/mbedtls_config.h +++ b/include/mbedtls/mbedtls_config.h @@ -1683,7 +1683,7 @@ * * Uncomment to enable invasive tests. */ -#define MBEDTLS_TEST_HOOKS +//#define MBEDTLS_TEST_HOOKS /** * \def MBEDTLS_THREADING_ALT diff --git a/library/psa_crypto.c b/library/psa_crypto.c index c7186af97..f5a879361 100644 --- a/library/psa_crypto.c +++ b/library/psa_crypto.c @@ -1003,8 +1003,8 @@ psa_status_t psa_wipe_key_slot( psa_key_slot_t *slot ) if( slot->lock_count != 1 ) { #if defined(MBEDTLS_TEST_HOOKS) - if( *mbedtls_test_hook_value != NULL ) - ( *mbedtls_test_hook_value )( slot->lock_count == 1, __FILE__, __LINE__ ); + if( *mbedtls_test_hook_assert_test != NULL ) + ( *mbedtls_test_hook_assert_test )( slot->lock_count == 1, __FILE__, __LINE__ ); #endif status = PSA_ERROR_CORRUPTION_DETECTED; } diff --git a/library/psa_crypto_slot_management.c b/library/psa_crypto_slot_management.c index 256408dfd..4a0763f00 100644 --- a/library/psa_crypto_slot_management.c +++ b/library/psa_crypto_slot_management.c @@ -416,8 +416,8 @@ psa_status_t psa_unlock_key_slot( psa_key_slot_t *slot ) slot->lock_count = 1; #if defined(MBEDTLS_TEST_HOOKS) - if( *mbedtls_test_hook_value != NULL ) - ( *mbedtls_test_hook_value )( slot->lock_count > 0, __FILE__, __LINE__ ); + if( *mbedtls_test_hook_assert_test != NULL ) + ( *mbedtls_test_hook_assert_test )( slot->lock_count > 0, __FILE__, __LINE__ ); #endif return( PSA_ERROR_CORRUPTION_DETECTED ); diff --git a/scripts/data_files/error.fmt b/scripts/data_files/error.fmt index c2b4b0877..8651a7b39 100644 --- a/scripts/data_files/error.fmt +++ b/scripts/data_files/error.fmt @@ -164,7 +164,7 @@ void mbedtls_strerror( int ret, char *buf, size_t buflen ) #if defined(MBEDTLS_TEST_HOOKS) void (*mbedtls_test_hook_error_add)( int, int, const char *, int ); -void (*mbedtls_test_hook_value)( int, const char *, int ); +void (*mbedtls_test_hook_assert_test)( int, const char *, int ); #endif #endif /* MBEDTLS_ERROR_C || MBEDTLS_ERROR_STRERROR_DUMMY */ diff --git a/tests/include/test/helpers.h b/tests/include/test/helpers.h index 40fcb03dd..8ee699668 100644 --- a/tests/include/test/helpers.h +++ b/tests/include/test/helpers.h @@ -237,7 +237,7 @@ int mbedtls_test_read_mpi( mbedtls_mpi *X, int radix, const char *s ); * \note If the check fails, fail the test currently being run. */ #if defined(MBEDTLS_TEST_HOOKS) -void mbedtls_test_hook_value_check( int test, const char * file, int line ); +void mbedtls_test_assert_test( int test, const char * file, int line ); #endif #endif /* TEST_HELPERS_H */ diff --git a/tests/src/helpers.c b/tests/src/helpers.c index bf25f21ad..e35ed62d6 100644 --- a/tests/src/helpers.c +++ b/tests/src/helpers.c @@ -276,11 +276,11 @@ int mbedtls_test_read_mpi( mbedtls_mpi *X, int radix, const char *s ) #endif #if defined(MBEDTLS_TEST_HOOKS) -void mbedtls_test_hook_value_check( int test, const char * file, int line ) +void mbedtls_test_assert_test( int test, const char * file, int line ) { if ( !test ) { - mbedtls_test_fail( "Wrong value in test", line, file ); + mbedtls_test_fail( "Test hook - test assertion failed.", line, file ); } } #endif diff --git a/tests/suites/main_test.function b/tests/suites/main_test.function index 9ac5a4a31..f34c1bd2f 100644 --- a/tests/suites/main_test.function +++ b/tests/suites/main_test.function @@ -239,9 +239,13 @@ int main( int argc, const char *argv[] ) { #if defined(MBEDTLS_TEST_HOOKS) && defined (MBEDTLS_ERROR_C) mbedtls_test_hook_error_add = &mbedtls_test_err_add_check; - mbedtls_test_hook_value = &mbedtls_test_hook_value_check; #endif +#if defined(MBEDTLS_TEST_HOOKS) + mbedtls_test_hook_assert_test = &mbedtls_test_assert_test; +#endif + + int ret = mbedtls_test_platform_setup(); if( ret != 0 ) {