X-Git-Url: https://gerrit.o-ran-sc.org/r/gitweb?a=blobdiff_plain;f=test%2Ftest_support.c;h=f0365909a7f170d59934656f49ffaba3a87a4511;hb=refs%2Fchanges%2F31%2F131%2F1;hp=4ed976c4a6def6cf2cb25e910dbc8b2d943c0096;hpb=8dd46415b94b33fa960bdd5732e909ffc4859520;p=ric-plt%2Flib%2Frmr.git diff --git a/test/test_support.c b/test/test_support.c index 4ed976c..f036590 100644 --- a/test/test_support.c +++ b/test/test_support.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, @@ -65,7 +65,7 @@ void sig_clean_exit( int sign ) { exit( 0 ); } -/* +/* Setup all of the signal handling for signals that we want to force a clean exit: term, intr, hup, quit, usr1/2 alarm, etc. All others we'll let default. */ @@ -74,7 +74,7 @@ static void set_signals( void ) { int sig_list[] = { SIGINT, SIGQUIT, SIGILL, SIGALRM, SIGTERM, SIGUSR1 , SIGUSR2 }; int i; int nele; // number of elements in the list - + nele = (int) ( sizeof( sig_list )/sizeof( int ) ); // convert raw size to the number of elements for( i = 0; i < nele; i ++ ) { memset( &sa, 0, sizeof( sa ) ); @@ -138,4 +138,33 @@ static int fail_if_equal( int a, int b, char* what ) { return a != b ? GOOD : BAD; // user may override good/bad so do NOT return a==b directly! } + +#ifndef NO_DUMMY_RMR +/* + Dummy message allocator for testing without sr_static functions +*/ +static rmr_mbuf_t* test_mk_msg( int len, int tr_len ) { + rmr_mbuf_t* new_msg; + uta_mhdr_t* hdr; + size_t alen; + + alen = sizeof( *hdr ) + tr_len + len; + + new_msg = (rmr_mbuf_t *) malloc( sizeof *new_msg ); + new_msg->tp_buf = (void *) malloc( alen ); + memset( new_msg->tp_buf, 0, alen ); + + hdr = (uta_mhdr_t*) new_msg->tp_buf; + SET_HDR_LEN( hdr ); + SET_HDR_TR_LEN( hdr, tr_len ); + + new_msg->header = new_msg->tp_buf; + new_msg->payload = new_msg->header + PAYLOAD_OFFSET( hdr ); + new_msg->alloc_len = alen; + new_msg->len = 0; + + return new_msg; +} +#endif + #endif