X-Git-Url: https://gerrit.o-ran-sc.org/r/gitweb?a=blobdiff_plain;f=test%2Frmr_si_rcv_static_test.c;h=b0403599dcb906a8cbd85a80b16ca0a2aa14c2b2;hb=11838bcf76f3614384459cb56e2ce80dea788cef;hp=ad543a0b7c3e53ec080ca3866d2acfda80b8e9cf;hpb=e15b1382dc618f6832957e67dc638b5e8f3f414d;p=ric-plt%2Flib%2Frmr.git diff --git a/test/rmr_si_rcv_static_test.c b/test/rmr_si_rcv_static_test.c index ad543a0..b040359 100644 --- a/test/rmr_si_rcv_static_test.c +++ b/test/rmr_si_rcv_static_test.c @@ -1,8 +1,8 @@ // : vi ts=4 sw=4 noet : /* ================================================================================== - Copyright (c) 2019-2020 Nokia - Copyright (c) 2018-2020 AT&T Intellectual Property. + Copyright (c) 2019-2021 Nokia + Copyright (c) 2018-2021 AT&T Intellectual Property. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -150,6 +150,7 @@ static int rmr_rcv_test( ) { } rmr_rts_msg( NULL, NULL ); // drive for coverage + errors += fail_if( errno == 0, "rmr_rts_msg did not set errno when given a nil context " ); rmr_rts_msg( rmc, NULL ); errors += fail_if( errno == 0, "rmr_rts_msg did not set errno when given a nil message " ); @@ -225,6 +226,42 @@ static int rmr_rcv_test( ) { rmr_close( rmc ); // no return to check; drive for coverage + // ------- receive specific is deprecated, but we still test to keep sonar happy --------------- + + rmr_rcv_specific( NULL, NULL, "12345", 0 ); // drive for error handling coverage + rmr_rcv_specific( NULL, msg, "12345", 2 ); + + strncpy( wbuf, "dummy message", sizeof( wbuf ) ); + msg = mk_populated_msg( 1024, 0, 0, -1, strlen( wbuf ) + 1 ); + strncpy( msg->payload, wbuf, msg->len ); + msg = rmr_send_msg( rmc, msg ); // give specific something to chew on + + strncpy( msg->payload, wbuf, msg->len ); + msg->mtype = 0; + rmr_str2xact( msg, "12345" ); // should allow rcv to find it + msg = rmr_send_msg( rmc, msg ); + + msg = rmr_rcv_specific( rmc, NULL, "12345", 2 ); + if( msg ) { + errors += fail_if( msg->state != 0, "rmr_rcv_specific failed to find the expected message" ); + } else { + errors++; + fprintf( stderr, " rcv specific expected to return a message and did not\n" ); + } + + strncpy( wbuf, "dummy message", sizeof( wbuf ) ); + msg = mk_populated_msg( 1024, 0, 0, -1, strlen( wbuf ) + 1 ); + strncpy( msg->payload, wbuf, msg->len ); + msg = rmr_send_msg( rmc, msg ); // give specific something to chew on + + fprintf( stderr, " starting rmr_rcv_specific test for no expected message\n" ); + strncpy( msg->payload, wbuf, msg->len ); + msg->mtype = 0; + rmr_str2xact( msg, "72345" ); // rcv should not find it + msg = rmr_send_msg( rmc, msg ); + msg = rmr_rcv_specific( rmc, msg, "12345", 2 ); + fail_if_nil( msg, "rmr_rcv_specific expected to retun nil message did not" ); + // --------------- phew, done ------------------------------------------------------------------------------ if( ! errors ) { @@ -233,5 +270,5 @@ static int rmr_rcv_test( ) { fprintf( stderr, " receive tests failures noticed \n" ); } - return !!errors; + return errors; }