X-Git-Url: https://gerrit.o-ran-sc.org/r/gitweb?a=blobdiff_plain;f=test%2Fsr_nng_static_test.c;h=809deba071a3dc610f31390cac2a0440d53e52b2;hb=412d53dfa2f9b5b56a448797d0dfec3b0f11f666;hp=49977065b4d548780320a3e9d5de38fdf35f6362;hpb=a41c6f5f26b3a44009f4aff3df3f83b9a79ace01;p=ric-plt%2Flib%2Frmr.git diff --git a/test/sr_nng_static_test.c b/test/sr_nng_static_test.c index 4997706..809deba 100644 --- a/test/sr_nng_static_test.c +++ b/test/sr_nng_static_test.c @@ -34,12 +34,18 @@ #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" /* Generate a simple route table (for all but direct route table testing). + This gets tricky inasmuch as we generate two in one; first a whole table + and then two update tables. The first is a table with a bad counter in the + last record to test that we don't load that table and error. The second + is a good update. */ static void gen_rt( uta_ctx_t* ctx ) { int fd; @@ -71,9 +77,24 @@ static void gen_rt( uta_ctx_t* ctx ) { } setenv( "RMR_SEED_RT", "utesting.rt", 1 ); + write( fd, rt_stuff, strlen( rt_stuff ) ); // write in the whole table + + rt_stuff = + "updatert|start\n" // this is an update to the table + "mse|4|99|fooapp:9999,barapp:9999;logger:9999\n" // update just one entry + "updatert|end | 3\n"; // bad count; this update should be rejected + write( fd, rt_stuff, strlen( rt_stuff ) ); + + rt_stuff = + "updatert|start\n" // this is an update to the table + "mse|4|10|fooapp:4561,barapp:4561;logger:9999\n" // update just one entry + "del|2|-1\n" // delete an entry; not there so no action + "del|2|10\n" // delete an entry + "updatert|end | 3\n"; // end table; updates have a count as last field write( fd, rt_stuff, strlen( rt_stuff ) ); + close( fd ); - read_static_rt( ctx, 0 ); + read_static_rt( ctx, 1 ); // force in verbose mode to see stats on tty if failure unlink( "utesting.rt" ); } @@ -143,7 +164,7 @@ static int sr_nng_test() { mbuf = rmr_rcv_msg( ctx, NULL ); } - size = 2048 - sizeof( uta_mhdr_t ); // emulated nng receive allocates 2K payloads + size = 2048 - em_hdr_size(); // emulated nng receive allocates 2K buffers -- subtract off header size state = rmr_payload_size( mbuf ); errors += fail_not_equal( state, size, "payload size didn't return expected value" ); // receive should always give 4k buffer