From: Michal 'vorner' Vaner Date: Thu, 2 May 2013 14:04:13 +0000 (+0200) Subject: [2836] Test growth of the mapped segment X-Git-Tag: bind10-1.2.0beta1-release~457^2~36 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=a752e1aeacc9470ff3dfb172bf3f9064eefc3161;p=thirdparty%2Fkea.git [2836] Test growth of the mapped segment Fill the memory image with a lot of records, so the segment must grow. Currently fails, because the growth is not handled. --- diff --git a/src/lib/datasrc/tests/memory/zone_data_updater_unittest.cc b/src/lib/datasrc/tests/memory/zone_data_updater_unittest.cc index ae18246857..78cfc54ea3 100644 --- a/src/lib/datasrc/tests/memory/zone_data_updater_unittest.cc +++ b/src/lib/datasrc/tests/memory/zone_data_updater_unittest.cc @@ -33,6 +33,7 @@ #include #include +#include #include @@ -56,6 +57,16 @@ public: virtual void cleanup() const {}; }; +ZoneNode* +getNode(isc::util::MemorySegment& mem_sgmt, const Name& name, + ZoneData* zone_data) +{ + ZoneNode* node = NULL; + zone_data->insertName(mem_sgmt, name, &node); + EXPECT_NE(static_cast(NULL), node); + return (node); +} + class ZoneDataUpdaterTest : public ::testing::TestWithParam { protected: ZoneDataUpdaterTest() : @@ -149,16 +160,6 @@ TEST_P(ZoneDataUpdaterTest, bothNull) { ZoneDataUpdater::NullRRset); } -ZoneNode* -getNode(isc::util::MemorySegment& mem_sgmt, const Name& name, - ZoneData* zone_data) -{ - ZoneNode* node = NULL; - zone_data->insertName(mem_sgmt, name, &node); - EXPECT_NE(static_cast(NULL), node); - return (node); -} - TEST_P(ZoneDataUpdaterTest, zoneMinTTL) { // If we add SOA, zone's min TTL will be updated. updater_->add(textToRRset( @@ -286,4 +287,29 @@ TEST_P(ZoneDataUpdaterTest, rrsigForNSEC3Only) { isc::NotImplemented); } +// Generate many small RRsets. This tests that the underlying memory segment +// can grow during the execution and that the updater handles that well. +// +// Some of the grows will happen inserting the RRSIG, some with the TXT. +TEST_P(ZoneDataUpdaterTest, manySmallRRsets) { + for (size_t i = 0; i < 32768; ++i) { + const std::string name(boost::lexical_cast(i) + + ".example.org."); + updater_->add(textToRRset(name + " 3600 IN TXT " + + std::string(30, 'X')), + textToRRset(name + " 3600 IN RRSIG TXT 5 3 3600 " + "20150420235959 20051021000000 1 " + "example.org. FAKE")); + ZoneNode* node = getNode(*mem_sgmt_, + Name(boost::lexical_cast(i) + + ".example.org"), zone_data_); + const RdataSet* rdset = node->getData(); + ASSERT_NE(static_cast(NULL), rdset); + rdset = RdataSet::find(rdset, RRType::TXT(), true); + ASSERT_NE(static_cast(NULL), rdset); + EXPECT_EQ(1, rdset->getRdataCount()); + EXPECT_EQ(1, rdset->getSigRdataCount()); + } +} + }