1
0
mirror of https://github.com/Mbed-TLS/mbedtls.git synced 2025-07-29 11:41:15 +03:00

SSL test programs: allow for test hooks init and error reports

Create utility functions to set up test hooks and report errors that
the test hooks might detect. Call them in ssl_client2 and ssl_server2.

Test hooks are potentially enabled by compiling with
MBEDTLS_TEST_HOOKS.

This commit only sets up the functions. It doesn't make them do
anything yet.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
This commit is contained in:
Gilles Peskine
2021-02-02 22:55:06 +01:00
parent 4337a9cb18
commit 53dea743d5
4 changed files with 68 additions and 0 deletions

View File

@ -734,6 +734,8 @@ int main( int argc, char *argv[] )
mbedtls_memory_buffer_alloc_init( alloc_buf, sizeof(alloc_buf) );
#endif
test_hooks_init( );
/*
* Make sure memory references are valid.
*/
@ -3036,6 +3038,14 @@ exit:
mbedtls_free( context_buf );
#endif
if( test_hooks_failure_detected( ) )
{
if( ret == 0 )
ret = 1;
mbedtls_printf( "Test hooks detected errors.\n" );
}
test_hooks_free( );
#if defined(MBEDTLS_MEMORY_BUFFER_ALLOC_C)
#if defined(MBEDTLS_MEMORY_DEBUG)
mbedtls_memory_buffer_alloc_status();