X-Git-Url: https://gerrit.o-ran-sc.org/r/gitweb?a=blobdiff_plain;f=test%2Ftest_support.c;h=4ed976c4a6def6cf2cb25e910dbc8b2d943c0096;hb=refs%2Fchanges%2F53%2F53%2F1;hp=d9a5f477582d44c3e34478632fe9a363f5f726a3;hpb=68c5cf1104e89f5c43786a3e48f5c6a1e757f59f;p=ric-plt%2Flib%2Frmr.git diff --git a/test/test_support.c b/test/test_support.c index d9a5f47..4ed976c 100644 --- a/test/test_support.c +++ b/test/test_support.c @@ -27,10 +27,15 @@ Date: 6 January 2019 */ +#ifndef _test_support_c +#define _test_support_c + #include #include #include #include +#include +#include #ifndef BAD #define BAD 1 // these are exit codes unless user overrides @@ -81,21 +86,21 @@ static void set_signals( void ) { static int fail_if_nil( void* p, char* what ) { if( !p ) { - fprintf( stderr, "[FAIL] pointer to '%s' was nil\n", what ); + fprintf( stderr, " %s: pointer was nil\n", what ); } return p ? GOOD : BAD; } static int fail_not_nil( void* p, char* what ) { if( p ) { - fprintf( stderr, "[FAIL] pointer to '%s' was not nil\n", what ); + fprintf( stderr, " %s: pointer was not nil\n", what ); } return !p ? GOOD : BAD; } static int fail_if_false( int bv, char* what ) { if( !bv ) { - fprintf( stderr, "[FAIL] boolean was false (%d) %s\n", bv, what ); + fprintf( stderr, " %s: expected true, boolean test was false (%d)\n", what, bv ); } return bv ? GOOD : BAD; @@ -103,7 +108,7 @@ static int fail_if_false( int bv, char* what ) { static int fail_if_true( int bv, char* what ) { if( bv ) { - fprintf( stderr, "[FAIL] boolean was true (%d) %s\n", bv, what ); + fprintf( stderr, " %s: expected false, boolean test was true (%d)\n", what, bv ); } return bv ? BAD : GOOD; } @@ -114,21 +119,23 @@ static int fail_if_true( int bv, char* what ) { static int fail_if( int bv, char* what ) { if( bv ) { - fprintf( stderr, "[FAIL] boolean was true (%d) %s\n", bv, what ); + fprintf( stderr, " %s: expected false, boolean test was true (%d)\n", what, bv ); } return bv ? BAD : GOOD; } static int fail_not_equal( int a, int b, char* what ) { if( a != b ) { - fprintf( stderr, "[FAIL] %s values were not equal a=%d b=%d\n", what, a, b ); + fprintf( stderr, " %s: values were not equal a=%d b=%d\n", what, a, b ); } return a == b ? GOOD : BAD; // user may override good/bad so do NOT return a==b directly! } static int fail_if_equal( int a, int b, char* what ) { if( a == b ) { - fprintf( stderr, "[FAIL] %s values were equal a=%d b=%d\n", what, a, b ); + fprintf( stderr, " %s values were equal a=%d b=%d\n", what, a, b ); } return a != b ? GOOD : BAD; // user may override good/bad so do NOT return a==b directly! } + +#endif