]> git.ipfire.org Git - thirdparty/bind9.git/commitdiff
add a unit test with an empty node
authorEvan Hunt <each@isc.org>
Wed, 5 Mar 2025 23:46:17 +0000 (15:46 -0800)
committerEvan Hunt <each@isc.org>
Fri, 14 Mar 2025 23:19:17 +0000 (23:19 +0000)
the db_test unit test now looks up an empty nonterminal node
to exercise the behavior of the step() function in qpzone.

tests/dns/db_test.c

index d9b7a1047a847bb54183b5f65ceb05a0a143fb78..7fa128b8010afb2841b814aaaad72edab81b8b6c 100644 (file)
@@ -351,8 +351,40 @@ ISC_LOOP_TEST_IMPL(version) {
        result = dns_db_find(db, name, ver, dns_rdatatype_a, 0, 0, &node,
                             foundname, &rdataset, NULL);
        assert_int_equal(result, ISC_R_SUCCESS);
+       dns_db_detachnode(db, &node);
+
+       /* Now we create a node with an empty parent */
+       result = dns_db_newversion(db, &new);
+       dns_test_namefromstring("long.ent.name.test.test.", &fname);
+       result = dns_db_findnode(db, name, true, &node);
+       assert_int_equal(result, ISC_R_SUCCESS);
+       result = dns_db_addrdataset(db, node, new, 0, &rdataset, 0, NULL);
+       assert_int_equal(result, ISC_R_SUCCESS);
        dns_rdataset_disassociate(&rdataset);
+       dns_rdataset_init(&rdataset);
+
+       /* look up the ENT; it should be empty */
+       dns_test_namefromstring("ent.name.test.test.", &fname);
        dns_db_detachnode(db, &node);
+       result = dns_db_find(db, name, new, dns_rdatatype_a, 0, 0, &node,
+                            foundname, &rdataset, NULL);
+       assert_int_equal(result, DNS_R_EMPTYNAME);
+
+       /* ... but then we roll it back... */
+       dns_db_closeversion(db, &new, false);
+
+       /* ... and the ENT should be NXDOMAIN now */
+       dns_test_namefromstring("ent.name.test.test.", &fname);
+       result = dns_db_find(db, name, ver, dns_rdatatype_a, 0, 0, &node,
+                            foundname, &rdataset, NULL);
+       assert_int_equal(result, DNS_R_NXDOMAIN);
+
+       if (dns_rdataset_isassociated(&rdataset)) {
+               dns_rdataset_disassociate(&rdataset);
+       }
+       if (node != NULL) {
+               dns_db_detachnode(db, &node);
+       }
        dns_db_closeversion(db, &ver, false);
 
        dns_db_detach(&db);