Push package ver 4.2.1 out of pkg-cloud staging
[ric-plt/lib/rmr.git] / test / rt_static_test.c
index d87a743..1647993 100644 (file)
@@ -98,6 +98,7 @@ fprintf( stderr, "<INFO> build key: %x %x --> %llx\n", (int) mtype, (int) sid, (
 */
 static int rt_test( ) {
        uta_ctx_t* ctx;                 // context needed to test load static rt
+       uta_ctx_t* pctx;                // "private" context for route manager communication tests
        route_table_t* rt;              // route table
        route_table_t* crt;             // cloned route table
        rtable_ent_t*   rte;    // route table entries from table
@@ -426,9 +427,11 @@ static int rt_test( ) {
 
 
        ep = (endpoint_t *) malloc( sizeof( *ep ) );
+       memset( ep, 0, sizeof( ep ) );
        pthread_mutex_init( &ep->gate, NULL );
        ep->name = strdup( "worm" );
        ep->addr = NULL;
+       ep->notify = 1;
        #ifdef NNG_UNDER_TEST
                state = uta_link2( ep );
        #else
@@ -457,6 +460,7 @@ static int rt_test( ) {
 
        #ifndef NNG_UNDER_TEST
                ep->open = 0;                                                   // context is used only if ep not open, so to check this test close the ep
+               ep->notify = 1;
                state = rt_link2_ep( NULL, ep );
                errors += fail_if_true( state, "rt_link2_ep returned true when given bad context" );
 
@@ -521,6 +525,36 @@ static int rt_test( ) {
                errors += fail_not_equal( state, 0, "epsock_meid returned true when given nil socket pointer" );
        #endif
 
+       // ------------  debugging and such; coverage only calls ----------------------------------------------------------
+               ep_stats( ctx->rtable, NULL, "name", NULL, NULL );                      // ensure no crash when given nil pointer
+               rt_epcounts( ctx->rtable, "testing" );
+               rt_epcounts( NULL, "testing" );
+
+               buf = ensure_nlterm( strdup( "Stand up and cheer!" ) );                                 // force addition of newline
+               if( buf ) {
+                       errors += fail_not_equal( strcmp( buf, "Stand up and cheer!\n" ), 0, "ensure nlterm didn't add newline" );
+                       free( buf );
+                       buf = NULL;
+               }
+
+
+       // ------------- route manager request/response funcitons -------------------------------------------------------
+               {
+                       rmr_mbuf_t*     smsg;
+
+                       smsg = rmr_alloc_msg( ctx, 1024 );
+                       send_rt_ack( ctx, smsg, "123456", 0, "no reason" );
+
+                       pctx = mk_dummy_ctx();
+                       ctx->rtg_whid = -1;
+                       state = send_update_req( pctx, ctx );
+                       errors += fail_not_equal( state, 0, "send_update_req did not return 0" );
+
+                       ctx->rtg_whid = rmr_wh_open( ctx, "localhost:19289" );
+                       state = send_update_req( pctx, ctx );
+                       errors += fail_if_equal( state, 0, "send_update_req to an open whid did not return 0" );
+               }
+
 
        // ------------- si only; fd to ep conversion functions ---------------------------------------------------------
        #ifndef NNG_UNDER_TEST