Correct table clear bug in route table ready
[ric-plt/lib/rmr.git] / test / rmr_nng_api_static_test.c
index ca2e6f2..6588907 100644 (file)
@@ -122,16 +122,25 @@ static int rmr_api_test( ) {
                return 1;
        }
 
+       setenv( "RMR_SRC_ID", "somehost", 1 );                                                          // context should have this as source
        if( (rmc2 = rmr_init( ":6789", 1024, FL_NOTHREAD )) == NULL ) {         // init without starting a thread
                errors += fail_if_nil( rmc, "rmr_init returned a nil pointer for non-threaded init "  );
        }
 
+       fprintf( stderr, "<INFO> with RMR_SRC_ID env set, source name in context: (%s)\n", ((uta_ctx_t *) rmc2)->my_name );
+       v = strcmp( ((uta_ctx_t *) rmc2)->my_name, "somehost:6789" );
+       errors += fail_not_equal( v, 0, "source name not set from environment variable (see previous info)" );
        free_ctx( rmc2 );                       // coverage
-
+       
+       unsetenv( "RMR_SRC_ID" );                                                                                               // context should NOT have our artificial name 
        if( (rmc2 = rmr_init( NULL, 1024, FL_NOTHREAD )) == NULL ) {                    // drive default port selector code
                errors += fail_if_nil( rmc, "rmr_init returned a nil pointer when driving for default port "  );
        }
 
+       fprintf( stderr, "<INFO> after unset of RMR_SRC_ID, source name in context: (%s)\n", ((uta_ctx_t *) rmc2)->my_name );
+       v = strcmp( ((uta_ctx_t *) rmc2)->my_name, "somehost:6789" );
+       errors += fail_if_equal( v, 0, "source name smells when removed from environment (see previous info)" );
+       free_ctx( rmc2 );                       // attempt to reduce leak check errors
 
        v = rmr_ready( rmc );           // unknown return; not checking at the moment
 
@@ -265,6 +274,8 @@ static int rmr_api_test( ) {
        snprintf( msg->xaction, 17, "%015d", 16 );              // dummy transaction id (emulation generates, this should arrive after a few calls to recv)
        msg->mtype = 0;
        msg->sub_id = -1;
+       em_set_rcvcount( 0 );                                                   // reset message counter
+       em_set_rcvdelay( 1 );                                                   // force slow msg rate during mt testing
        msg = rmr_call( rmc, msg );                                             // dummy nng/nano function will sequentually add xactions and should match or '16'
        errors += fail_if_nil( msg, "rmr_call returned a nil message on call expected to succeed "  );
        if( msg ) {
@@ -435,10 +446,14 @@ static int rmr_api_test( ) {
                errors += fail_if_nil( msg, "mt_call with known xaction id returned nil message" );
        }
        fprintf( stderr, "<INFO> time check: %ld\n", time( NULL ) );
-               
 
        em_set_mtc_msgs( 0 );                                                   // turn off 
-       em_set_rcvdelay( 0 );                                                   // full speed receive rate
+       em_set_rcvdelay( 0 );                                                   // full speed receive rate to overflow the ring
+
+       fprintf( stderr, "<INFO> pausing 5s to allow mt-call receive ring to fill  %ld\n", time( NULL ) );
+       sleep( 2 );
+       fprintf( stderr, "<INFO> tests continuing %ld\n", time( NULL ) );
+       em_set_rcvdelay( 1 );                                                   // restore slow receive pace for any later tests
        ((uta_ctx_t *)rmc)->shutdown = 1;                               // force the mt-reciver attached to the context to stop
 #endif