mirror of
https://git.suyu.dev/suyu/mbedtls.git
synced 2026-01-01 04:05:16 +01:00
Add tests for debug_print_ret() and debug_print_buf().
This commit is contained in:
parent
2b34657b39
commit
57ffa5570d
2 changed files with 72 additions and 5 deletions
|
|
@ -18,10 +18,53 @@ void string_debug(void *data, int level, const char *str)
|
|||
/* END_HEADER */
|
||||
|
||||
/* BEGIN_DEPENDENCIES
|
||||
* depends_on:POLARSSL_DEBUG_C:POLARSSL_BIGNUM_C:POLARSSL_SSL_TLS_C:POLARSSL_RSA_C
|
||||
* depends_on:POLARSSL_DEBUG_C:POLARSSL_SSL_TLS_C
|
||||
* END_DEPENDENCIES
|
||||
*/
|
||||
|
||||
/* BEGIN_CASE */
|
||||
void debug_print_ret( char *file, int line, char *text, int value,
|
||||
char *result_str )
|
||||
{
|
||||
ssl_context ssl;
|
||||
struct buffer_data buffer;
|
||||
|
||||
memset( &ssl, 0, sizeof( ssl_context ) );
|
||||
memset( buffer.buf, 0, 2000 );
|
||||
buffer.ptr = buffer.buf;
|
||||
|
||||
ssl_set_dbg(&ssl, string_debug, &buffer);
|
||||
|
||||
debug_print_ret( &ssl, 0, file, line, text, value);
|
||||
|
||||
TEST_ASSERT( strcmp( buffer.buf, result_str ) == 0 );
|
||||
}
|
||||
/* END_CASE */
|
||||
|
||||
/* BEGIN_CASE */
|
||||
void debug_print_buf( char *file, int line, char *text, char *data_string,
|
||||
char *result_str )
|
||||
{
|
||||
unsigned char data[10000];
|
||||
ssl_context ssl;
|
||||
struct buffer_data buffer;
|
||||
size_t data_len;
|
||||
|
||||
memset( &data, 0, sizeof( data ) );
|
||||
memset( &ssl, 0, sizeof( ssl_context ) );
|
||||
memset( buffer.buf, 0, 2000 );
|
||||
buffer.ptr = buffer.buf;
|
||||
|
||||
data_len = unhexify( data, data_string );
|
||||
|
||||
ssl_set_dbg(&ssl, string_debug, &buffer);
|
||||
|
||||
debug_print_buf( &ssl, 0, file, line, text, data, data_len );
|
||||
|
||||
TEST_ASSERT( strcmp( buffer.buf, result_str ) == 0 );
|
||||
}
|
||||
/* END_CASE */
|
||||
|
||||
/* BEGIN_CASE depends_on:POLARSSL_FS_IO:POLARSSL_X509_CRT_PARSE_C */
|
||||
void debug_print_crt( char *crt_file, char *file, int line, char *prefix,
|
||||
char *result_str )
|
||||
|
|
@ -33,7 +76,7 @@ void debug_print_crt( char *crt_file, char *file, int line, char *prefix,
|
|||
x509_crt_init( &crt );
|
||||
memset( &ssl, 0, sizeof( ssl_context ) );
|
||||
memset( buffer.buf, 0, 2000 );
|
||||
buffer.ptr = buffer.buf;
|
||||
buffer.ptr = buffer.buf;
|
||||
|
||||
ssl_set_dbg(&ssl, string_debug, &buffer);
|
||||
|
||||
|
|
@ -46,7 +89,7 @@ void debug_print_crt( char *crt_file, char *file, int line, char *prefix,
|
|||
}
|
||||
/* END_CASE */
|
||||
|
||||
/* BEGIN_CASE */
|
||||
/* BEGIN_CASE depends_on:POLARSSL_BIGNUM_C */
|
||||
void debug_print_mpi( int radix, char *value, char *file, int line,
|
||||
char *prefix, char *result_str )
|
||||
{
|
||||
|
|
@ -58,7 +101,7 @@ void debug_print_mpi( int radix, char *value, char *file, int line,
|
|||
|
||||
memset( &ssl, 0, sizeof( ssl_context ) );
|
||||
memset( buffer.buf, 0, 2000 );
|
||||
buffer.ptr = buffer.buf;
|
||||
buffer.ptr = buffer.buf;
|
||||
|
||||
TEST_ASSERT( mpi_read_string( &val, radix, value ) == 0 );
|
||||
ssl_set_dbg(&ssl, string_debug, &buffer);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue