mirror of
https://github.com/yuzu-emu/mbedtls.git
synced 2024-11-23 05:55:40 +01:00
fix main_test.function to use polarssl (f)printf functions
This commit is contained in:
parent
9014b6f227
commit
3d536ba30c
@ -5,6 +5,7 @@
|
|||||||
#include "polarssl/platform.h"
|
#include "polarssl/platform.h"
|
||||||
#else
|
#else
|
||||||
#define polarssl_printf printf
|
#define polarssl_printf printf
|
||||||
|
#define polarssl_fprintf fprintf
|
||||||
#define polarssl_malloc malloc
|
#define polarssl_malloc malloc
|
||||||
#define polarssl_free free
|
#define polarssl_free free
|
||||||
#endif
|
#endif
|
||||||
@ -25,8 +26,8 @@ static int test_assert( int correct, const char *test )
|
|||||||
|
|
||||||
test_errors++;
|
test_errors++;
|
||||||
if( test_errors == 1 )
|
if( test_errors == 1 )
|
||||||
printf( "FAILED\n" );
|
polarssl_printf( "FAILED\n" );
|
||||||
printf( " %s\n", test );
|
polarssl_printf( " %s\n", test );
|
||||||
|
|
||||||
return( 1 );
|
return( 1 );
|
||||||
}
|
}
|
||||||
@ -41,7 +42,7 @@ int verify_string( char **str )
|
|||||||
if( (*str)[0] != '"' ||
|
if( (*str)[0] != '"' ||
|
||||||
(*str)[strlen( *str ) - 1] != '"' )
|
(*str)[strlen( *str ) - 1] != '"' )
|
||||||
{
|
{
|
||||||
printf( "Expected string (with \"\") for parameter and got: %s\n", *str );
|
polarssl_printf( "Expected string (with \"\") for parameter and got: %s\n", *str );
|
||||||
return( -1 );
|
return( -1 );
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -94,7 +95,7 @@ int verify_int( char *str, int *value )
|
|||||||
|
|
||||||
MAPPING_CODE
|
MAPPING_CODE
|
||||||
|
|
||||||
printf( "Expected integer for parameter and got: %s\n", str );
|
polarssl_printf( "Expected integer for parameter and got: %s\n", str );
|
||||||
return( -1 );
|
return( -1 );
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -120,7 +121,7 @@ int dispatch_test(int cnt, char *params[50])
|
|||||||
#if defined(TEST_SUITE_ACTIVE)
|
#if defined(TEST_SUITE_ACTIVE)
|
||||||
DISPATCH_FUNCTION
|
DISPATCH_FUNCTION
|
||||||
{
|
{
|
||||||
fprintf( stdout, "FAILED\nSkipping unknown test function '%s'\n", params[0] );
|
polarssl_fprintf( stdout, "FAILED\nSkipping unknown test function '%s'\n", params[0] );
|
||||||
fflush( stdout );
|
fflush( stdout );
|
||||||
return( 1 );
|
return( 1 );
|
||||||
}
|
}
|
||||||
@ -224,7 +225,7 @@ int main()
|
|||||||
file = fopen( filename, "r" );
|
file = fopen( filename, "r" );
|
||||||
if( file == NULL )
|
if( file == NULL )
|
||||||
{
|
{
|
||||||
fprintf( stderr, "Failed to open\n" );
|
polarssl_fprintf( stderr, "Failed to open\n" );
|
||||||
return( 1 );
|
return( 1 );
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -234,11 +235,11 @@ int main()
|
|||||||
|
|
||||||
if( ( ret = get_line( file, buf, sizeof(buf) ) ) != 0 )
|
if( ( ret = get_line( file, buf, sizeof(buf) ) ) != 0 )
|
||||||
break;
|
break;
|
||||||
fprintf( stdout, "%s%.66s", test_errors ? "\n" : "", buf );
|
polarssl_fprintf( stdout, "%s%.66s", test_errors ? "\n" : "", buf );
|
||||||
fprintf( stdout, " " );
|
polarssl_fprintf( stdout, " " );
|
||||||
for( i = strlen( buf ) + 1; i < 67; i++ )
|
for( i = strlen( buf ) + 1; i < 67; i++ )
|
||||||
fprintf( stdout, "." );
|
polarssl_fprintf( stdout, "." );
|
||||||
fprintf( stdout, " " );
|
polarssl_fprintf( stdout, " " );
|
||||||
fflush( stdout );
|
fflush( stdout );
|
||||||
|
|
||||||
total_tests++;
|
total_tests++;
|
||||||
@ -267,17 +268,17 @@ int main()
|
|||||||
if( skip == 1 || ret == 3 )
|
if( skip == 1 || ret == 3 )
|
||||||
{
|
{
|
||||||
total_skipped++;
|
total_skipped++;
|
||||||
fprintf( stdout, "----\n" );
|
polarssl_fprintf( stdout, "----\n" );
|
||||||
fflush( stdout );
|
fflush( stdout );
|
||||||
}
|
}
|
||||||
else if( ret == 0 && test_errors == 0 )
|
else if( ret == 0 && test_errors == 0 )
|
||||||
{
|
{
|
||||||
fprintf( stdout, "PASS\n" );
|
polarssl_fprintf( stdout, "PASS\n" );
|
||||||
fflush( stdout );
|
fflush( stdout );
|
||||||
}
|
}
|
||||||
else if( ret == 2 )
|
else if( ret == 2 )
|
||||||
{
|
{
|
||||||
fprintf( stderr, "FAILED: FATAL PARSE ERROR\n" );
|
polarssl_fprintf( stderr, "FAILED: FATAL PARSE ERROR\n" );
|
||||||
fclose(file);
|
fclose(file);
|
||||||
exit( 2 );
|
exit( 2 );
|
||||||
}
|
}
|
||||||
@ -288,19 +289,19 @@ int main()
|
|||||||
break;
|
break;
|
||||||
if( strlen(buf) != 0 )
|
if( strlen(buf) != 0 )
|
||||||
{
|
{
|
||||||
fprintf( stderr, "Should be empty %d\n", (int) strlen(buf) );
|
polarssl_fprintf( stderr, "Should be empty %d\n", (int) strlen(buf) );
|
||||||
return( 1 );
|
return( 1 );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
fclose(file);
|
fclose(file);
|
||||||
|
|
||||||
fprintf( stdout, "\n----------------------------------------------------------------------------\n\n");
|
polarssl_fprintf( stdout, "\n----------------------------------------------------------------------------\n\n");
|
||||||
if( total_errors == 0 )
|
if( total_errors == 0 )
|
||||||
fprintf( stdout, "PASSED" );
|
polarssl_fprintf( stdout, "PASSED" );
|
||||||
else
|
else
|
||||||
fprintf( stdout, "FAILED" );
|
polarssl_fprintf( stdout, "FAILED" );
|
||||||
|
|
||||||
fprintf( stdout, " (%d / %d tests (%d skipped))\n",
|
polarssl_fprintf( stdout, " (%d / %d tests (%d skipped))\n",
|
||||||
total_tests - total_errors, total_tests, total_skipped );
|
total_tests - total_errors, total_tests, total_skipped );
|
||||||
|
|
||||||
#if defined(POLARSSL_MEMORY_BUFFER_ALLOC_C) && \
|
#if defined(POLARSSL_MEMORY_BUFFER_ALLOC_C) && \
|
||||||
|
Loading…
Reference in New Issue
Block a user