From: Michal 'vorner' Vaner Date: Mon, 13 May 2013 13:00:51 +0000 (+0200) Subject: [2836] Attempt a test for whole zone loading X-Git-Tag: bind10-1.2.0beta1-release~457^2~14 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=423740919b7a050dc1255a0ebdc6ab6b71ea777f;p=thirdparty%2Fkea.git [2836] Attempt a test for whole zone loading Attempt to write a test that loads a bunch of zones, probably causing a relocation. However, it currently crashes and does so before the relocation happens, which is strange. It does not crash with the local segment, only with the mapped, which is stranger. --- diff --git a/src/lib/datasrc/tests/memory/zone_data_loader_unittest.cc b/src/lib/datasrc/tests/memory/zone_data_loader_unittest.cc index abc6f13357..a9aaea3906 100644 --- a/src/lib/datasrc/tests/memory/zone_data_loader_unittest.cc +++ b/src/lib/datasrc/tests/memory/zone_data_loader_unittest.cc @@ -16,11 +16,16 @@ #include #include #include +#include +#include #include #include #include +#include +#include +#include #include "memory_segment_test.h" @@ -28,9 +33,13 @@ using namespace isc::dns; using namespace isc::datasrc::memory; +using isc::util::MemorySegmentMapped; +using isc::datasrc::memory::detail::SegmentObjectHolder; namespace { +const char* const mapped_file = TEST_DATA_BUILDDIR "/test.mapped"; + class ZoneDataLoaderTest : public ::testing::Test { protected: ZoneDataLoaderTest() : zclass_(RRClass::IN()), zone_data_(NULL) {} @@ -73,4 +82,31 @@ TEST_F(ZoneDataLoaderTest, zoneMinTTL) { EXPECT_EQ(RRTTL(1200), RRTTL(b)); } +// Load bunch of small zones, hoping some of the relocation will happen +// during the memory creation, not only Rdata creation. +TEST(ZoneDataLoaterTest, relocate) { + MemorySegmentMapped segment(mapped_file, + isc::util::MemorySegmentMapped::CREATE_ONLY, + 4096); + const size_t zone_count = 10000; + typedef SegmentObjectHolder Holder; + typedef boost::shared_ptr HolderPtr; + std::vector zones; + for (size_t i = 0; i < zone_count; ++i) { + // Load some zone + ZoneData* data = loadZoneData(segment, RRClass::IN(), + Name("example.org"), + TEST_DATA_DIR + "/example.org-nsec3-signed.zone"); + // Store it, so it is cleaned up later + zones.push_back(HolderPtr(new Holder(segment, data, + RRClass::IN()))); + + } + // Deallocate all the zones now. + zones.clear(); + EXPECT_TRUE(segment.allMemoryDeallocated()); + EXPECT_EQ(0, unlink(mapped_file)); +} + }