Fix to test output in test suites

Fixes the test suites to consistently use mbedtls_fprintf to output to
stdout or stderr.

Also redirects output from the tests to /dev/null to avoid confusing
output if the test suite code or library outputs anything to stdout.
This commit is contained in:
Simon Butcher 2016-09-30 13:11:29 +01:00
parent bd8d221920
commit 2573136fa8
2 changed files with 62 additions and 11 deletions

View file

@ -8,16 +8,13 @@
#include "mbedtls/platform.h"
#else
#include <stdio.h>
#define mbedtls_printf printf
#define mbedtls_fprintf fprintf
#define mbedtls_calloc calloc
#define mbedtls_snprintf snprintf
#define mbedtls_calloc calloc
#define mbedtls_free free
#define mbedtls_exit exit
#define mbedtls_time time
#define mbedtls_time_t time_t
#define mbedtls_fprintf fprintf
#define mbedtls_printf printf
#define mbedtls_snprintf snprintf
#define MBEDTLS_EXIT_SUCCESS EXIT_SUCCESS
#define MBEDTLS_EXIT_FAILURE EXIT_FAILURE
#endif
@ -355,7 +352,8 @@ static void test_fail( const char *test, int line_no, const char* filename )
{
test_errors++;
if( test_errors == 1 )
mbedtls_printf( "FAILED\n" );
mbedtls_printf( " %s\n at line %d, %s\n", test, line_no, filename );
mbedtls_fprintf( stdout, "FAILED\n" );
mbedtls_fprintf( stdout, " %s\n at line %d, %s\n", test, line_no,
filename );
}