*/
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
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
#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" );
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