Code Review
/
ric-plt
/
lib
/
rmr.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
review
|
tree
raw
|
inline
| side by side
Release RMR version 4.9.2
[ric-plt/lib/rmr.git]
/
test
/
test_gen_rt.c
diff --git
a/test/test_gen_rt.c
b/test/test_gen_rt.c
index
08c1276
..
8373d8d
100644
(file)
--- a/
test/test_gen_rt.c
+++ b/
test/test_gen_rt.c
@@
-31,12
+31,15
@@
/*
Generate a simple route table (for all but direct route table testing).
/*
Generate a simple route table (for all but direct route table testing).
- This gets tricky inasmuch as we generate two in one; first a whole table
+ This gets tricky inasmuch as we generate two in one; first a whole table
and then two update tables. The first is a table with a bad counter in the
last record to test that we don't load that table and error. The second
is a good update. The same applies to the meid map; first has a bad counter
and some bad records to drive coverage testing. The end should leave a good
meid map in the table.
and then two update tables. The first is a table with a bad counter in the
last record to test that we don't load that table and error. The second
is a good update. The same applies to the meid map; first has a bad counter
and some bad records to drive coverage testing. The end should leave a good
meid map in the table.
+
+ Once the file is generated, it is forced in via static read and the file
+ is unlinked.
*/
static void gen_rt( uta_ctx_t* ctx ) {
int fd;
*/
static void gen_rt( uta_ctx_t* ctx ) {
int fd;
@@
-49,6
+52,8
@@
static void gen_rt( uta_ctx_t* ctx ) {
}
rt_stuff =
}
rt_stuff =
+ "updatert|start\n" // update check before whole table received
+ "updatert|end\n"
"newrt|end\n" // end of table check before start of table found
"# comment to drive full comment test\n"
"\n" // handle blank lines
"newrt|end\n" // end of table check before start of table found
"# comment to drive full comment test\n"
"\n" // handle blank lines
@@
-72,11
+77,11
@@
static void gen_rt( uta_ctx_t* ctx ) {
rt_stuff = // add an meid map which will fail
"meid_map | start\n"
rt_stuff = // add an meid map which will fail
"meid_map | start\n"
- "mme_ar | e2t-1 | one two three four\
n"
+ "mme_ar | e2t-1 | one two three four\
r" // also test bloody apple way with \r
"mme_del | one two\n"
"mme_del \n" // short entries drive various checks for coverage
"mme_del | one two\n"
"mme_del \n" // short entries drive various checks for coverage
- "mme_ar \n"
- "mme_ar | e2t-0 \n"
+ "mme_ar \n"
+ "mme_ar | e2t-0 \n"
"meid_map | end | 5\n"; // this will fail as the short recs don't "count"
write( fd, rt_stuff, strlen( rt_stuff ) );
"meid_map | end | 5\n"; // this will fail as the short recs don't "count"
write( fd, rt_stuff, strlen( rt_stuff ) );
@@
-108,7
+113,7
@@
static void gen_rt( uta_ctx_t* ctx ) {
"mme_del | meid11 meid12 meid13\n" // includes a non-existant meid
"meid_map | end | 1\n";
write( fd, rt_stuff, strlen( rt_stuff ) );
"mme_del | meid11 meid12 meid13\n" // includes a non-existant meid
"meid_map | end | 1\n";
write( fd, rt_stuff, strlen( rt_stuff ) );
-
+
close( fd );
read_static_rt( ctx, 1 ); // force in verbose mode to see stats on tty if failure
unlink( "utesting.rt" );
close( fd );
read_static_rt( ctx, 1 ); // force in verbose mode to see stats on tty if failure
unlink( "utesting.rt" );
@@
-118,23
+123,27
@@
static void gen_rt( uta_ctx_t* ctx ) {
/*
Generate a custom route table file using the buffer passed in.
/*
Generate a custom route table file using the buffer passed in.
+ Then force it to be read into the current route table. The file
+ is unlinked when finished.
*/
static void gen_custom_rt( uta_ctx_t* ctx, char* buf ) {
int fd;
*/
static void gen_custom_rt( uta_ctx_t* ctx, char* buf ) {
int fd;
- char* rt_stuff; // strings for the route table
- fd = open( "utesting.rt", O_WRONLY | O_CREAT, 0600 );
+ fd = open( "
X
utesting.rt", O_WRONLY | O_CREAT, 0600 );
if( fd < 0 ) {
fprintf( stderr, "<BUGGERED> unable to open file for testing route table gen\n" );
return;
}
if( fd < 0 ) {
fprintf( stderr, "<BUGGERED> unable to open file for testing route table gen\n" );
return;
}
- setenv( "RMR_SEED_RT", "utesting.rt", 1 );
+ setenv( "RMR_SEED_RT", "
X
utesting.rt", 1 );
- write( fd, rt_stuff, strlen( buf ) );
+ fprintf( stderr, "<INFO> creating custom rt from buffer (%d bytes)\n", (int) strlen (buf ) );
+ if( write( fd, buf, strlen( buf ) ) != strlen( buf ) ) {
+ fprintf( stderr, "<BUGGERED> write failed: %s\n", strerror( errno ) );
+ }
close( fd );
read_static_rt( ctx, 1 ); // force in verbose mode to see stats on tty if failure
close( fd );
read_static_rt( ctx, 1 ); // force in verbose mode to see stats on tty if failure
- unlink( "utesting.rt" );
+ unlink( "
X
utesting.rt" );
}
}