Add additional env variable dump during init 21/4521/2 4.2.1
authorE. Scott Daniels <daniels@research.att.com>
Tue, 4 Aug 2020 17:48:47 +0000 (13:48 -0400)
committerE. Scott Daniels <daniels@research.att.com>
Fri, 7 Aug 2020 13:38:28 +0000 (09:38 -0400)
If the RMR_LOG_VLEVEL environment is set to 4 or greater
the settingf for the environment variables that are
significant to RMR are written to stderr.

Issue-ID: RIC-630

Signed-off-by: E. Scott Daniels <daniels@research.att.com>
Change-Id: I6709f2c6d6c592494b0a7edbf23b6bd234715262

CHANGES_CORE.txt
CMakeLists.txt
docs/rel-notes.rst
src/rmr/common/src/rtc_static.c
src/rmr/common/src/tools_static.c
src/rmr/si/src/rmr_si.c
test/rmr_si_api_static_test.c
test/sr_si_static_test.c
test/tools_static_test.c
test/tools_test.c

index c325496..4df9b24 100644 (file)
@@ -5,6 +5,10 @@
 # API and build change  and fix summaries. Doc correctsions
 # and/or changes are not mentioned here; see the commit messages.
 
+2020 August 4; Version 4.2.1
+       Add additional environment variable dump if RMR_LOG_VLEVEL set to
+       4 at start.
+
 2020 August 3; Version 4.2.0
        Add support for the RMR_RTREQ_FREQ environment variable to control
        the request frequency for a new route table (default 5s if not
index 4a936fd..2479654 100644 (file)
@@ -41,7 +41,7 @@ cmake_minimum_required( VERSION 3.5 )
 
 set( major_version "4" )               # should be automatically populated from git tag later, but until CI process sets a tag we use this
 set( minor_version "2" )
-set( patch_level "0" )
+set( patch_level "1" )
 
 set( install_root "${CMAKE_INSTALL_PREFIX}" )
 set( install_inc "include/rmr" )
index e6ac54b..3399fe4 100644 (file)
@@ -22,6 +22,14 @@ the need to leap frog versions ceased, and beginning with
 version 4.0.0, the RMR versions should no longer skip.
 
 
+2020 August 4; Version 4.2.1
+----------------------------
+
+Add additional environment variable dump if RMR_LOG_VLEVEL
+set to 4 at start.
+
+
+
 2020 August 3; Version 4.2.0
 ----------------------------
 
index e92e53d..c1bad15 100644 (file)
@@ -279,7 +279,7 @@ static void* rtc( void* vctx ) {
                rt_req_freq = atoi( eptr );
                if( rt_req_freq < 1 || rt_req_freq > 300 ) {
                        rt_req_freq = DEF_RTREQ_FREQ;
-                       rmr_vlog( RMR_VL_WARN, "rmr_rtc: RT request frequency (%s) out of range (1-300), using default", DEF_RTREQ_FREQ );
+                       rmr_vlog( RMR_VL_WARN, "rmr_rtc: RT request frequency (%d) out of range (1-300), using default", DEF_RTREQ_FREQ );
                }
        }
        rmr_vlog( RMR_VL_INFO, "rmr_rtc: RT request frequency set to: %d seconds", rt_req_freq );
index b4245cd..df49dd8 100644 (file)
@@ -29,6 +29,9 @@
 
                                        uta_link2       -- establish a nanomsg connection to a host
 
+                                       uta_dump_env -- dump the environment variables to stdout that are
+                                                               of importance to RMR.
+
        Author:         E. Scott Daniels
        Date:           30 November 2018
 */
@@ -88,9 +91,9 @@ static int uta_tokenise( char* buf, char** tokens, int max, char sep ) {
        Given a buffer of 'sep' separated tokens, and a list of things,
        return up to max tokens with any tokens that matched things in
        the list. Toks is the user supplied array of char* which we will
-       fill in (up to max) with pointers to tokens from buf.  This 
-       damages buf, so the caller must dup the string if it must be 
-       preserved for later, original, use.  The pointers returned in 
+       fill in (up to max) with pointers to tokens from buf.  This
+       damages buf, so the caller must dup the string if it must be
+       preserved for later, original, use.  The pointers returned in
        toks will reference portions of bufs.
 
        Returns the number of tokens referenced by toks.
@@ -102,7 +105,7 @@ static int uta_rmip_tokenise( char* buf, if_addrs_t* iplist, char** toks, int ma
        int i;
        int j;
 
-       
+
        all_toks = malloc( sizeof( char * ) * max );                                    // refernce to all tokens; we'll prune
        pcount = ntoks = uta_tokenise( buf, all_toks, max, sep );               // split them up
        j = 0;
@@ -284,7 +287,7 @@ static int uta_has_str( char const* buf, char const* str, char sep, int max ) {
        to the list so that we don't pick up entries from the rtable that are for other
        processes listening on different interfaces.
 
-       The ENV_BIN_IF environment variable may be either an IP address (v6 must be in 
+       The ENV_BIN_IF environment variable may be either an IP address (v6 must be in
        square braces), or an interface name (e.g. eth0).
 */
 if_addrs_t*  mk_ip_list( char* port ) {
@@ -460,4 +463,37 @@ static char* get_default_ip( if_addrs_t* iplist ) {
        return NULL;
 }
 
+/*
+       Write all environment variables that we consider to be important to stderr.
+*/
+static void uta_dump_env( ) {
+       char* token;
+       char* elist[] = {
+                       ENV_BIND_IF,
+                       ENV_RTG_PORT,
+                       ENV_RTG_ADDR,
+                       ENV_SEED_RT,
+                       ENV_SEED_MEMAP,
+                       ENV_RTG_RAW,
+                       ENV_VERBOSE_FILE,
+                       ENV_NAME_ONLY,
+                       ENV_WARNINGS,
+                       ENV_SRC_ID,
+                       ENV_LOG_HR,
+                       ENV_LOG_VLEVEL,
+                       ENV_CTL_PORT,
+                       ENV_RTREQ_FREA
+       };
+       int i;
+
+       for( i = 0; i < sizeof( elist ) / sizeof( char *); i ++ ) {
+               token = getenv( elist[i] );
+               if( token != NULL ) {
+                       rmr_vlog( RMR_VL_INFO, "dump_env: %s = '%s'\n", elist[i], token );
+               } else {
+                       rmr_vlog( RMR_VL_INFO, "dump_env: %s = <unset>\n", elist[i] );
+               }
+       }
+}
+
 #endif
index 7a2bc96..93475f9 100644 (file)
@@ -556,14 +556,16 @@ static void* init(  char* uproto_port, int def_msg_size, int flags ) {
        int             old_vlevel;
 
        old_vlevel = rmr_vlog_init();                   // initialise and get the current level
-       rmr_set_vlevel( RMR_VL_INFO );          // we WILL announce our version etc
 
        if( ! announced ) {
+               rmr_set_vlevel( RMR_VL_INFO );          // we WILL announce our version
                rmr_vlog( RMR_VL_INFO, "ric message routing library on SI95/g mv=%d flg=%02x (%s %s.%s.%s built: %s)\n",
                        RMR_MSG_VER, flags, QUOTE_DEF(GIT_ID), QUOTE_DEF(MAJOR_VER), QUOTE_DEF(MINOR_VER), QUOTE_DEF(PATCH_VER), __DATE__ );
                announced = 1;
+
+               rmr_set_vlevel( old_vlevel );           // return logging to the desired state
+               uta_dump_env();                                                 // spit out environment settings meaningful to us if in info mode
        }
-       rmr_set_vlevel( old_vlevel );           // return logging to the desired state
 
        errno = 0;
        if( uproto_port == NULL ) {
index b7f97bf..5424e98 100644 (file)
@@ -264,6 +264,25 @@ static int rmr_api_test( ) {
        rmr_set_low_latency( NULL );
        rmr_set_fack( NULL );
 
+
+       msg2 = rmr_alloc_msg( rmc,  1024 );
+       msg2 = rmr_rcv_msg( NULL, msg2 );
+       if( msg2 != NULL ) {
+               errors += fail_if( msg2->state == RMR_OK, "nil context check for rcv msg returned OK" );
+       }
+       msg2 = rmr_torcv_msg( NULL, msg2, 200 );
+       if( msg2 != NULL ) {
+               errors += fail_if( msg2->state == RMR_OK, "nil context check for torcv msg returned OK" );
+       }
+
+       //  ----- thread start coverage ---------------------------------------------------------------------------
+       setenv( "RMR_WARNINGS", "1", 1 );       // force non-default branches during these tests
+       setenv( "RMR_SRC_NAMEONLY", "1", 1 );
+
+       rmr_init( ":6789", 1024, 0 );           // threaded mode with defined/default RM target
+       setenv( "RMR_RTG_SVC", "-1", 1 );       // force into static table mode
+       rmr_init( ":6789", 1024, 0 );           // threaded mode with static table
+
        // --------------- phew, done ------------------------------------------------------------------------------
 
        if( ! errors ) {
index be99359..e3b5a77 100644 (file)
@@ -147,6 +147,10 @@ static int sr_si_test() {
        rtc_file( NULL );                       // the static file only collector
        rtc_file( ctx );
 
+       setenv( "RMR_RTREQ_FREQ", "400", 1 );   // force error checking code in rtc to resort to default
+       rtc( ctx );
+
+       setenv( "RMR_CTL_PORT", "43086", 1 );   // force defined branch in rtc
        rtc( ctx );
 
        setenv( "RMR_RTG_SVC", "4567", 1 );             // drive for edge case coverage to ensure no nil pointer etc
index 0269522..f1c2ffc 100644 (file)
@@ -77,6 +77,8 @@ static int tools_test( ) {
        void*   if_list;
 
 
+       uta_dump_env();
+
        // ------------------ tokenise tests -----------------------------------------------------------
        dbuf = strdup( buf );
        i = uta_tokenise( dbuf, tokens, 127, ',' );
index 3a09d44..fb6aafa 100644 (file)
@@ -45,6 +45,7 @@
 #define NO_EMULATION
 #include "test_support.c"              // our private library of test tools
 
+#include "logging.c"           // tools references logging, so pull in too
 #include "tools_static.c"
 
 #include "tools_static_test.c"