From e91e21cf1b8e7a05929bfaf1dbcec40c4e48804c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Manuel=20P=C3=A9gouri=C3=A9-Gonnard?= Date: Mon, 22 Jun 2015 18:47:07 +0200 Subject: [PATCH] Simplify code in test suites Hopefully makes it easier on static analyzers --- tests/suites/main_test.function | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/tests/suites/main_test.function b/tests/suites/main_test.function index ba1328877..a60db941b 100644 --- a/tests/suites/main_test.function +++ b/tests/suites/main_test.function @@ -22,23 +22,22 @@ static int test_errors = 0; SUITE_PRE_DEP #define TEST_SUITE_ACTIVE -static int test_assert( int correct, const char *test ) +static void test_fail( const char *test ) { - if( correct ) - return( 0 ); - test_errors++; if( test_errors == 1 ) mbedtls_printf( "FAILED\n" ); mbedtls_printf( " %s\n", test ); - - return( 1 ); } #define TEST_ASSERT( TEST ) \ - do { test_assert( (TEST) ? 1 : 0, #TEST ); \ - if( test_errors) goto exit; \ - } while (0) + do { \ + if( ! (TEST) ) \ + { \ + test_fail( #TEST ); \ + goto exit; \ + } \ + } while( 0 ) int verify_string( char **str ) {