tests improved
This commit is contained in:
parent
7cab4db54a
commit
51daa79d39
|
@ -168,10 +168,11 @@ int radix_search(radix_holder_t t, record_t r) {
|
|||
/*--------------------------------------------------------------------------------*/
|
||||
#include <assert.h>
|
||||
#include <arpa/inet.h>
|
||||
#include <time.h>
|
||||
|
||||
#define RULES_FILE "../data/routing-data"
|
||||
#define TEST_FILE "../data/test-data"
|
||||
#define TEST_ROWS 6286
|
||||
#define TEST_ROWS 39222 /*39222*/
|
||||
#define READ_MODE "r"
|
||||
|
||||
int parse_line(FILE* f, record_t r) {
|
||||
|
@ -258,9 +259,12 @@ int load_tests(struct routing_record** ref) {
|
|||
return 0;
|
||||
}
|
||||
|
||||
for (cnt = 0; cnt < TEST_ROWS; ++cnt)
|
||||
if (!parse_line(f, &r[cnt]))
|
||||
printf("test parse failed %d\n", cnt);
|
||||
for (cnt = 0; cnt < TEST_ROWS; ++cnt) {
|
||||
if (!parse_line(f, &r[cnt])) {
|
||||
printf("WARNING test parse failed %d\n", cnt);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
fclose(f);
|
||||
*ref = r;
|
||||
|
@ -270,21 +274,36 @@ int load_tests(struct routing_record** ref) {
|
|||
int fire_tests(radix_holder_t t, struct routing_record* r) {
|
||||
int row;
|
||||
int wrong = TEST_ROWS;
|
||||
unsigned short ref_pop;
|
||||
unsigned short ref_pop, ref_scope;
|
||||
|
||||
for (row = 0; row < TEST_ROWS; ++row, ++r) {
|
||||
ref_pop = r->_rule;
|
||||
r->_rule = INVALID_RULE;
|
||||
radix_search(t, r);
|
||||
if ( ref_pop == r->_rule)
|
||||
clock_t start, end;
|
||||
double lookup_time;
|
||||
|
||||
start = clock();
|
||||
|
||||
for (row = 0; row < TEST_ROWS; ++row) {
|
||||
ref_pop = r[row]._rule;
|
||||
ref_scope = r[row]._mask;
|
||||
|
||||
r[row]._rule = INVALID_RULE;
|
||||
radix_search(t, &r[row]);
|
||||
if (ref_pop == r[row]._rule && ref_scope == r[row]._mask) {
|
||||
--wrong;
|
||||
else
|
||||
printf("ref: %d got: %d @ %d\n", ref_pop, r->_rule, row );
|
||||
} else {
|
||||
if (ref_pop != r[row]._rule)
|
||||
printf("pop: %d got: %d @ %d\n", ref_pop, r[row]._rule, row );
|
||||
if (ref_scope != r[row]._mask)
|
||||
printf("scp: %d got: %d @ %d\n", ref_scope, r[row]._mask, row );
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
end = clock();
|
||||
lookup_time = ((double) (end - start)) / CLOCKS_PER_SEC * 1000;
|
||||
|
||||
printf("%d lookups in %f ms (%f microseconds per op)\n", TEST_ROWS, lookup_time, ((end - start)/(double)TEST_ROWS));
|
||||
|
||||
free(r);
|
||||
*/
|
||||
|
||||
return wrong;
|
||||
|
||||
return 0;
|
||||
|
|
Loading…
Reference in New Issue