|
@@ -18,15 +18,19 @@
|
|
|
|
|
|
#include <dns/name.h>
|
|
#include <dns/name.h>
|
|
#include <dns/labelsequence.h>
|
|
#include <dns/labelsequence.h>
|
|
|
|
+#include <dns/rrclass.h>
|
|
|
|
|
|
#include <datasrc/memory/rdata_encoder.h>
|
|
#include <datasrc/memory/rdata_encoder.h>
|
|
#include <datasrc/memory/rdataset.h>
|
|
#include <datasrc/memory/rdataset.h>
|
|
#include <datasrc/memory/zone_data.h>
|
|
#include <datasrc/memory/zone_data.h>
|
|
|
|
|
|
|
|
+#include <testutils/dnsmessage_test.h>
|
|
|
|
+
|
|
#include <gtest/gtest.h>
|
|
#include <gtest/gtest.h>
|
|
|
|
|
|
using namespace isc::dns;
|
|
using namespace isc::dns;
|
|
using namespace isc::datasrc::memory;
|
|
using namespace isc::datasrc::memory;
|
|
|
|
+using namespace isc::testutils;
|
|
|
|
|
|
namespace {
|
|
namespace {
|
|
|
|
|
|
@@ -37,7 +41,7 @@ protected:
|
|
{}
|
|
{}
|
|
void TearDown() {
|
|
void TearDown() {
|
|
if (zone_data_ != NULL) {
|
|
if (zone_data_ != NULL) {
|
|
- ZoneData::destroy(mem_sgmt_, zone_data_);
|
|
|
|
|
|
+ ZoneData::destroy(RRClass::IN(), mem_sgmt_, zone_data_);
|
|
}
|
|
}
|
|
// detect any memory leak in the test memory segment
|
|
// detect any memory leak in the test memory segment
|
|
EXPECT_TRUE(mem_sgmt_.allMemoryDeallocated());
|
|
EXPECT_TRUE(mem_sgmt_.allMemoryDeallocated());
|
|
@@ -52,4 +56,31 @@ protected:
|
|
TEST_F(ZoneDataTest, getOriginNode) {
|
|
TEST_F(ZoneDataTest, getOriginNode) {
|
|
EXPECT_EQ(LabelSequence(zname_), zone_data_->getOriginNode()->getLabels());
|
|
EXPECT_EQ(LabelSequence(zname_), zone_data_->getOriginNode()->getLabels());
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+TEST_F(ZoneDataTest, addRdataSets) {
|
|
|
|
+ // Insert a name to the zone, and add a couple the data (RdataSet) objects
|
|
|
|
+ // to the corresponding node.
|
|
|
|
+
|
|
|
|
+ ConstRRsetPtr a_rrset_ =
|
|
|
|
+ textToRRset("www.example.com. 3600 IN A 192.0.2.1");
|
|
|
|
+
|
|
|
|
+ ZoneData::ZoneNode* node = NULL;
|
|
|
|
+ zone_data_->insertName(mem_sgmt_, a_rrset_->getName(), &node);
|
|
|
|
+ ASSERT_NE(static_cast<ZoneData::ZoneNode*>(NULL), node);
|
|
|
|
+ EXPECT_TRUE(node->isEmpty()); // initially it should be empty
|
|
|
|
+
|
|
|
|
+ RdataSet* rdataset_a =
|
|
|
|
+ RdataSet::create(mem_sgmt_, encoder_, a_rrset_, ConstRRsetPtr());
|
|
|
|
+ node->setData(rdataset_a);
|
|
|
|
+
|
|
|
|
+ ConstRRsetPtr aaaa_rrset_ =
|
|
|
|
+ textToRRset("www.example.com. 3600 IN AAAA 2001:db8::1");
|
|
|
|
+ RdataSet* rdataset_aaaa =
|
|
|
|
+ RdataSet::create(mem_sgmt_, encoder_, aaaa_rrset_, ConstRRsetPtr());
|
|
|
|
+ // make a linked list and replace the list head
|
|
|
|
+ rdataset_aaaa->next = rdataset_a;
|
|
|
|
+ node->setData(rdataset_aaaa);
|
|
|
|
+
|
|
|
|
+ // TearDown() will confirm there's no leak on destroy
|
|
|
|
+}
|
|
}
|
|
}
|