X-Git-Url: https://gerrit.o-ran-sc.org/r/gitweb?a=blobdiff_plain;f=test%2Frt_static_test.c;h=9559004d06dab3cf55f6928964b6ecb14bf1b65b;hb=20829ec38b851e7894883ba6b1711ccf8d05c3f4;hp=6d416ef68780dbb57f418539a5cf819369ca40a1;hpb=6511ac74cdc367a94bffeb3743624775acd52c5b;p=ric-plt%2Flib%2Frmr.git diff --git a/test/rt_static_test.c b/test/rt_static_test.c index 6d416ef..9559004 100644 --- a/test/rt_static_test.c +++ b/test/rt_static_test.c @@ -123,6 +123,7 @@ static int rt_test( ) { char *buf; char* seed_fname; // seed file nng_socket nn_sock; // this is a struct in nng, so difficult to validate + rmr_mbuf_t* mbuf; // message for meid route testing setenv( "ENV_VERBOSE_FILE", ".ut_rmr_verbose", 1 ); // allow for verbose code in rtc to be driven i = open( ".ut_rmr_verbose", O_RDWR | O_CREAT, 0644 ); @@ -250,8 +251,10 @@ static int rt_test( ) { ep = uta_get_ep( rt, "bad_name:4560" ); errors += fail_not_nil( ep, "end point (fetch by name with bad name)" ); - state = uta_epsock_byname( rt, "localhost:4561", &nn_sock ); // this should be found + ep = NULL; + state = uta_epsock_byname( rt, "localhost:4561", &nn_sock, &ep ); // this should be found errors += fail_if_equal( state, 0, "socket (by name)" ); + errors += fail_if_nil( ep, "epsock_byname did not populate endpoint pointer when expected to" ); //alt_value = uta_epsock_byname( rt, "localhost:4562" ); // we might do a memcmp on the two structs, but for now nothing //errors += fail_if_equal( value, alt_value, "app1/app2 sockets" ); @@ -290,7 +293,7 @@ static int rt_test( ) { rte = uta_get_rte( rt, 0, 1, FALSE ); // get an rte for the next loop if( rte ) { for( i = 0; i < 10; i++ ) { // round robin return value should be different each time - value = uta_epsock_rr( rte, 0, &more, &nn_sock ); // msg type 1, group 1 + value = uta_epsock_rr( rte, 0, &more, &nn_sock, &ep ); // msg type 1, group 1 errors += fail_if_equal( value, alt_value, "round robiin sockets with multiple end points" ); errors += fail_if_false( more, "more for mtype==1" ); alt_value = value; @@ -301,7 +304,7 @@ static int rt_test( ) { rte = uta_get_rte( rt, 0, 3, FALSE ); // get an rte for the next loop if( rte ) { for( i = 0; i < 10; i++ ) { // this mtype has only one endpoint, so rr should be same each time - value = uta_epsock_rr( rte, 0, NULL, &nn_sock ); // also test ability to deal properly with nil more pointer + value = uta_epsock_rr( rte, 0, NULL, &nn_sock, &ep ); // also test ability to deal properly with nil more pointer if( i ) { errors += fail_not_equal( value, alt_value, "round robin sockets with one endpoint" ); errors += fail_not_equal( more, -1, "more value changed in single group instance" ); @@ -311,12 +314,13 @@ static int rt_test( ) { } rte = uta_get_rte( rt, 11, 3, TRUE ); - state = uta_epsock_rr( rte, 22, NULL, NULL ); + state = uta_epsock_rr( rte, 22, NULL, NULL, &ep ); errors += fail_if_true( state, "uta_epsock_rr returned bad (non-zero) state when given nil socket pointer" ); + uta_rt_clone( NULL ); // verify null parms don't crash things uta_rt_drop( NULL ); - uta_epsock_rr( NULL, 0, &more, &nn_sock ); // drive null case for coverage + uta_epsock_rr( NULL, 0, &more, &nn_sock, &ep ); // drive null case for coverage uta_add_rte( NULL, 99, 1 ); uta_get_rte( NULL, 0, 1000, TRUE ); @@ -365,6 +369,25 @@ static int rt_test( ) { state = uta_link2( ep ); errors += fail_if_true( state, "link2 did not return false when given nil pointers" ); + // ----------------- test the meid support for looking up an endpoint based on the meid in the message ----- + + ctx->my_name = strdup( "my_host_name" ); // set up to load a rtable + ctx->my_ip = strdup( "192.168.1.30" ); + gen_rt( ctx ); // generate a route table with meid entries and hang off ctx + + mbuf = rmr_alloc_msg( ctx, 2048 ); // buffer to play with + mbuf->len = 100; + rmr_str2meid( mbuf, "meid1" ); // id that we know is in the map + + ep = NULL; // force to nil so we see it go non-nil + state = epsock_meid( ctx->rtable, mbuf, &nn_sock, &ep ); + errors += fail_if_nil( ep, "ep was nil when looking up ep with known meid in message" ); + errors += fail_not_equal( state, 1, "state was not true when looking up ep with known meid in message" ); + + rmr_str2meid( mbuf, "XXXmeid1" ); // id that we know is NOT in the map + state = epsock_meid( ctx->rtable, mbuf, &nn_sock, &ep ); + // it is NOT a valid check to test ep for nil -- epsock_mied doesn't guarentee ep is set/cleared when state is false + errors += fail_not_equal( state, 0, "state was not false when looking up ep with unknown meid in message" ); return !!errors; // 1 or 0 regardless of count }