From: Wouter Wijngaards Date: Tue, 27 Mar 2007 09:32:08 +0000 (+0000) Subject: Cache falloff test. X-Git-Tag: release-0.2~28 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=4ad4cbdf7409d2c82980d7c77c51f12dc361b4f3;p=thirdparty%2Funbound.git Cache falloff test. testbound can pass config options from replay file to unbound. git-svn-id: file:///svn/unbound/trunk@199 be551aaa-1e26-0410-a405-d3ace91eadb9 --- diff --git a/doc/Changelog b/doc/Changelog index 5e67f645e..393fd2bcd 100644 --- a/doc/Changelog +++ b/doc/Changelog @@ -1,5 +1,8 @@ 27 March 2007: Wouter - added test for cache and not cached answers, in testbound replays. + - testbound can give config file and commandline options from the + replay file to unbound. + - created test that checks if items drop out of the cache. 26 March 2007: Wouter - config settings for slab hash message cache. diff --git a/testcode/replay.c b/testcode/replay.c index 264dd7bbd..13be63d03 100644 --- a/testcode/replay.c +++ b/testcode/replay.c @@ -234,11 +234,10 @@ make_scenario(char* line) } struct replay_scenario* -replay_scenario_read(FILE* in, const char* name) +replay_scenario_read(FILE* in, const char* name, int* lineno) { char line[MAX_LINE_LEN]; char *parse; - int lineno = 0; struct replay_scenario* scen = NULL; uint16_t ttl = 3600; ldns_rdf* or = NULL; @@ -247,7 +246,7 @@ replay_scenario_read(FILE* in, const char* name) while(fgets(line, MAX_LINE_LEN-1, in)) { parse=line; - lineno++; + (*lineno)++; while(isspace(*parse)) parse++; if(!*parse) @@ -257,26 +256,26 @@ replay_scenario_read(FILE* in, const char* name) if(parse_keyword(&parse, "SCENARIO_BEGIN")) { scen = make_scenario(parse); if(!scen) - fatal_exit("%d: could not make scen", lineno); + fatal_exit("%d: could not make scen", *lineno); continue; } if(!scen) - fatal_exit("%d: expected SCENARIO", lineno); + fatal_exit("%d: expected SCENARIO", *lineno); if(parse_keyword(&parse, "RANGE_BEGIN")) { struct replay_range* newr = replay_range_read(parse, - in, name, &lineno, line, &ttl, &or, &prev); + in, name, lineno, line, &ttl, &or, &prev); if(!newr) - fatal_exit("%d: bad range", lineno); + fatal_exit("%d: bad range", *lineno); newr->next_range = scen->range_list; scen->range_list = newr; } else if(parse_keyword(&parse, "STEP")) { struct replay_moment* mom = replay_moment_read(parse, - in, name, &lineno, &ttl, &or, &prev); + in, name, lineno, &ttl, &or, &prev); if(!mom) - fatal_exit("%d: bad moment", lineno); + fatal_exit("%d: bad moment", *lineno); if(scen->mom_last && scen->mom_last->time_step >= mom->time_step) - fatal_exit("%d: time goes backwards", lineno); + fatal_exit("%d: time goes backwards", *lineno); if(scen->mom_last) scen->mom_last->mom_next = mom; else scen->mom_first = mom; diff --git a/testcode/replay.h b/testcode/replay.h index d0114eaf3..a873e5042 100644 --- a/testcode/replay.h +++ b/testcode/replay.h @@ -263,9 +263,11 @@ struct replay_answer { * Read a replay scenario from the file. * @param in: file to read from. * @param name: name to print in errors. + * @param lineno: incremented for every line read. * @return: Scenario. NULL if no scenario read. */ -struct replay_scenario* replay_scenario_read(FILE* in, const char* name); +struct replay_scenario* replay_scenario_read(FILE* in, const char* name, + int* lineno); /** * Delete scenario. diff --git a/testcode/testbound.c b/testcode/testbound.c index b749c8874..67448f8e5 100644 --- a/testcode/testbound.c +++ b/testcode/testbound.c @@ -51,6 +51,9 @@ #include "daemon/unbound.c" #undef main +/** maximum line length for lines in the replay file. */ +#define MAX_LINE_LEN 1024 + /** give commandline usage for testbound. */ static void testbound_usage() @@ -107,25 +110,66 @@ static void echo_cmdline(int argc, char* argv[]) { int i; - printf("testbound is starting:"); + fprintf(stderr, "testbound is starting:"); for(i=0; i