]> git.ipfire.org Git - thirdparty/unbound.git/commitdiff
Cache test.
authorWouter Wijngaards <wouter@nlnetlabs.nl>
Mon, 26 Mar 2007 15:01:11 +0000 (15:01 +0000)
committerWouter Wijngaards <wouter@nlnetlabs.nl>
Mon, 26 Mar 2007 15:01:11 +0000 (15:01 +0000)
git-svn-id: file:///svn/unbound/trunk@197 be551aaa-1e26-0410-a405-d3ace91eadb9

doc/Changelog
testcode/fake_event.c
testdata/fwd_cached.rpl [new file with mode: 0644]

index 8ce4df11d8544555db656a195f1dc6dd1c197e9b..756d7349cdb45ab68cfbd681857ec1691cd278e5 100644 (file)
@@ -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.
index 4cb0c210ce90aeb948409c3e3e68ae06edee9ede..d4e4aef087e19796c123a08a417c4e17af4da006 100644 (file)
@@ -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 (file)
index 0000000..8de5f9e
--- /dev/null
@@ -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