X-Git-Url: https://gerrit.o-ran-sc.org/r/gitweb?a=blobdiff_plain;f=test%2Ftest_support.c;h=d14678b7bd724a934ff5586d6820231253182d96;hb=9c923bcc9322c22220b574671c7b46f10008c614;hp=084256f482ed4fd9c29d283ccec6112937b974c8;hpb=d9de79acd9c205dc4f795e90a98331628ed6c85b;p=ric-plt%2Flib%2Frmr.git diff --git a/test/test_support.c b/test/test_support.c index 084256f..d14678b 100644 --- a/test/test_support.c +++ b/test/test_support.c @@ -1,8 +1,8 @@ -// : vi ts=4 sw=4 noet : +// vi: ts=4 sw=4 noet : /* ================================================================================== - Copyright (c) 2019 Nokia - Copyright (c) 2018-2019 AT&T Intellectual Property. + Copyright (c) 2019-2020 Nokia + Copyright (c) 2018-2020 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. @@ -37,6 +37,33 @@ #include #include +/* + This is ugly, but needed to allow for component testing. + + The test code (e.g. foo_test.c and not foo_static_test.c) can include these + constants to turn off the import of test support files: + NO_EMULATION -- the transport emulation will not be included + NO_PRIVATE_HEADERS -- the private headers for the transport component of RMR + (e.g. si) will not be included. +*/ +#ifndef NO_EMULATION // assume emulation unless specifically put off (love double negatives) + #ifdef NNG_UNDER_TEST + #define TP_HDR_LEN 0 // needed for support functions but nonexistant in nng world + #include "test_nng_em.c" // nano/ngg emulation functions + #else + #include "test_si95_em.c" // si emulation functions + #endif +#endif + +#ifndef NO_PRIVATE_HEADERS // include transport headers unless specifically turned off + #ifdef NNG_UNDER_TEST + #include // context things are type sensitive + #else + #include "si95/socket_if.h" // need to have the si context more than anything else + #include + #endif +#endif + #ifndef BAD #define BAD 1 // these are exit codes unless user overrides #define GOOD 0 @@ -167,9 +194,10 @@ static rmr_mbuf_t* test_mk_msg( int len, int tr_len ) { uta_mhdr_t* hdr; size_t alen; - alen = sizeof( *hdr ) + tr_len + len; // this does no support allocating len2 and len3 data fields + alen = sizeof( *hdr ) + tr_len + len + TP_HDR_LEN; // this does no support allocating len2 and len3 data fields new_msg = (rmr_mbuf_t *) malloc( sizeof *new_msg ); + memset( new_msg, 0, sizeof( *new_msg ) ); new_msg->tp_buf = (void *) malloc( alen ); memset( new_msg->tp_buf, 0, alen );