+
// : vi ts=4 sw=4 noet :
/*
==================================================================================
- Copyright (c) 2019 Nokia
- Copyright (c) 2018-2019 AT&T Intellectual Property.
+ Copyright (c) 2019-2021 Nokia
+ Copyright (c) 2018-2021 AT&T Intellectual Property.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
k = (uint64_t) sid << 32;
k += mtype;
-fprintf( stderr, "<INFO> build key: %x %x --> %llx\n", (int) mtype, (int) sid, (long long) k );
+ fprintf( stderr, "<INFO> build key: %x %x --> %llx\n", (int) mtype, (int) sid, (long long) k );
return k;
}
+/*
+ Create a very large set of things to clone and ensure that the colleciton
+ buffers are properly resized without errors.
+*/
+static int lg_clone_test( ) {
+ int errors = 0;
+ uta_ctx_t* ctx;
+ char* old_env;
+ route_table_t* p;
+
+ old_env = getenv( "RMR_SEED_RT" );
+ setenv( "RMR_SEED_RT", "./large_meid.rt", 1 );
+
+ ctx = mk_dummy_ctx();
+
+ read_static_rt( ctx, 0 );
+ p = uta_rt_clone( ctx, ctx->rtable, NULL, 1 ); // clone to force the copy from the existing table
+ errors += fail_if_nil( p, "clone of large table returned nil" );
+ if( p != NULL ) {
+ errors += fail_not_equal( p->error, 0, "clone of large table had error" );
+ }
+
+ setenv( "RMR_SEED_RT", old_env, 1 );
+
+ return errors;
+}
+
/*
This is the main route table test. It sets up a very specific table
for testing (not via the generic setup function for other test
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
}
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
#endif
// ---------------- misc coverage tests --------------------------------------------------------------------------
- collect_things( NULL, NULL, NULL, NULL, NULL ); // these both return null, these test NP checks
- collect_things( NULL, NULL, NULL, NULL, (void *) 1234 ); // the last is an invalid pointer, but check needed to force check on previous param
- del_rte( NULL, NULL, NULL, NULL, NULL );
+ collect_things( NULL, NULL, NULL, NULL, NULL ); // these both return null, these test NP checks
+ collect_things( NULL, NULL, NULL, NULL, (void *) 1234 ); // the last is an invalid pointer, but check needed to force check on previous param
+ del_rte( NULL, NULL, NULL, NULL, NULL );
+
+ ctx = mk_dummy_ctx();
+ roll_tables( ctx ); // drive nil rt check
+
+
+
+ // ------ specific edge case tests -------------------------------------------------------------------------------
+ errors += lg_clone_test( );
- return !!errors; // 1 or 0 regardless of count
+ return errors; // 1 or 0 regardless of count
}