Ensure RT incremental update not applied early

This change ensures that a full table has been provided by the
route generator (route manager) prior to RMR accepting any
incremental updates.

The change also captures the initial value of the RMR_SEED
environment variable such that it cannot be changed once it has
been used.

Issue-ID: RIC-329

Signed-off-by: E. Scott Daniels <daniels@att.com>
Change-Id: I168cb42905e41641590130de724965e8dbca67e6
diff --git a/test/rt_static_test.c b/test/rt_static_test.c
index 7a51bca..3bdd312 100644
--- a/test/rt_static_test.c
+++ b/test/rt_static_test.c
@@ -1,3 +1,4 @@
+
 // : vi ts=4 sw=4 noet :
 /*
 ==================================================================================
@@ -500,6 +501,10 @@
 		errors += fail_if_nil( ctx->rtable, "edge case route table didn't generate a pointer into the context" );
 
 		unsetenv( "RMR_SEED_RT" );			// remove for next read try
+		if( ctx && ctx->seed_rt_fname != NULL ) {
+			free( ctx->seed_rt_fname );
+			ctx->seed_rt_fname = NULL;
+		}
 		read_static_rt( ctx, 0 );			// drive for not there coverage
 	}
 
@@ -571,6 +576,10 @@
 	ctx->rtable = NULL;
 	ctx->my_name = strdup( "my_host_name" );		// set up to load a rtable
 	ctx->my_ip = strdup( "192.168.1.30" );
+	if( ctx && ctx->seed_rt_fname != NULL ) {
+		free( ctx->seed_rt_fname );
+		ctx->seed_rt_fname = NULL;
+	}
 	gen_rt( ctx );									// generate a route table with meid entries and hang off ctx
 
 	mbuf = rmr_alloc_msg( ctx, 2048 );               //  buffer to play with
diff --git a/test/test_ctx_support.c b/test/test_ctx_support.c
index d15239a..cd3f14e 100644
--- a/test/test_ctx_support.c
+++ b/test/test_ctx_support.c
@@ -45,6 +45,7 @@
 	}
 
 	memset( ctx, 0, sizeof( *ctx ) );
+	ctx->snarf_rt_fd = -1;
 
 	return ctx;
 }
@@ -70,6 +71,7 @@
 	ctx->si_ctx = malloc( 1024 );
 	ctx->my_name = strdup( "hostname1" );
 	ctx->my_ip = strdup( "123.45.67.89" );
+	ctx->snarf_rt_fd = -1;
 
 	ctx->rtgate = (pthread_mutex_t *) malloc( sizeof( *ctx->rtgate ) );
     if( ctx->rtgate != NULL ) {
diff --git a/test/test_gen_rt.c b/test/test_gen_rt.c
index 79b413f..5748ca1 100644
--- a/test/test_gen_rt.c
+++ b/test/test_gen_rt.c
@@ -45,6 +45,7 @@
 	int		fd;
 	char* 	rt_stuff;		// strings for the route table
 
+ctx->flags |= 0x08;
 	fd = open( "utesting.rt", O_WRONLY | O_CREAT, 0600 );
 	if( fd < 0 ) {
 		fprintf( stderr, "<BUGGERED> unable to open file for testing route table gen\n" );