From: Evan Hunt Date: Wed, 5 Mar 2025 23:46:17 +0000 (-0800) Subject: add a unit test with an empty node X-Git-Tag: v9.21.7~53^2 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=ecde0ea2d719153c84fca19eaeeeeb6a01c10c1a;p=thirdparty%2Fbind9.git add a unit test with an empty node the db_test unit test now looks up an empty nonterminal node to exercise the behavior of the step() function in qpzone. --- diff --git a/tests/dns/db_test.c b/tests/dns/db_test.c index d9b7a1047a8..7fa128b8010 100644 --- a/tests/dns/db_test.c +++ b/tests/dns/db_test.c @@ -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);