|
@@ -16,11 +16,16 @@
|
|
|
#include <datasrc/memory/rdataset.h>
|
|
|
#include <datasrc/memory/zone_data.h>
|
|
|
#include <datasrc/memory/zone_data_updater.h>
|
|
|
+#include <datasrc/memory/segment_object_holder.h>
|
|
|
+#include <datasrc/zone_iterator.h>
|
|
|
|
|
|
#include <util/buffer.h>
|
|
|
|
|
|
#include <dns/name.h>
|
|
|
#include <dns/rrclass.h>
|
|
|
+#include <dns/rdataclass.h>
|
|
|
+#include <util/memory_segment_mapped.h>
|
|
|
+#include <util/memory_segment_local.h>
|
|
|
|
|
|
#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<ZoneData, RRClass> Holder;
|
|
|
+ typedef boost::shared_ptr<Holder> HolderPtr;
|
|
|
+ std::vector<HolderPtr> 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));
|
|
|
+}
|
|
|
+
|
|
|
}
|