X-Git-Url: https://gerrit.o-ran-sc.org/r/gitweb?a=blobdiff_plain;f=test%2Fwormhole_static_test.c;h=f2d4bf6e763bb616bc488454341039b0d2dc7114;hb=a41c6f5f26b3a44009f4aff3df3f83b9a79ace01;hp=7a4246f9f7020a5b26c482de864754e1b0f6a0d5;hpb=8dd46415b94b33fa960bdd5732e909ffc4859520;p=ric-plt%2Flib%2Frmr.git diff --git a/test/wormhole_static_test.c b/test/wormhole_static_test.c index 7a4246f..f2d4bf6 100644 --- a/test/wormhole_static_test.c +++ b/test/wormhole_static_test.c @@ -1,14 +1,14 @@ // : vi ts=4 sw=4 noet : /* ================================================================================== - Copyright (c) 2019 Nokia - Copyright (c) 2018-2019 AT&T Intellectual Property. + Copyright (c) 2019 Nokia + Copyright (c) 2018-2019 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. You may obtain a copy of the License at - http://www.apache.org/licenses/LICENSE-2.0 + http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, @@ -41,13 +41,14 @@ /* Note that the last tests in this function destroy the context and message so - any tests added MUST be ahead of those tests. + any tests added MUST be ahead of those tests. */ static int worm_test( ) { uta_ctx_t* ctx; // context needed to test load static rt 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; @@ -100,11 +101,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)" );