BIND 10 master, updated. e46d39396cca6ed4b401a265383e5f89b9b7c7f0 Merge branch 'master' into trac2150_2
BIND 10 source code commits
bind10-changes at lists.isc.org
Mon Sep 17 18:52:13 UTC 2012
The branch, master has been updated
via e46d39396cca6ed4b401a265383e5f89b9b7c7f0 (commit)
via 5b8f36f524d99d1e97d0c562153ef6102c10bb93 (commit)
via dc8237b41256dcdb50220a9937aa6426f96b981a (commit)
via 4e25ff76b698c04d2aa9f0e2ed391a3b6922b8f7 (commit)
via 65ef86855e3fc12b765ba3af403e92af112578da (commit)
via 0ccc72ed6a2a8298af79e19c4b13935471652947 (commit)
via 0b66c1db1a3016532fca5e8ff4be11299646aaf7 (commit)
via 3c03d322a1845fd162f8e3bb83e403f3a1977847 (commit)
from 547bcae62d8767bc92af6eafb396f454b344b593 (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
commit e46d39396cca6ed4b401a265383e5f89b9b7c7f0
Merge: 5b8f36f 547bcae
Author: Mukund Sivaraman <muks at isc.org>
Date: Tue Sep 18 00:14:28 2012 +0530
Merge branch 'master' into trac2150_2
-----------------------------------------------------------------------
Summary of changes:
src/lib/datasrc/memory/domaintree.h | 25 +++-
.../datasrc/memory/tests/domaintree_unittest.cc | 136 ++++++++++++++++++++
2 files changed, 155 insertions(+), 6 deletions(-)
-----------------------------------------------------------------------
diff --git a/src/lib/datasrc/memory/domaintree.h b/src/lib/datasrc/memory/domaintree.h
index db2f7e6..b29f10f 100644
--- a/src/lib/datasrc/memory/domaintree.h
+++ b/src/lib/datasrc/memory/domaintree.h
@@ -1153,9 +1153,11 @@ public:
/// Another special feature of this version is the ability to record
/// more detailed information regarding the search result.
///
- /// This information will be returned via the \c node_path parameter,
- /// which is an object of class \c DomainTreeNodeChain.
- /// The passed parameter must be empty.
+ /// This information will be returned via the \c node_path
+ /// parameter, which is an object of class \c DomainTreeNodeChain.
+ /// The passed parameter must be empty if the label sequence is
+ /// absolute. If the label sequence is not absolute, then find()
+ /// will begin from the top of the node chain.
///
/// On success, the node sequence stored in \c node_path will contain all
/// the ancestor nodes from the found node towards the root.
@@ -1462,12 +1464,23 @@ DomainTree<T>::find(const isc::dns::LabelSequence& target_labels_orig,
bool (*callback)(const DomainTreeNode<T>&, CBARG),
CBARG callback_arg) const
{
- if (!node_path.isEmpty()) {
+ if (node_path.isEmpty() ^ target_labels_orig.isAbsolute()) {
isc_throw(isc::BadValue,
- "DomainTree::find is given a non empty chain");
+ "DomainTree::find() is given mismatched node chain"
+ " and label sequence");
+ }
+
+ DomainTreeNode<T>* node;
+
+ if (!node_path.isEmpty()) {
+ // Get the top node in the node chain
+ node = const_cast<DomainTreeNode<T>*>(node_path.top());
+ // Start searching from its down pointer
+ node = node->getDown();
+ } else {
+ node = root_.get();
}
- DomainTreeNode<T>* node = root_.get();
Result ret = NOTFOUND;
dns::LabelSequence target_labels(target_labels_orig);
diff --git a/src/lib/datasrc/memory/tests/domaintree_unittest.cc b/src/lib/datasrc/memory/tests/domaintree_unittest.cc
index 3d1ab56..ef90050 100644
--- a/src/lib/datasrc/memory/tests/domaintree_unittest.cc
+++ b/src/lib/datasrc/memory/tests/domaintree_unittest.cc
@@ -454,6 +454,142 @@ TEST_F(DomainTreeTest, callbackLabelSequence) {
performCallbackTest(dtree, mem_sgmt_, ls1, ls2);
}
+TEST_F(DomainTreeTest, findInSubTree) {
+ // For the version that takes a node chain, the chain must be empty.
+ DomainTreeNodeChain<int> chain;
+ bool flag;
+
+ // Searching for a non-absolute (right-stripped) label sequence when
+ // chain is empty should throw.
+ const Name n0("w.y.d.e.f");
+ LabelSequence ls0(n0);
+ ls0.stripRight(1);
+ EXPECT_THROW(dtree_expose_empty_node.find(ls0, &cdtnode, chain,
+ testCallback, &flag),
+ isc::BadValue);
+
+ // First, find a sub-tree node
+ chain.clear();
+ const LabelSequence ls1(n0);
+ DomainTree<int>::Result result =
+ dtree_expose_empty_node.find(ls1, &cdtnode, chain,
+ testCallback, &flag);
+ EXPECT_EQ(DomainTree<int>::EXACTMATCH, result);
+ EXPECT_EQ(n0, chain.getAbsoluteName());
+
+ // Searching for an absolute label sequence when chain is already
+ // populated should throw.
+ const Name n2a("o");
+ const LabelSequence ls2a(n2a);
+ EXPECT_THROW(dtree_expose_empty_node.find(ls2a, &cdtnode, chain,
+ testCallback, &flag),
+ isc::BadValue);
+
+ // Now, find "o.w.y.d.e.f." by right-stripping the "w.y.d.e.f."
+ // suffix to "o" (non-absolute).
+ const Name n2("o.w.y.d.e.f");
+ LabelSequence ls2(n2);
+ ls2.stripRight(6);
+ EXPECT_EQ("o", ls2.toText());
+
+ result = dtree_expose_empty_node.find(ls2, &cdtnode, chain,
+ testCallback, &flag);
+ EXPECT_EQ(DomainTree<int>::EXACTMATCH, result);
+ EXPECT_EQ(n2, chain.getAbsoluteName());
+
+ // Another test. Start with "d.e.f." node.
+ chain.clear();
+ const Name n3("d.e.f");
+ const LabelSequence ls3(n3);
+ result =
+ dtree_expose_empty_node.find(ls3, &cdtnode, chain,
+ testCallback, &flag);
+ EXPECT_EQ(DomainTree<int>::EXACTMATCH, result);
+ EXPECT_EQ(n3, chain.getAbsoluteName());
+
+ // Now, find "o.w.y.d.e.f." by right-stripping the "w.y.d.e.f."
+ // suffix to "o.w.y" (non-absolute).
+ const Name n4("o.w.y.d.e.f");
+ LabelSequence ls4(n2);
+ ls4.stripRight(4);
+ EXPECT_EQ("o.w.y", ls4.toText());
+
+ result = dtree_expose_empty_node.find(ls4, &cdtnode, chain,
+ testCallback, &flag);
+ EXPECT_EQ(DomainTree<int>::EXACTMATCH, result);
+ EXPECT_EQ(n4, chain.getAbsoluteName());
+}
+
+TEST_F(DomainTreeTest, findInSubTreeSameLabelSequence) {
+ // For the version that takes a node chain, the chain must be empty.
+ DomainTreeNodeChain<int> chain;
+ bool flag;
+
+ const Name n1("c.g.h");
+
+ // First insert a "c.g.h." node.
+ dtree_expose_empty_node.insert(mem_sgmt_, n1, &dtnode);
+
+ /* Now, the tree looks like:
+ *
+ * .
+ * |
+ * b
+ * / \
+ * a d.e.f
+ * / | \____
+ * c | \
+ * | g.h
+ * | |
+ * w.y i
+ * / | \ / \
+ * x | z c k
+ * | |
+ * p j
+ * / \
+ * o q
+ */
+
+ // Make a non-absolute label sequence. We will search for this same
+ // sequence in two places in the tree.
+ LabelSequence ls1(n1);
+ ls1.stripRight(3);
+ EXPECT_EQ("c", ls1.toText());
+
+ // First, find "g.h."
+ const Name n2("g.h");
+ const LabelSequence ls2(n2);
+ DomainTree<int>::Result result =
+ dtree_expose_empty_node.find(ls2, &cdtnode, chain,
+ testCallback, &flag);
+ EXPECT_EQ(DomainTree<int>::EXACTMATCH, result);
+ EXPECT_EQ(n2, chain.getAbsoluteName());
+
+ // Now, find "c.g.h." by searching just the non-absolute ls1 label
+ // sequence.
+ result = dtree_expose_empty_node.find(ls1, &cdtnode, chain,
+ testCallback, &flag);
+ EXPECT_EQ(DomainTree<int>::EXACTMATCH, result);
+ EXPECT_EQ(n1, chain.getAbsoluteName());
+
+ // Now, find "." (the root node)
+ chain.clear();
+ const Name n3(".");
+ const LabelSequence ls3(n3);
+ result =
+ dtree_expose_empty_node.find(ls3, &cdtnode, chain,
+ testCallback, &flag);
+ EXPECT_EQ(DomainTree<int>::EXACTMATCH, result);
+ EXPECT_EQ(n3, chain.getAbsoluteName());
+
+ // Now, find "c." by searching just the non-absolute ls1 label
+ // sequence.
+ result = dtree_expose_empty_node.find(ls1, &cdtnode, chain,
+ testCallback, &flag);
+ EXPECT_EQ(DomainTree<int>::EXACTMATCH, result);
+ EXPECT_EQ(Name("c."), chain.getAbsoluteName());
+}
+
TEST_F(DomainTreeTest, chainLevel) {
TestDomainTreeNodeChain chain;
More information about the bind10-changes
mailing list