mirror of
https://gitlab.isc.org/isc-projects/bind9
synced 2025-08-29 13:38:26 +00:00
[master] remove obsolete unit test
This commit is contained in:
parent
d82b18a552
commit
741cf3d24e
@ -897,237 +897,6 @@ ATF_TC_BODY(rbt_remove, tc) {
|
|||||||
dns_test_end();
|
dns_test_end();
|
||||||
}
|
}
|
||||||
|
|
||||||
ATF_TC(rbt_remove_empty);
|
|
||||||
ATF_TC_HEAD(rbt_remove_empty, tc) {
|
|
||||||
atf_tc_set_md_var(tc, "descr",
|
|
||||||
"Test removal from a tree when "
|
|
||||||
"upper nodes are empty");
|
|
||||||
}
|
|
||||||
ATF_TC_BODY(rbt_remove_empty, tc) {
|
|
||||||
/*
|
|
||||||
* This test is similar to the rbt_remove test, but checks node
|
|
||||||
* deletion when upper nodes are empty.
|
|
||||||
*/
|
|
||||||
isc_result_t result;
|
|
||||||
size_t j;
|
|
||||||
|
|
||||||
UNUSED(tc);
|
|
||||||
|
|
||||||
isc_mem_debugging = ISC_MEM_DEBUGRECORD;
|
|
||||||
|
|
||||||
result = dns_test_begin(NULL, ISC_TRUE);
|
|
||||||
ATF_REQUIRE_EQ(result, ISC_R_SUCCESS);
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Delete single nodes and check if the rest of the nodes exist.
|
|
||||||
*/
|
|
||||||
for (j = 0; j < ordered_names_count; j++) {
|
|
||||||
dns_rbt_t *mytree = NULL;
|
|
||||||
dns_rbtnode_t *node;
|
|
||||||
size_t i;
|
|
||||||
isc_boolean_t tree_ok;
|
|
||||||
dns_rbtnodechain_t chain;
|
|
||||||
size_t start_node;
|
|
||||||
|
|
||||||
/* Create a tree. */
|
|
||||||
result = dns_rbt_create(mctx, delete_data, NULL, &mytree);
|
|
||||||
ATF_REQUIRE_EQ(result, ISC_R_SUCCESS);
|
|
||||||
|
|
||||||
/* Insert test data into the tree. */
|
|
||||||
for (i = 0; i < domain_names_count; i++) {
|
|
||||||
node = NULL;
|
|
||||||
result = insert_helper(mytree, domain_names[i], &node);
|
|
||||||
ATF_REQUIRE_EQ(result, ISC_R_SUCCESS);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Check that all names exist in order. */
|
|
||||||
for (i = 0; i < ordered_names_count; i++) {
|
|
||||||
dns_fixedname_t fname;
|
|
||||||
dns_name_t *name;
|
|
||||||
|
|
||||||
build_name_from_str(ordered_names[i], &fname);
|
|
||||||
|
|
||||||
name = dns_fixedname_name(&fname);
|
|
||||||
node = NULL;
|
|
||||||
result = dns_rbt_findnode(mytree, name, NULL,
|
|
||||||
&node, NULL,
|
|
||||||
DNS_RBTFIND_EMPTYDATA,
|
|
||||||
NULL, NULL);
|
|
||||||
ATF_CHECK_EQ(result, ISC_R_SUCCESS);
|
|
||||||
|
|
||||||
/* Check that node data is empty */
|
|
||||||
ATF_REQUIRE(node != NULL);
|
|
||||||
ATF_REQUIRE_EQ(node->data, NULL);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Now, delete the j'th node from the tree. */
|
|
||||||
{
|
|
||||||
dns_fixedname_t fname;
|
|
||||||
dns_name_t *name;
|
|
||||||
|
|
||||||
build_name_from_str(ordered_names[j], &fname);
|
|
||||||
|
|
||||||
name = dns_fixedname_name(&fname);
|
|
||||||
|
|
||||||
node = NULL;
|
|
||||||
result = dns_rbt_findnode(mytree, name, NULL, &node,
|
|
||||||
NULL, DNS_RBTFIND_EMPTYDATA,
|
|
||||||
NULL, NULL);
|
|
||||||
ATF_CHECK_EQ(result, ISC_R_SUCCESS);
|
|
||||||
|
|
||||||
result = dns_rbt_deletenode(mytree, node, ISC_FALSE);
|
|
||||||
ATF_CHECK_EQ(result, ISC_R_SUCCESS);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Check RB tree properties. */
|
|
||||||
tree_ok = dns__rbt_checkproperties(mytree);
|
|
||||||
ATF_CHECK_EQ(tree_ok, ISC_TRUE);
|
|
||||||
|
|
||||||
dns_rbtnodechain_init(&chain, mctx);
|
|
||||||
|
|
||||||
/* Now, walk through nodes in order. */
|
|
||||||
if (j == 0) {
|
|
||||||
/*
|
|
||||||
* Node for ordered_names[0] was already deleted
|
|
||||||
* above. We start from node 1.
|
|
||||||
*/
|
|
||||||
dns_fixedname_t fname;
|
|
||||||
dns_name_t *name;
|
|
||||||
|
|
||||||
build_name_from_str(ordered_names[0], &fname);
|
|
||||||
name = dns_fixedname_name(&fname);
|
|
||||||
node = NULL;
|
|
||||||
result = dns_rbt_findnode(mytree, name, NULL,
|
|
||||||
&node, NULL,
|
|
||||||
DNS_RBTFIND_EMPTYDATA,
|
|
||||||
NULL, NULL);
|
|
||||||
ATF_CHECK(result != ISC_R_SUCCESS);
|
|
||||||
|
|
||||||
build_name_from_str(ordered_names[1], &fname);
|
|
||||||
name = dns_fixedname_name(&fname);
|
|
||||||
node = NULL;
|
|
||||||
result = dns_rbt_findnode(mytree, name, NULL,
|
|
||||||
&node, &chain,
|
|
||||||
DNS_RBTFIND_EMPTYDATA,
|
|
||||||
NULL, NULL);
|
|
||||||
ATF_CHECK_EQ(result, ISC_R_SUCCESS);
|
|
||||||
start_node = 1;
|
|
||||||
} else {
|
|
||||||
/* Start from node 0. */
|
|
||||||
dns_fixedname_t fname;
|
|
||||||
dns_name_t *name;
|
|
||||||
|
|
||||||
build_name_from_str(ordered_names[0], &fname);
|
|
||||||
name = dns_fixedname_name(&fname);
|
|
||||||
node = NULL;
|
|
||||||
result = dns_rbt_findnode(mytree, name, NULL,
|
|
||||||
&node, &chain,
|
|
||||||
DNS_RBTFIND_EMPTYDATA,
|
|
||||||
NULL, NULL);
|
|
||||||
ATF_CHECK_EQ(result, ISC_R_SUCCESS);
|
|
||||||
start_node = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* node and chain have been set by the code above at
|
|
||||||
* this point.
|
|
||||||
*/
|
|
||||||
for (i = start_node; i < ordered_names_count; i++) {
|
|
||||||
dns_fixedname_t fntmp1, fntmp2;
|
|
||||||
dns_name_t *ntmp1, *ntmp2;
|
|
||||||
dns_fixedname_t fname_j, fname_i;
|
|
||||||
dns_name_t *name_j, *name_i;
|
|
||||||
|
|
||||||
build_name_from_str("j.z.d.e.f", &fntmp1);
|
|
||||||
ntmp1 = dns_fixedname_name(&fntmp1);
|
|
||||||
build_name_from_str("z.d.e.f", &fntmp2);
|
|
||||||
ntmp2 = dns_fixedname_name(&fntmp2);
|
|
||||||
|
|
||||||
build_name_from_str(ordered_names[j], &fname_j);
|
|
||||||
name_j = dns_fixedname_name(&fname_j);
|
|
||||||
build_name_from_str(ordered_names[i], &fname_i);
|
|
||||||
name_i = dns_fixedname_name(&fname_i);
|
|
||||||
|
|
||||||
if (dns_name_equal(name_j, ntmp1) &&
|
|
||||||
dns_name_equal(name_i, ntmp2))
|
|
||||||
{
|
|
||||||
/*
|
|
||||||
* The only special case in the
|
|
||||||
* tree. Here, "z.d.e.f" will not exist
|
|
||||||
* as it would have been removed during
|
|
||||||
* removal of "j.z.d.e.f".
|
|
||||||
*/
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (dns_name_equal(name_i, name_j)) {
|
|
||||||
dns_fixedname_t fntmp3, fntmp4, fntmp5, fntmp6;
|
|
||||||
dns_name_t *ntmp3, *ntmp4, *ntmp5, *ntmp6;
|
|
||||||
|
|
||||||
/*
|
|
||||||
* This may be true for the last node if
|
|
||||||
* we seek ahead in the loop using
|
|
||||||
* dns_rbtnodechain_next() below.
|
|
||||||
*/
|
|
||||||
if (node == NULL) {
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* All ordered nodes are empty
|
|
||||||
* initially. If an empty removed node
|
|
||||||
* exists because it is a super-domain,
|
|
||||||
* just skip it.
|
|
||||||
*/
|
|
||||||
build_name_from_str("d.e.f", &fntmp3);
|
|
||||||
ntmp3 = dns_fixedname_name(&fntmp3);
|
|
||||||
build_name_from_str("w.y.d.e.f", &fntmp4);
|
|
||||||
ntmp4 = dns_fixedname_name(&fntmp4);
|
|
||||||
build_name_from_str("z.d.e.f", &fntmp5);
|
|
||||||
ntmp5 = dns_fixedname_name(&fntmp5);
|
|
||||||
build_name_from_str("g.h", &fntmp6);
|
|
||||||
ntmp6 = dns_fixedname_name(&fntmp6);
|
|
||||||
|
|
||||||
if (dns_name_equal(name_j, ntmp3) ||
|
|
||||||
dns_name_equal(name_j, ntmp4) ||
|
|
||||||
dns_name_equal(name_j, ntmp5) ||
|
|
||||||
dns_name_equal(name_j, ntmp6))
|
|
||||||
{
|
|
||||||
result = dns_rbtnodechain_next(&chain,
|
|
||||||
NULL,
|
|
||||||
NULL);
|
|
||||||
if (result == ISC_R_NOMORE) {
|
|
||||||
node = NULL;
|
|
||||||
} else {
|
|
||||||
dns_rbtnodechain_current(&chain,
|
|
||||||
NULL,
|
|
||||||
NULL,
|
|
||||||
&node);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
ATF_REQUIRE(node != NULL);
|
|
||||||
|
|
||||||
result = dns_rbtnodechain_next(&chain, NULL, NULL);
|
|
||||||
if (result == ISC_R_NOMORE) {
|
|
||||||
node = NULL;
|
|
||||||
} else {
|
|
||||||
dns_rbtnodechain_current(&chain, NULL, NULL,
|
|
||||||
&node);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/* We should have reached the end of the tree. */
|
|
||||||
ATF_REQUIRE_EQ(node, NULL);
|
|
||||||
|
|
||||||
dns_rbt_destroy(&mytree);
|
|
||||||
}
|
|
||||||
|
|
||||||
dns_test_end();
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
insert_nodes(dns_rbt_t *mytree, char **names,
|
insert_nodes(dns_rbt_t *mytree, char **names,
|
||||||
size_t *names_count, isc_uint32_t num_names)
|
size_t *names_count, isc_uint32_t num_names)
|
||||||
@ -1450,7 +1219,6 @@ ATF_TP_ADD_TCS(tp) {
|
|||||||
ATF_TP_ADD_TC(tp, rbt_check_distance_ordered);
|
ATF_TP_ADD_TC(tp, rbt_check_distance_ordered);
|
||||||
ATF_TP_ADD_TC(tp, rbt_insert);
|
ATF_TP_ADD_TC(tp, rbt_insert);
|
||||||
ATF_TP_ADD_TC(tp, rbt_remove);
|
ATF_TP_ADD_TC(tp, rbt_remove);
|
||||||
ATF_TP_ADD_TC(tp, rbt_remove_empty);
|
|
||||||
ATF_TP_ADD_TC(tp, rbt_insert_and_remove);
|
ATF_TP_ADD_TC(tp, rbt_insert_and_remove);
|
||||||
#ifdef ISC_PLATFORM_USETHREADS
|
#ifdef ISC_PLATFORM_USETHREADS
|
||||||
#ifdef DNS_BENCHMARK_TESTS
|
#ifdef DNS_BENCHMARK_TESTS
|
||||||
|
Loading…
x
Reference in New Issue
Block a user