Fix minor style issues in test framework
This commit is contained in:
parent
2573136fa8
commit
8ca53b51c5
2 changed files with 48 additions and 32 deletions
|
@ -34,6 +34,9 @@ typedef UINT32 uint32_t;
|
|||
|
||||
#include <string.h>
|
||||
|
||||
#if defined(__unix__) || (defined(__APPLE__) && defined(__MACH__))
|
||||
#include <unistd.h>
|
||||
#endif
|
||||
|
||||
/*----------------------------------------------------------------------------*/
|
||||
/* Constants */
|
||||
|
@ -102,6 +105,43 @@ static int test_errors = 0;
|
|||
/*----------------------------------------------------------------------------*/
|
||||
/* Helper Functions */
|
||||
|
||||
#if defined(__unix__) || (defined(__APPLE__) && defined(__MACH__))
|
||||
static int redirect_output( FILE** out_stream, const char* path )
|
||||
{
|
||||
int stdout_fd = dup( fileno( *out_stream ) );
|
||||
|
||||
if( stdout_fd == -1 )
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
|
||||
fflush( *out_stream );
|
||||
fclose( *out_stream );
|
||||
*out_stream = fopen( path, "w" );
|
||||
|
||||
if( *out_stream == NULL )
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
|
||||
return stdout_fd;
|
||||
}
|
||||
|
||||
static int restore_output( FILE** out_stream, int old_fd )
|
||||
{
|
||||
fflush( *out_stream );
|
||||
fclose( *out_stream );
|
||||
|
||||
*out_stream = fdopen( old_fd, "w" );
|
||||
if( *out_stream == NULL )
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
#endif /* __unix__ || __APPLE__ __MACH__ */
|
||||
|
||||
static int unhexify( unsigned char *obuf, const char *ibuf )
|
||||
{
|
||||
unsigned char c, c2;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue