mbedtls/tests/suites/test_suite_debug.function
Paul Bakker 69e095cc15 - Changed the behaviour of x509parse_parse_crt for permissive parsing. Now returns the number of 'failed certificates' instead of having a switch to enable it.
- As a consequence all error code that were positive were changed. A lot of MALLOC_FAILED and FILE_IO_ERROR error codes added for different modules.
 - Programs and tests were adapted accordingly
2011-12-10 21:55:01 +00:00

69 lines
1.5 KiB
Text

BEGIN_HEADER
#include <polarssl/debug.h>
struct buffer_data
{
char buf[2000];
char *ptr;
};
void string_debug(void *data, int level, const char *str)
{
struct buffer_data *buffer = (struct buffer_data *) data;
((void) level);
memcpy(buffer->ptr, str, strlen(str));
buffer->ptr += strlen(str);
}
END_HEADER
BEGIN_DEPENDENCIES
depends_on:POLARSSL_DEBUG_C:POLARSSL_BIGNUM_C:POLARSSL_SSL_TLS_C:POLARSSL_RSA_C
END_DEPENDENCIES
BEGIN_CASE
debug_print_crt:crt_file:file:line:prefix:result_str
{
x509_cert crt;
ssl_context ssl;
struct buffer_data buffer;
memset( &crt, 0, sizeof( x509_cert ) );
memset( &ssl, 0, sizeof( ssl_context ) );
memset( buffer.buf, 0, 2000 );
buffer.ptr = buffer.buf;
ssl_set_dbg(&ssl, string_debug, &buffer);
TEST_ASSERT( x509parse_crtfile( &crt, {crt_file} ) == 0 );
debug_print_crt( &ssl, 0, {file}, {line}, {prefix}, &crt);
TEST_ASSERT( strcmp( buffer.buf, {result_str} ) == 0 );
}
END_CASE
BEGIN_CASE
debug_print_mpi:radix:value:file:line:prefix:result_str
{
ssl_context ssl;
struct buffer_data buffer;
mpi val;
mpi_init( &val );
memset( &ssl, 0, sizeof( ssl_context ) );
memset( buffer.buf, 0, 2000 );
buffer.ptr = buffer.buf;
TEST_ASSERT( mpi_read_string( &val, {radix}, {value} ) == 0 );
ssl_set_dbg(&ssl, string_debug, &buffer);
debug_print_mpi( &ssl, 0, {file}, {line}, {prefix}, &val);
TEST_ASSERT( strcmp( buffer.buf, {result_str} ) == 0 );
mpi_free( &val );
}
END_CASE