mirror of
https://github.com/NLnetLabs/unbound.git
synced 2026-09-13 13:27:43 +02:00
auth zone test checks stored axfr zonefile
git-svn-id: file:///svn/unbound/trunk@4486 be551aaa-1e26-0410-a405-d3ace91eadb9
This commit is contained in:
@@ -158,6 +158,7 @@ repevt_string(enum replay_event_type t)
|
||||
case repevt_back_reply: return "REPLY";
|
||||
case repevt_back_query: return "CHECK_OUT_QUERY";
|
||||
case repevt_autotrust_check: return "CHECK_AUTOTRUST";
|
||||
case repevt_tempfile_check: return "CHECK_TEMPFILE";
|
||||
case repevt_error: return "ERROR";
|
||||
case repevt_assign: return "ASSIGN";
|
||||
case repevt_traffic: return "TRAFFIC";
|
||||
@@ -611,6 +612,59 @@ autotrust_check(struct replay_runtime* runtime, struct replay_moment* mom)
|
||||
log_info("autotrust %s is OK", mom->autotrust_id);
|
||||
}
|
||||
|
||||
/** check tempfile file contents */
|
||||
static void
|
||||
tempfile_check(struct replay_runtime* runtime, struct replay_moment* mom)
|
||||
{
|
||||
char name[1024], line[1024];
|
||||
FILE *in;
|
||||
int lineno = 0, oke=1;
|
||||
char* expanded;
|
||||
struct config_strlist* p;
|
||||
line[sizeof(line)-1] = 0;
|
||||
log_assert(mom->autotrust_id);
|
||||
fake_temp_file("_temp_", mom->autotrust_id, name, sizeof(name));
|
||||
in = fopen(name, "r");
|
||||
if(!in) fatal_exit("could not open %s: %s", name, strerror(errno));
|
||||
for(p=mom->file_content; p; p=p->next) {
|
||||
lineno++;
|
||||
if(!fgets(line, (int)sizeof(line)-1, in)) {
|
||||
log_err("tempfile check failed, could not read line");
|
||||
log_err("file %s, line %d", name, lineno);
|
||||
log_err("should be: %s", p->str);
|
||||
fatal_exit("tempfile_check failed");
|
||||
}
|
||||
if(line[0]) line[strlen(line)-1] = 0; /* remove newline */
|
||||
expanded = macro_process(runtime->vars, runtime, p->str);
|
||||
if(!expanded)
|
||||
fatal_exit("could not expand macro line %d", lineno);
|
||||
if(verbosity >= 7 && strcmp(p->str, expanded) != 0)
|
||||
log_info("expanded '%s' to '%s'", p->str, expanded);
|
||||
if(strcmp(expanded, line) != 0) {
|
||||
log_err("mismatch in file %s, line %d", name, lineno);
|
||||
log_err("file has : %s", line);
|
||||
log_err("should be: %s", expanded);
|
||||
free(expanded);
|
||||
oke = 0;
|
||||
continue;
|
||||
}
|
||||
free(expanded);
|
||||
fprintf(stderr, "%s:%2d ok : %s\n", name, lineno, line);
|
||||
}
|
||||
if(fgets(line, (int)sizeof(line)-1, in)) {
|
||||
log_err("tempfile check failed, extra lines in %s after %d",
|
||||
name, lineno);
|
||||
do {
|
||||
fprintf(stderr, "file has: %s", line);
|
||||
} while(fgets(line, (int)sizeof(line)-1, in));
|
||||
oke = 0;
|
||||
}
|
||||
fclose(in);
|
||||
if(!oke)
|
||||
fatal_exit("tempfile_check STEP %d failed", mom->time_step);
|
||||
log_info("tempfile %s is OK", mom->autotrust_id);
|
||||
}
|
||||
|
||||
/** Store RTT in infra cache */
|
||||
static void
|
||||
do_infra_rtt(struct replay_runtime* runtime)
|
||||
@@ -720,6 +774,10 @@ do_moment_and_advance(struct replay_runtime* runtime)
|
||||
autotrust_check(runtime, runtime->now);
|
||||
advance_moment(runtime);
|
||||
break;
|
||||
case repevt_tempfile_check:
|
||||
tempfile_check(runtime, runtime->now);
|
||||
advance_moment(runtime);
|
||||
break;
|
||||
case repevt_assign:
|
||||
moment_assign(runtime, runtime->now);
|
||||
advance_moment(runtime);
|
||||
|
||||
Reference in New Issue
Block a user