Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

2.14.1: problems running tests #2311

Closed
0-wiz-0 opened this issue Dec 21, 2018 · 3 comments
Closed

2.14.1: problems running tests #2311

0-wiz-0 opened this issue Dec 21, 2018 · 3 comments
Labels
bug component-platform Portability layer and build scripts historical-reviewing Currently reviewing (for legacy PR/issues)

Comments

@0-wiz-0
Copy link

0-wiz-0 commented Dec 21, 2018

When I try building the tests on NetBSD (8.99.27/amd64), I get the following compilation error:

suites/host_test.function: In function 'execute_tests':
suites/host_test.function:556:50: error: lvalue required as unary '&' operand
                     stdout_fd = redirect_output( &stdout, "/dev/null" );
                                                  ^
suites/host_test.function:576:56: error: lvalue required as unary '&' operand
                 if( !option_verbose && restore_output( &stdout, stdout_fd ) )
                                                        ^

That's with gcc-6.5.0 in case it matters, the default compiler on that version of NetBSD.

@hanno-becker hanno-becker added bug tracking component-platform Portability layer and build scripts labels Dec 21, 2018
@ciarmcom
Copy link

ARM Internal Ref: IOTSSL-2676

@ip1981
Copy link

ip1981 commented Nov 29, 2019

I just removed that part for Dyson. The problem is that stdin/stdout/stderr can be macros, and they are on NetBSD, Solaris.

Description: Remove stdout redirection because it is broken.
stdout, stderr, stdin are macros on Dyson.
Bug: https://github.com/ARMmbed/mbedtls/issues/2311
Last-Update: 2019-11-29
--- mbedtls-2.16.3.orig/tests/suites/helpers.function
+++ mbedtls-2.16.3/tests/suites/helpers.function
@@ -356,49 +356,6 @@ void mbedtls_param_failed( const char *f
 }
 #endif
 
-#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 )
-    {
-        close( stdout_fd );
-        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;
-}
-
-static void close_output( FILE* out_stream )
-{
-    fclose( out_stream );
-}
-#endif /* __unix__ || __APPLE__ __MACH__ */
-
 int unhexify( unsigned char *obuf, const char *ibuf )
 {
     unsigned char c, c2;
--- mbedtls-2.16.3.orig/tests/suites/host_test.function
+++ mbedtls-2.16.3/tests/suites/host_test.function
@@ -400,9 +400,6 @@ int execute_tests( int argc , const char
     /* Store for proccessed integer params. */
     int int_params[50];
     void *pointer;
-#if defined(__unix__) || (defined(__APPLE__) && defined(__MACH__))
-    int stdout_fd = -1;
-#endif /* __unix__ || __APPLE__ __MACH__ */
 
 #if defined(MBEDTLS_MEMORY_BUFFER_ALLOC_C) && \
     !defined(TEST_SUITE_MEMORY_BUFFER_ALLOC)
@@ -549,21 +546,6 @@ int execute_tests( int argc , const char
                 test_info.result = TEST_RESULT_SUCCESS;
                 test_info.paramfail_test_state = PARAMFAIL_TESTSTATE_IDLE;
 
-#if defined(__unix__) || (defined(__APPLE__) && defined(__MACH__))
-                /* Suppress all output from the library unless we're verbose
-                 * mode
-                 */
-                if( !option_verbose )
-                {
-                    stdout_fd = redirect_output( &stdout, "/dev/null" );
-                    if( stdout_fd == -1 )
-                    {
-                        /* Redirection has failed with no stdout so exit */
-                        exit( 1 );
-                    }
-                }
-#endif /* __unix__ || __APPLE__ __MACH__ */
-
                 function_id = strtol( params[0], NULL, 10 );
                 if ( (ret = check_test( function_id )) == DISPATCH_TEST_SUCCESS )
                 {
@@ -574,14 +556,6 @@ int execute_tests( int argc , const char
                     }
                 }
 
-#if defined(__unix__) || (defined(__APPLE__) && defined(__MACH__))
-                if( !option_verbose && restore_output( &stdout, stdout_fd ) )
-                {
-                        /* Redirection has failed with no stdout so exit */
-                        exit( 1 );
-                }
-#endif /* __unix__ || __APPLE__ __MACH__ */
-
             }
 
             if( unmet_dep_count > 0 || ret == DISPATCH_UNSUPPORTED_SUITE )
@@ -669,10 +643,5 @@ int execute_tests( int argc , const char
     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 );
 }

@tom-cosgrove-arm tom-cosgrove-arm added historical-reviewing Currently reviewing (for legacy PR/issues) and removed historical-reviewing Currently reviewing (for legacy PR/issues) labels Nov 25, 2022
@tom-cosgrove-arm
Copy link
Contributor

Closing, as fixed by #3528

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug component-platform Portability layer and build scripts historical-reviewing Currently reviewing (for legacy PR/issues)
Projects
None yet
Development

No branches or pull requests

6 participants