From d5a9e4129685ec3666b1dbdf34d58f5b6bb45feb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Manuel=20P=C3=A9gouri=C3=A9-Gonnard?= Date: Mon, 4 May 2015 11:11:42 +0200 Subject: [PATCH] Adapt test_suite_debug to recent changes --- tests/suites/test_suite_debug.function | 32 +++++++++++++++++++++----- 1 file changed, 26 insertions(+), 6 deletions(-) diff --git a/tests/suites/test_suite_debug.function b/tests/suites/test_suite_debug.function index 492e32d7c..c423545f1 100644 --- a/tests/suites/test_suite_debug.function +++ b/tests/suites/test_suite_debug.function @@ -36,10 +36,12 @@ void debug_print_msg_threshold( int threshold, int level, char *file, int line, mbedtls_ssl_context ssl; struct buffer_data buffer; - memset( &ssl, 0, sizeof( mbedtls_ssl_context ) ); + mbedtls_ssl_init( &ssl ); memset( buffer.buf, 0, 2000 ); buffer.ptr = buffer.buf; + TEST_ASSERT( mbedtls_ssl_setup( &ssl ) == 0 ); + mbedtls_debug_set_log_mode( MBEDTLS_DEBUG_LOG_FULL ); mbedtls_debug_set_threshold( threshold ); mbedtls_ssl_set_dbg(&ssl, string_debug, &buffer); @@ -48,6 +50,9 @@ void debug_print_msg_threshold( int threshold, int level, char *file, int line, mbedtls_debug_fmt("Text message, 2 == %d", 2 ) ); TEST_ASSERT( strcmp( buffer.buf, result_str ) == 0 ); + +exit: + mbedtls_ssl_free( &ssl ); } /* END_CASE */ @@ -58,16 +63,21 @@ void mbedtls_debug_print_ret( int mode, char *file, int line, char *text, int va mbedtls_ssl_context ssl; struct buffer_data buffer; - memset( &ssl, 0, sizeof( mbedtls_ssl_context ) ); + mbedtls_ssl_init( &ssl ); memset( buffer.buf, 0, 2000 ); buffer.ptr = buffer.buf; + TEST_ASSERT( mbedtls_ssl_setup( &ssl ) == 0 ); + mbedtls_debug_set_log_mode( mode ); mbedtls_ssl_set_dbg(&ssl, string_debug, &buffer); mbedtls_debug_print_ret( &ssl, 0, file, line, text, value); TEST_ASSERT( strcmp( buffer.buf, result_str ) == 0 ); + +exit: + mbedtls_ssl_free( &ssl ); } /* END_CASE */ @@ -80,19 +90,24 @@ void mbedtls_debug_print_buf( int mode, char *file, int line, char *text, struct buffer_data buffer; size_t data_len; + mbedtls_ssl_init( &ssl ); memset( &data, 0, sizeof( data ) ); - memset( &ssl, 0, sizeof( mbedtls_ssl_context ) ); memset( buffer.buf, 0, 2000 ); buffer.ptr = buffer.buf; data_len = unhexify( data, data_string ); + TEST_ASSERT( mbedtls_ssl_setup( &ssl ) == 0 ); + mbedtls_debug_set_log_mode( mode ); mbedtls_ssl_set_dbg(&ssl, string_debug, &buffer); mbedtls_debug_print_buf( &ssl, 0, file, line, text, data, data_len ); TEST_ASSERT( strcmp( buffer.buf, result_str ) == 0 ); + +exit: + mbedtls_ssl_free( &ssl ); } /* END_CASE */ @@ -104,11 +119,13 @@ void mbedtls_debug_print_crt( int mode, char *crt_file, char *file, int line, mbedtls_ssl_context ssl; struct buffer_data buffer; + mbedtls_ssl_init( &ssl ); mbedtls_x509_crt_init( &crt ); - memset( &ssl, 0, sizeof( mbedtls_ssl_context ) ); memset( buffer.buf, 0, 2000 ); buffer.ptr = buffer.buf; + TEST_ASSERT( mbedtls_ssl_setup( &ssl ) == 0 ); + mbedtls_debug_set_log_mode( mode ); mbedtls_ssl_set_dbg(&ssl, string_debug, &buffer); @@ -119,6 +136,7 @@ void mbedtls_debug_print_crt( int mode, char *crt_file, char *file, int line, exit: mbedtls_x509_crt_free( &crt ); + mbedtls_ssl_free( &ssl ); } /* END_CASE */ @@ -130,12 +148,13 @@ void mbedtls_debug_print_mpi( int mode, int radix, char *value, char *file, int struct buffer_data buffer; mbedtls_mpi val; + mbedtls_ssl_init( &ssl ); mbedtls_mpi_init( &val ); - - memset( &ssl, 0, sizeof( mbedtls_ssl_context ) ); memset( buffer.buf, 0, 2000 ); buffer.ptr = buffer.buf; + TEST_ASSERT( mbedtls_ssl_setup( &ssl ) == 0 ); + TEST_ASSERT( mbedtls_mpi_read_string( &val, radix, value ) == 0 ); mbedtls_debug_set_log_mode( mode ); @@ -147,5 +166,6 @@ void mbedtls_debug_print_mpi( int mode, int radix, char *value, char *file, int exit: mbedtls_mpi_free( &val ); + mbedtls_ssl_free( &ssl ); } /* END_CASE */