Fix minor style issues in test framework
diff --git a/tests/suites/helpers.function b/tests/suites/helpers.function
index 2475a3c..5938447 100644
--- a/tests/suites/helpers.function
+++ b/tests/suites/helpers.function
@@ -34,6 +34,9 @@
#include <string.h>
+#if defined(__unix__) || (defined(__APPLE__) && defined(__MACH__))
+#include <unistd.h>
+#endif
/*----------------------------------------------------------------------------*/
/* Constants */
@@ -102,6 +105,43 @@
/*----------------------------------------------------------------------------*/
/* 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;