X-Git-Url: https://gerrit.o-ran-sc.org/r/gitweb?a=blobdiff_plain;f=test%2Fmbuf_api_test.c;h=30427b11b3c2fff64d58f685ff8dc7d0b680ef06;hb=d710957ed5d73bf2da2ceea3f5a1a3c509275c30;hp=858efdc2d21b76d4872fab5a06420942b36faec6;hpb=9e0c1e70ff256eb05ad29d2fa8252b6219cb3659;p=ric-plt%2Flib%2Frmr.git diff --git a/test/mbuf_api_test.c b/test/mbuf_api_test.c index 858efdc..30427b1 100644 --- a/test/mbuf_api_test.c +++ b/test/mbuf_api_test.c @@ -22,6 +22,10 @@ /* Mnemonic: mbuf_api_test.c Abstract: Unit tests for the mbuf common API functions. + To allow the mbuf functions to be tested without the bulk of the + RMr mechanics, we dummy up a couple of functions that are in + rmr[_nng].c. + Author: E. Scott Daniels Date: 2 April 2019 */ @@ -45,6 +49,47 @@ #include "test_support.c" // our private library of test tools #include "mbuf_api_static_test.c" // test functions +// --- dummies ------------------------------------------------------------------- + +/* + This will leak, but we're not here to test free. +*/ +extern void rmr_free_msg( rmr_mbuf_t* mbuf ) { + return; +} + +/* + Minimal buffer realloc to allow api to be tested without coverage hit if + we actually pulled in the sr static set. + + WARNING: this is NOT a complete realloc. We assume that we are testing + just the trace length adjustment portion of the set_trace() + API and are not striving to test the real realloc function. That + will be tested when the mbuf_api_static_test code is used by the + more generic RMr test. So, not all fields in the realloc'd buffer + can be used. +*/ +extern rmr_mbuf_t* rmr_realloc_msg( rmr_mbuf_t* msg, int new_tr_size ) { + rmr_mbuf_t* new_msg; + uta_mhdr_t* hdr; + + new_msg = (rmr_mbuf_t *) malloc( sizeof *new_msg ); + new_msg->tp_buf = (void *) malloc( 2048 ); + memset( new_msg->tp_buf, 0, 2048 ); + hdr = (uta_mhdr_t*) new_msg->tp_buf; + SET_HDR_LEN( hdr ); + SET_HDR_TR_LEN( hdr, new_tr_size ); + + new_msg->payload = new_msg->tp_buf + new_tr_size; + new_msg->header = new_msg->tp_buf; + new_msg->alloc_len = 2048; + new_msg->len = msg->len; + + return new_msg; +} + +// -------------------------------------------------------------------------------- + int main( ) { int errors = 0;