X-Git-Url: https://gerrit.o-ran-sc.org/r/gitweb?a=blobdiff_plain;f=test%2Fwormhole_static_test.c;h=47bd85f5dc0f241f64d189a529f89cce57b16560;hb=3925774e739509bb51df2c81addb3ab742c1801f;hp=9cb8d82bcc406f5cc4ef61b9ed26181bbd59602f;hpb=8790bf0c4f4f08fd05853afa67e211112b344a42;p=ric-plt%2Flib%2Frmr.git diff --git a/test/wormhole_static_test.c b/test/wormhole_static_test.c index 9cb8d82..47bd85f 100644 --- a/test/wormhole_static_test.c +++ b/test/wormhole_static_test.c @@ -34,9 +34,11 @@ #include #include #include +#include +#include -#include "../src/common/include/rmr.h" -#include "../src/common/include/rmr_agnostic.h" +#include "rmr.h" +#include "rmr_agnostic.h" /* @@ -48,6 +50,7 @@ static int worm_test( ) { char wbuf[1024]; int errors = 0; // number errors found int i; + void* p; rmr_mbuf_t* mbuf; // mbuf to send to peer int whid = -1; @@ -60,6 +63,7 @@ static int worm_test( ) { } memset( ctx, 0, sizeof( *ctx ) ); ctx->my_name = strdup( "tester" ); + ctx->my_ip = strdup( "30.4.19.86:1111" ); gen_rt( ctx ); @@ -100,11 +104,22 @@ static int worm_test( ) { whid = rmr_wh_open( ctx, "localhost:21961" ); errors += fail_not_equal( whid, 3, "attempt to fill in a hole didn't return expected" ); - rmr_wh_send_msg( NULL, 0, NULL ); // tests for coverage - rmr_wh_send_msg( ctx, 0, NULL ); + p = rmr_wh_send_msg( NULL, 0, NULL ); // tests for coverage + fail_not_nil( p, "wh_send_msg returned a pointer when given nil context and message" ); + + p = rmr_wh_send_msg( ctx, 0, NULL ); + fail_not_nil( p, "wh_send_msg returned a pointer when given nil message with valid context" ); mbuf = rmr_alloc_msg( ctx, 2048 ); // get an muf to pass round errors += fail_if_nil( mbuf, "unable to allocate mbuf for send tests (giving up on send tests)" ); + + mbuf->state = 0; + mbuf = rmr_wh_send_msg( NULL, 0, mbuf ); + if( mbuf ) { + fail_if_equal( mbuf->state, 0, "wh_send_msg returned a zero state when given a nil context" ); + } + fail_if_nil( mbuf, "wh_send_msg returned a nil message buffer when given a nil context" ); + while( mbuf ) { if( !(mbuf = rmr_wh_send_msg( ctx, 50, mbuf )) ) { // test for coverage errors += fail_if_nil( mbuf, "send didn't return an mbuf (skip rest of send tests)" );