X-Git-Url: https://gerrit.o-ran-sc.org/r/gitweb?a=blobdiff_plain;f=test%2Frmr_nng_api_static_test.c;h=2db1a202a3d178203cce84d8ae70dc9ff8054fc4;hb=907fbf43104b1670b7374bf1a4b22096977774bf;hp=e0dc4d8dec0cda2c777818bcc64df6a8442e8cc2;hpb=6d3e334fe1980c1a3581f3d8fd26d7ec7e8d60f7;p=ric-plt%2Flib%2Frmr.git diff --git a/test/rmr_nng_api_static_test.c b/test/rmr_nng_api_static_test.c index e0dc4d8..2db1a20 100644 --- a/test/rmr_nng_api_static_test.c +++ b/test/rmr_nng_api_static_test.c @@ -222,22 +222,23 @@ static int rmr_api_test( ) { errors += fail_if( errno != 0, "rmr_rts_msg did not reset errno " ); - snprintf( msg->xaction, 17, "%015d", 16 ); // dummy transaction id (emulation generates, this should arrive after a few calls to recv) msg->state = 0; msg = rmr_call( NULL, msg ); errors += fail_if( msg->state == 0, "rmr_call did not set message state when given message with nil context " ); + snprintf( msg->xaction, 17, "%015d", 16 ); // dummy transaction id (emulation generates, this should arrive after a few calls to recv) msg->mtype = 0; - msg = rmr_call( rmc, msg ); // this call should return a message as we can anticipate a dummy message in + msg->sub_id = -1; + msg = rmr_call( rmc, msg ); // dummy nng/nano function will sequentually add xactions and should match or '16' errors += fail_if_nil( msg, "rmr_call returned a nil message on call expected to succeed " ); if( msg ) { errors += fail_not_equal( msg->state, RMR_OK, "rmr_call did not properly set state on successful return " ); errors += fail_not_equal( errno, 0, "rmr_call did not properly set errno (a) on successful return " ); } - snprintf( wbuf, 17, "%015d", 14 ); // if we call receive we should find this in the first 15 tries - for( i = 0; i < 16; i++ ) { + snprintf( wbuf, 17, "%015d", 14 ); // while waiting, the queued messages should have #14, so issue a few receives looking for it + for( i = 0; i < 16; i++ ) { // it should be in the first 15 msg = rmr_rcv_msg( rmc, msg ); if( msg ) { if( strcmp( wbuf, msg->xaction ) == 0 ) { // found the queued message @@ -254,15 +255,10 @@ static int rmr_api_test( ) { if( ! msg ) { msg = rmr_alloc_msg( rmc, 2048 ); // something buggered above; get a new one } - msg = rmr_call( rmc, msg ); // make a call that we never expect a response on - errors += fail_if_nil( msg, "rmr_call returned a non-nil message on call expected not to receive a response " ); - if( msg ) { - errors += fail_if_equal( msg->state, RMR_OK, "rmr_call did not properly set state on queued message receive " ); - errors += fail_if( errno == 0, "rmr_call did not properly set errno on queued message receivesuccessful " ); - } - - msg = rmr_call( rmc, msg ); // this should "timeout" because the message xaction id won't ever appear again - errors += fail_if_nil( msg, "rmr_call returned a nil message on call expected to fail " ); + msg->mtype = 0; + msg->sub_id = -1; + msg = rmr_call( rmc, msg ); // make a call that we never expect a response on (nil pointer back) + errors += fail_not_nil( msg, "rmr_call returned a nil message on call expected not to receive a response " ); errors += fail_if( errno == 0, "rmr_call did not set errno on failure " ); rmr_free_msg( NULL ); // drive for coverage; nothing to check