Fix bug in redirection of unit test outputs

Avoid replacing handle. stdout is defined as a macro on several platforms.

Signed-off-by: gufe44 <gu981@protonmail.com>
This commit is contained in:
gufe44
2020-07-30 09:02:27 +02:00
committed by gufe44
parent a586099fd3
commit 650ce76544
3 changed files with 37 additions and 31 deletions

View File

@@ -555,7 +555,7 @@ int execute_tests( int argc , const char ** argv )
*/
if( !option_verbose )
{
stdout_fd = redirect_output( &stdout, "/dev/null" );
stdout_fd = redirect_output( stdout, "/dev/null" );
if( stdout_fd == -1 )
{
/* Redirection has failed with no stdout so exit */
@@ -575,7 +575,7 @@ int execute_tests( int argc , const char ** argv )
}
#if defined(__unix__) || (defined(__APPLE__) && defined(__MACH__))
if( !option_verbose && restore_output( &stdout, stdout_fd ) )
if( !option_verbose && restore_output( stdout, stdout_fd ) )
{
/* Redirection has failed with no stdout so exit */
exit( 1 );
@@ -667,10 +667,5 @@ int execute_tests( int argc , const char ** argv )
mbedtls_memory_buffer_alloc_free();
#endif
#if defined(__unix__) || (defined(__APPLE__) && defined(__MACH__))
if( stdout_fd != -1 )
close_output( stdout );
#endif /* __unix__ || __APPLE__ __MACH__ */
return( total_errors != 0 );
}