From 157defb03f29a119a7d8b6ccdfb1f96dda6eee3f Mon Sep 17 00:00:00 2001 From: Wouter Wijngaards Date: Mon, 26 Mar 2007 15:01:11 +0000 Subject: [PATCH] Cache test. git-svn-id: file:///svn/unbound/trunk@197 be551aaa-1e26-0410-a405-d3ace91eadb9 --- doc/Changelog | 2 ++ testcode/fake_event.c | 10 +++++--- testdata/fwd_cached.rpl | 56 +++++++++++++++++++++++++++++++++++++++++ 3 files changed, 65 insertions(+), 3 deletions(-) create mode 100644 testdata/fwd_cached.rpl diff --git a/doc/Changelog b/doc/Changelog index 8ce4df11d..756d7349c 100644 --- a/doc/Changelog +++ b/doc/Changelog @@ -1,5 +1,7 @@ 26 March 2007: Wouter - config settings for slab hash message cache. + - test for cached answer. + - Fixup deleting fake answer from testbound list. 23 March 2007: Wouter - review of yesterday's commits. diff --git a/testcode/fake_event.c b/testcode/fake_event.c index 4cb0c210c..d4e4aef08 100644 --- a/testcode/fake_event.c +++ b/testcode/fake_event.c @@ -280,7 +280,7 @@ static void answer_check_it(struct replay_runtime* runtime) { struct replay_answer* ans = runtime->answer_list, - **prev = &runtime->answer_list; + *prev = NULL; log_assert(runtime && runtime->now && runtime->now->evt_type == repevt_front_reply); while(ans) { @@ -294,12 +294,16 @@ answer_check_it(struct replay_runtime* runtime) log_info("testbound: do STEP %d %s", runtime->now->time_step, repevt_string(runtime->now->evt_type)); - *prev = ans->next; + if(prev) + prev->next = ans->next; + else runtime->answer_list = ans->next; + if(!ans->next) + runtime->answer_last = prev; delete_replay_answer(ans); ans = n; return; } else { - prev = &ans->next; + prev = ans; ans = ans->next; } } diff --git a/testdata/fwd_cached.rpl b/testdata/fwd_cached.rpl new file mode 100644 index 000000000..8de5f9ea1 --- /dev/null +++ b/testdata/fwd_cached.rpl @@ -0,0 +1,56 @@ +; This is a comment. + +SCENARIO_BEGIN Query receives answer from the cache + +STEP 1 QUERY +ENTRY_BEGIN + SECTION QUESTION + www.example.com. IN A +ENTRY_END +; the query is sent to the forwarder - no cache yet. +STEP 2 CHECK_OUT_QUERY +ENTRY_BEGIN + MATCH qname qtype opcode + SECTION QUESTION + www.example.com. IN A +ENTRY_END +STEP 3 REPLY +ENTRY_BEGIN + MATCH opcode qtype qname + ADJUST copy_id + REPLY QR RD RA NOERROR + SECTION QUESTION + www.example.com. IN A + SECTION ANSWER + www.example.com. IN A 10.20.30.40 + SECTION AUTHORITY + www.example.com. IN NS ns.example.com. + SECTION ADDITIONAL + ns.example.com. IN A 10.20.30.50 +ENTRY_END +STEP 4 CHECK_ANSWER +ENTRY_BEGIN + MATCH opcode qname qtype + SECTION QUESTION + www.example.com. IN A + SECTION ANSWER + www.example.com. IN A 10.20.30.40 +ENTRY_END + +; another query, same, so it must be answered frm the cache +STEP 5 QUERY +ENTRY_BEGIN + SECTION QUESTION + www.example.com. IN A +ENTRY_END +; immediate answer without an OUT_QUERY happening (checked on exit) +STEP 6 CHECK_ANSWER +ENTRY_BEGIN + MATCH opcode qname qtype + SECTION QUESTION + www.example.com. IN A + SECTION ANSWER + www.example.com. IN A 10.20.30.40 +ENTRY_END + +SCENARIO_END -- 2.47.2