BIND 10 trac2850_2, updated. 32d750c6674613bd630eb1e724adc82b8ec8a622 [2850] Rename MemorySegmentTest to MemorySegmentMock (to not resemble a fixture)
BIND 10 source code commits
bind10-changes at lists.isc.org
Thu May 9 12:38:53 UTC 2013
The branch, trac2850_2 has been updated
via 32d750c6674613bd630eb1e724adc82b8ec8a622 (commit)
via 7bea7dd8c15ce158908b8c42c93533089d12da8a (commit)
via 4cac3ddb232eac0e52451c0aff718f3207fc7977 (commit)
from eda6761d2607385c10bb6a9e8bdc5c1209405093 (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 32d750c6674613bd630eb1e724adc82b8ec8a622
Author: Mukund Sivaraman <muks at isc.org>
Date: Thu May 9 18:08:27 2013 +0530
[2850] Rename MemorySegmentTest to MemorySegmentMock (to not resemble a fixture)
commit 7bea7dd8c15ce158908b8c42c93533089d12da8a
Author: Mukund Sivaraman <muks at isc.org>
Date: Thu May 9 17:58:31 2013 +0530
[2850] Rename ZoneTableSegmentTest to ZoneTableSegmentMock (to not resemble a fixture)
commit 4cac3ddb232eac0e52451c0aff718f3207fc7977
Author: Mukund Sivaraman <muks at isc.org>
Date: Thu May 9 17:44:49 2013 +0530
[2850] Destroy ZoneTableSegment object upon exception (see full log)
Ideally, this should use something like a SegmentObjectHolder, but a
SegmentObjectHolder takes unnecessary arguments. In this limited
usecase, ZoneTableSegment::destroy() just calls its destructor, so
std::auto_ptr should be ok here.
-----------------------------------------------------------------------
Summary of changes:
.../datasrc/tests/memory/memory_client_unittest.cc | 12 ++++++------
...memory_segment_test.h => memory_segment_mock.h} | 4 ++--
.../tests/memory/rrset_collection_unittest.cc | 6 +++---
.../tests/memory/zone_data_loader_unittest.cc | 4 ++--
src/lib/datasrc/tests/memory/zone_data_unittest.cc | 7 +++----
.../tests/memory/zone_data_updater_unittest.cc | 4 ++--
.../datasrc/tests/memory/zone_finder_unittest.cc | 10 +++++-----
.../memory/zone_table_segment_mapped_unittest.cc | 11 +++++++----
...le_segment_test.h => zone_table_segment_mock.h} | 6 +++---
.../datasrc/tests/memory/zone_table_unittest.cc | 6 +++---
.../datasrc/tests/memory/zone_writer_unittest.cc | 10 +++++-----
11 files changed, 41 insertions(+), 39 deletions(-)
rename src/lib/datasrc/tests/memory/{memory_segment_test.h => memory_segment_mock.h} (95%)
rename src/lib/datasrc/tests/memory/{zone_table_segment_test.h => zone_table_segment_mock.h} (94%)
-----------------------------------------------------------------------
diff --git a/src/lib/datasrc/tests/memory/memory_client_unittest.cc b/src/lib/datasrc/tests/memory/memory_client_unittest.cc
index f5b72a0..2092b44 100644
--- a/src/lib/datasrc/tests/memory/memory_client_unittest.cc
+++ b/src/lib/datasrc/tests/memory/memory_client_unittest.cc
@@ -37,8 +37,8 @@
#include <testutils/dnsmessage_test.h>
-#include "memory_segment_test.h"
-#include "zone_table_segment_test.h"
+#include <datasrc/tests/memory/memory_segment_mock.h>
+#include <datasrc/tests/memory/zone_table_segment_mock.h>
#include <gtest/gtest.h>
@@ -169,7 +169,7 @@ public:
class MemoryClientTest : public ::testing::Test {
protected:
MemoryClientTest() : zclass_(RRClass::IN()),
- ztable_segment_(new test::ZoneTableSegmentTest(
+ ztable_segment_(new test::ZoneTableSegmentMock(
zclass_, mem_sgmt_)),
client_(new InMemoryClient(ztable_segment_, zclass_))
{}
@@ -179,7 +179,7 @@ protected:
EXPECT_TRUE(mem_sgmt_.allMemoryDeallocated()); // catch any leak here.
}
const RRClass zclass_;
- test::MemorySegmentTest mem_sgmt_;
+ test::MemorySegmentMock mem_sgmt_;
shared_ptr<ZoneTableSegment> ztable_segment_;
boost::scoped_ptr<InMemoryClient> client_;
};
@@ -305,12 +305,12 @@ TEST_F(MemoryClientTest, loadMemoryAllocationFailures) {
mem_sgmt_.setThrowCount(i);
EXPECT_THROW({
shared_ptr<ZoneTableSegment> ztable_segment(
- new test::ZoneTableSegmentTest(
+ new test::ZoneTableSegmentMock(
zclass_, mem_sgmt_));
// Include the InMemoryClient construction too here. Now,
// even allocations done from InMemoryClient constructor
- // fail (due to MemorySegmentTest throwing) and we check for
+ // fail (due to MemorySegmentMock throwing) and we check for
// leaks when this happens.
InMemoryClient client2(ztable_segment, zclass_);
loadZoneIntoTable(*ztable_segment, Name("example.org"), zclass_,
diff --git a/src/lib/datasrc/tests/memory/memory_segment_mock.h b/src/lib/datasrc/tests/memory/memory_segment_mock.h
new file mode 100644
index 0000000..92c291d
--- /dev/null
+++ b/src/lib/datasrc/tests/memory/memory_segment_mock.h
@@ -0,0 +1,62 @@
+// Copyright (C) 2012 Internet Systems Consortium, Inc. ("ISC")
+//
+// Permission to use, copy, modify, and/or distribute this software for any
+// purpose with or without fee is hereby granted, provided that the above
+// copyright notice and this permission notice appear in all copies.
+//
+// THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH
+// REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
+// AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT,
+// INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
+// LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
+// OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
+// PERFORMANCE OF THIS SOFTWARE.
+
+#ifndef DATASRC_MEMORY_SEGMENT_TEST_H
+#define DATASRC_MEMORY_SEGMENT_TEST_H 1
+
+#include <util/memory_segment_local.h>
+
+#include <cstddef> // for size_t
+#include <new> // for bad_alloc
+
+namespace isc {
+namespace datasrc {
+namespace memory {
+namespace test {
+
+// A special memory segment that can be used for tests. It normally behaves
+// like a "local" memory segment. If "throw count" is set to non 0 via
+// setThrowCount(), it continues the normal behavior until the specified
+// number of calls to allocate(), exclusive, and throws an exception at the
+// next call. For example, if count is set to 3, the next two calls to
+// allocate() will succeed, and the 3rd call will fail with an exception.
+// This segment object can be used after the exception is thrown, and the
+// count is internally reset to 0.
+class MemorySegmentMock : public isc::util::MemorySegmentLocal {
+public:
+ MemorySegmentMock() : throw_count_(0) {}
+ virtual void* allocate(std::size_t size) {
+ if (throw_count_ > 0) {
+ if (--throw_count_ == 0) {
+ throw std::bad_alloc();
+ }
+ }
+ return (isc::util::MemorySegmentLocal::allocate(size));
+ }
+ void setThrowCount(std::size_t count) { throw_count_ = count; }
+
+private:
+ std::size_t throw_count_;
+};
+
+} // namespace test
+} // namespace memory
+} // namespace datasrc
+} // namespace isc
+
+#endif // DATASRC_MEMORY_SEGMENT_TEST_H
+
+// Local Variables:
+// mode: c++
+// End:
diff --git a/src/lib/datasrc/tests/memory/memory_segment_test.h b/src/lib/datasrc/tests/memory/memory_segment_test.h
deleted file mode 100644
index 3195a9b..0000000
--- a/src/lib/datasrc/tests/memory/memory_segment_test.h
+++ /dev/null
@@ -1,62 +0,0 @@
-// Copyright (C) 2012 Internet Systems Consortium, Inc. ("ISC")
-//
-// Permission to use, copy, modify, and/or distribute this software for any
-// purpose with or without fee is hereby granted, provided that the above
-// copyright notice and this permission notice appear in all copies.
-//
-// THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH
-// REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
-// AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT,
-// INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
-// LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
-// OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
-// PERFORMANCE OF THIS SOFTWARE.
-
-#ifndef DATASRC_MEMORY_SEGMENT_TEST_H
-#define DATASRC_MEMORY_SEGMENT_TEST_H 1
-
-#include <util/memory_segment_local.h>
-
-#include <cstddef> // for size_t
-#include <new> // for bad_alloc
-
-namespace isc {
-namespace datasrc {
-namespace memory {
-namespace test {
-
-// A special memory segment that can be used for tests. It normally behaves
-// like a "local" memory segment. If "throw count" is set to non 0 via
-// setThrowCount(), it continues the normal behavior until the specified
-// number of calls to allocate(), exclusive, and throws an exception at the
-// next call. For example, if count is set to 3, the next two calls to
-// allocate() will succeed, and the 3rd call will fail with an exception.
-// This segment object can be used after the exception is thrown, and the
-// count is internally reset to 0.
-class MemorySegmentTest : public isc::util::MemorySegmentLocal {
-public:
- MemorySegmentTest() : throw_count_(0) {}
- virtual void* allocate(std::size_t size) {
- if (throw_count_ > 0) {
- if (--throw_count_ == 0) {
- throw std::bad_alloc();
- }
- }
- return (isc::util::MemorySegmentLocal::allocate(size));
- }
- void setThrowCount(std::size_t count) { throw_count_ = count; }
-
-private:
- std::size_t throw_count_;
-};
-
-} // namespace test
-} // namespace memory
-} // namespace datasrc
-} // namespace isc
-
-#endif // DATASRC_MEMORY_SEGMENT_TEST_H
-
-// Local Variables:
-// mode: c++
-// End:
diff --git a/src/lib/datasrc/tests/memory/rrset_collection_unittest.cc b/src/lib/datasrc/tests/memory/rrset_collection_unittest.cc
index 04e285b..6329b6b 100644
--- a/src/lib/datasrc/tests/memory/rrset_collection_unittest.cc
+++ b/src/lib/datasrc/tests/memory/rrset_collection_unittest.cc
@@ -15,13 +15,13 @@
#include <datasrc/memory/rrset_collection.h>
-#include "memory_segment_test.h"
-
#include <datasrc/memory/zone_data_loader.h>
#include <datasrc/memory/segment_object_holder.h>
#include <dns/rrttl.h>
#include <dns/rdataclass.h>
+#include <datasrc/tests/memory/memory_segment_mock.h>
+
#include <gtest/gtest.h>
using namespace isc::dns;
@@ -52,7 +52,7 @@ public:
const RRClass rrclass;
const Name origin;
std::string zone_file;
- test::MemorySegmentTest mem_sgmt;
+ test::MemorySegmentMock mem_sgmt;
SegmentObjectHolder<ZoneData, RRClass> zone_data_holder;
RRsetCollection collection;
};
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 abc6f13..47ec4d3 100644
--- a/src/lib/datasrc/tests/memory/zone_data_loader_unittest.cc
+++ b/src/lib/datasrc/tests/memory/zone_data_loader_unittest.cc
@@ -22,7 +22,7 @@
#include <dns/name.h>
#include <dns/rrclass.h>
-#include "memory_segment_test.h"
+#include <datasrc/tests/memory/memory_segment_mock.h>
#include <gtest/gtest.h>
@@ -41,7 +41,7 @@ protected:
EXPECT_TRUE(mem_sgmt_.allMemoryDeallocated()); // catch any leak here.
}
const RRClass zclass_;
- test::MemorySegmentTest mem_sgmt_;
+ test::MemorySegmentMock mem_sgmt_;
ZoneData* zone_data_;
};
diff --git a/src/lib/datasrc/tests/memory/zone_data_unittest.cc b/src/lib/datasrc/tests/memory/zone_data_unittest.cc
index ffbd0f6..983e588 100644
--- a/src/lib/datasrc/tests/memory/zone_data_unittest.cc
+++ b/src/lib/datasrc/tests/memory/zone_data_unittest.cc
@@ -16,8 +16,6 @@
#include <datasrc/memory/rdata_serialization.h>
#include <datasrc/memory/rdataset.h>
-#include "memory_segment_test.h"
-
#include <dns/rdataclass.h>
#include <exceptions/exceptions.h>
@@ -30,6 +28,7 @@
#include <dns/rrttl.h>
#include <testutils/dnsmessage_test.h>
+#include <datasrc/tests/memory/memory_segment_mock.h>
#include <gtest/gtest.h>
@@ -73,7 +72,7 @@ protected:
EXPECT_TRUE(mem_sgmt_.allMemoryDeallocated());
}
- MemorySegmentTest mem_sgmt_;
+ MemorySegmentMock mem_sgmt_;
NSEC3Data* nsec3_data_;
const generic::NSEC3PARAM param_rdata_, param_rdata_nosalt_,
param_rdata_largesalt_;
@@ -88,7 +87,7 @@ protected:
// Shared by both test cases using NSEC3 and NSEC3PARAM Rdata
template <typename RdataType>
void
-checkNSEC3Data(MemorySegmentTest& mem_sgmt,
+checkNSEC3Data(MemorySegmentMock& mem_sgmt,
const Name& zone_name,
const RdataType& expect_rdata)
{
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 6399923..94870f9 100644
--- a/src/lib/datasrc/tests/memory/zone_data_updater_unittest.cc
+++ b/src/lib/datasrc/tests/memory/zone_data_updater_unittest.cc
@@ -25,7 +25,7 @@
#include <dns/rrset.h>
#include <dns/rrttl.h>
-#include "memory_segment_test.h"
+#include <datasrc/tests/memory/memory_segment_mock.h>
#include <gtest/gtest.h>
@@ -66,7 +66,7 @@ protected:
const Name zname_;
const RRClass zclass_;
- test::MemorySegmentTest mem_sgmt_;
+ test::MemorySegmentMock mem_sgmt_;
ZoneData* zone_data_;
boost::scoped_ptr<ZoneDataUpdater> updater_;
};
diff --git a/src/lib/datasrc/tests/memory/zone_finder_unittest.cc b/src/lib/datasrc/tests/memory/zone_finder_unittest.cc
index 0350ed9..be53820 100644
--- a/src/lib/datasrc/tests/memory/zone_finder_unittest.cc
+++ b/src/lib/datasrc/tests/memory/zone_finder_unittest.cc
@@ -12,8 +12,8 @@
// OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
// PERFORMANCE OF THIS SOFTWARE.
-#include <datasrc/tests/memory/memory_segment_test.h>
-#include <datasrc/tests/memory/zone_table_segment_test.h>
+#include <datasrc/tests/memory/memory_segment_mock.h>
+#include <datasrc/tests/memory/zone_table_segment_mock.h>
#include <datasrc/tests/memory/zone_loader_util.h>
// NOTE: this faked_nsec3 inclusion (and all related code below)
@@ -221,7 +221,7 @@ protected:
const RRClass class_;
const Name origin_;
// The zone finder to torture by tests
- MemorySegmentTest mem_sgmt_;
+ MemorySegmentMock mem_sgmt_;
memory::ZoneData* zone_data_;
memory::InMemoryZoneFinder zone_finder_;
ZoneDataUpdater updater_;
@@ -1613,7 +1613,7 @@ TEST_F(InMemoryZoneFinderTest, findOrphanRRSIG) {
TEST_F(InMemoryZoneFinderTest, NSECNonExistentTest) {
const Name name("example.com.");
shared_ptr<ZoneTableSegment> ztable_segment(
- new ZoneTableSegmentTest(class_, mem_sgmt_));
+ new ZoneTableSegmentMock(class_, mem_sgmt_));
loadZoneIntoTable(*ztable_segment, name, class_,
TEST_DATA_DIR "/2504-test.zone");
InMemoryClient client(ztable_segment, class_);
@@ -1775,7 +1775,7 @@ TEST_F(InMemoryZoneFinderNSEC3Test, findNSEC3MissingOrigin) {
const Name name("example.com.");
shared_ptr<ZoneTableSegment> ztable_segment(
- new ZoneTableSegmentTest(class_, mem_sgmt_));
+ new ZoneTableSegmentMock(class_, mem_sgmt_));
loadZoneIntoTable(*ztable_segment, name, class_,
TEST_DATA_DIR "/2503-test.zone");
InMemoryClient client(ztable_segment, class_);
diff --git a/src/lib/datasrc/tests/memory/zone_table_segment_mapped_unittest.cc b/src/lib/datasrc/tests/memory/zone_table_segment_mapped_unittest.cc
index d7bffa1..8a6fcaf 100644
--- a/src/lib/datasrc/tests/memory/zone_table_segment_mapped_unittest.cc
+++ b/src/lib/datasrc/tests/memory/zone_table_segment_mapped_unittest.cc
@@ -22,6 +22,7 @@
#include <boost/scoped_ptr.hpp>
#include <boost/interprocess/file_mapping.hpp>
+#include <memory>
#include <cerrno>
#include <sys/stat.h>
@@ -51,17 +52,17 @@ protected:
Element::fromJSON(
"{\"mapped-file\": \"" + std::string(mapped_file2) + "\"}"))
{
- EXPECT_NE(static_cast<void*>(NULL), ztable_segment_);
+ EXPECT_NE(static_cast<void*>(NULL), ztable_segment_.get());
// Verify that a ZoneTableSegmentMapped is created.
ZoneTableSegmentMapped* mapped_segment =
- dynamic_cast<ZoneTableSegmentMapped*>(ztable_segment_);
+ dynamic_cast<ZoneTableSegmentMapped*>(ztable_segment_.get());
EXPECT_NE(static_cast<void*>(NULL), mapped_segment);
createTestData();
}
~ZoneTableSegmentMappedTest() {
- ZoneTableSegment::destroy(ztable_segment_);
+ ZoneTableSegment::destroy(ztable_segment_.release());
boost::interprocess::file_mapping::remove(mapped_file);
boost::interprocess::file_mapping::remove(mapped_file2);
}
@@ -81,7 +82,9 @@ protected:
void addData(MemorySegment& segment);
bool verifyData(const MemorySegment& segment);
- ZoneTableSegment* ztable_segment_;
+ // Ideally, this should be something similar to a
+ // SegmentObjectHolder, not an auto_ptr.
+ std::auto_ptr<ZoneTableSegment> ztable_segment_;
const ConstElementPtr config_params_;
const ConstElementPtr config_params2_;
std::vector<TestDataElement> test_data_;
diff --git a/src/lib/datasrc/tests/memory/zone_table_segment_mock.h b/src/lib/datasrc/tests/memory/zone_table_segment_mock.h
new file mode 100644
index 0000000..4eae191
--- /dev/null
+++ b/src/lib/datasrc/tests/memory/zone_table_segment_mock.h
@@ -0,0 +1,87 @@
+// Copyright (C) 2012 Internet Systems Consortium, Inc. ("ISC")
+//
+// Permission to use, copy, modify, and/or distribute this software for any
+// purpose with or without fee is hereby granted, provided that the above
+// copyright notice and this permission notice appear in all copies.
+//
+// THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH
+// REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
+// AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT,
+// INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
+// LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
+// OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
+// PERFORMANCE OF THIS SOFTWARE.
+
+#ifndef DATASRC_MEMORY_ZONE_TABLE_SEGMENT_TEST_H
+#define DATASRC_MEMORY_ZONE_TABLE_SEGMENT_TEST_H 1
+
+#include <datasrc/memory/zone_table_segment.h>
+#include <datasrc/memory/zone_table.h>
+#include <datasrc/memory/zone_data.h>
+#include <datasrc/memory/zone_writer.h>
+
+namespace isc {
+namespace datasrc {
+namespace memory {
+namespace test {
+
+// A special ZoneTableSegment that can be used for tests. It can be
+// passed a MemorySegment that can be used later to test if all memory
+// was de-allocated on it.
+class ZoneTableSegmentMock : public ZoneTableSegment {
+public:
+ ZoneTableSegmentMock(const isc::dns::RRClass& rrclass,
+ isc::util::MemorySegment& mem_sgmt) :
+ ZoneTableSegment(rrclass),
+ mem_sgmt_(mem_sgmt),
+ header_(ZoneTable::create(mem_sgmt_, rrclass))
+ {}
+
+ virtual ~ZoneTableSegmentMock() {
+ ZoneTable::destroy(mem_sgmt_, header_.getTable());
+ }
+
+ virtual void reset(MemorySegmentOpenMode, isc::data::ConstElementPtr) {
+ isc_throw(isc::NotImplemented, "reset() is not implemented");
+ }
+
+ virtual void clear() {
+ isc_throw(isc::NotImplemented, "clear() is not implemented");
+ }
+
+ virtual void resetHeader() {
+ // This method does not have to do anything in this
+ // implementation.
+ }
+
+ virtual ZoneTableHeader& getHeader() {
+ return (header_);
+ }
+
+ virtual const ZoneTableHeader& getHeader() const {
+ return (header_);
+ }
+
+ virtual isc::util::MemorySegment& getMemorySegment() {
+ return (mem_sgmt_);
+ }
+
+ virtual bool isWritable() const {
+ return (true);
+ }
+
+private:
+ isc::util::MemorySegment& mem_sgmt_;
+ ZoneTableHeader header_;
+};
+
+} // namespace test
+} // namespace memory
+} // namespace datasrc
+} // namespace isc
+
+#endif // DATASRC_MEMORY_ZONE_TABLE_SEGMENT_TEST_H
+
+// Local Variables:
+// mode: c++
+// End:
diff --git a/src/lib/datasrc/tests/memory/zone_table_segment_test.h b/src/lib/datasrc/tests/memory/zone_table_segment_test.h
deleted file mode 100644
index 2d1368c..0000000
--- a/src/lib/datasrc/tests/memory/zone_table_segment_test.h
+++ /dev/null
@@ -1,87 +0,0 @@
-// Copyright (C) 2012 Internet Systems Consortium, Inc. ("ISC")
-//
-// Permission to use, copy, modify, and/or distribute this software for any
-// purpose with or without fee is hereby granted, provided that the above
-// copyright notice and this permission notice appear in all copies.
-//
-// THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH
-// REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
-// AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT,
-// INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
-// LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
-// OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
-// PERFORMANCE OF THIS SOFTWARE.
-
-#ifndef DATASRC_MEMORY_ZONE_TABLE_SEGMENT_TEST_H
-#define DATASRC_MEMORY_ZONE_TABLE_SEGMENT_TEST_H 1
-
-#include <datasrc/memory/zone_table_segment.h>
-#include <datasrc/memory/zone_table.h>
-#include <datasrc/memory/zone_data.h>
-#include <datasrc/memory/zone_writer.h>
-
-namespace isc {
-namespace datasrc {
-namespace memory {
-namespace test {
-
-// A special ZoneTableSegment that can be used for tests. It can be
-// passed a MemorySegment that can be used later to test if all memory
-// was de-allocated on it.
-class ZoneTableSegmentTest : public ZoneTableSegment {
-public:
- ZoneTableSegmentTest(const isc::dns::RRClass& rrclass,
- isc::util::MemorySegment& mem_sgmt) :
- ZoneTableSegment(rrclass),
- mem_sgmt_(mem_sgmt),
- header_(ZoneTable::create(mem_sgmt_, rrclass))
- {}
-
- virtual ~ZoneTableSegmentTest() {
- ZoneTable::destroy(mem_sgmt_, header_.getTable());
- }
-
- virtual void reset(MemorySegmentOpenMode, isc::data::ConstElementPtr) {
- isc_throw(isc::NotImplemented, "reset() is not implemented");
- }
-
- virtual void clear() {
- isc_throw(isc::NotImplemented, "clear() is not implemented");
- }
-
- virtual void resetHeader() {
- // This method does not have to do anything in this
- // implementation.
- }
-
- virtual ZoneTableHeader& getHeader() {
- return (header_);
- }
-
- virtual const ZoneTableHeader& getHeader() const {
- return (header_);
- }
-
- virtual isc::util::MemorySegment& getMemorySegment() {
- return (mem_sgmt_);
- }
-
- virtual bool isWritable() const {
- return (true);
- }
-
-private:
- isc::util::MemorySegment& mem_sgmt_;
- ZoneTableHeader header_;
-};
-
-} // namespace test
-} // namespace memory
-} // namespace datasrc
-} // namespace isc
-
-#endif // DATASRC_MEMORY_ZONE_TABLE_SEGMENT_TEST_H
-
-// Local Variables:
-// mode: c++
-// End:
diff --git a/src/lib/datasrc/tests/memory/zone_table_unittest.cc b/src/lib/datasrc/tests/memory/zone_table_unittest.cc
index 0109793..6599f3b 100644
--- a/src/lib/datasrc/tests/memory/zone_table_unittest.cc
+++ b/src/lib/datasrc/tests/memory/zone_table_unittest.cc
@@ -12,8 +12,6 @@
// OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
// PERFORMANCE OF THIS SOFTWARE.
-#include "memory_segment_test.h"
-
#include <exceptions/exceptions.h>
#include <util/memory_segment_local.h>
@@ -26,6 +24,8 @@
#include <datasrc/memory/zone_table.h>
#include <datasrc/memory/segment_object_holder.h>
+#include <datasrc/tests/memory/memory_segment_mock.h>
+
#include <gtest/gtest.h>
#include <new> // for bad_alloc
@@ -56,7 +56,7 @@ protected:
}
const RRClass zclass_;
const Name zname1, zname2, zname3;
- test::MemorySegmentTest mem_sgmt_;
+ test::MemorySegmentMock mem_sgmt_;
ZoneTable* zone_table;
};
diff --git a/src/lib/datasrc/tests/memory/zone_writer_unittest.cc b/src/lib/datasrc/tests/memory/zone_writer_unittest.cc
index d69fce5..455e1c9 100644
--- a/src/lib/datasrc/tests/memory/zone_writer_unittest.cc
+++ b/src/lib/datasrc/tests/memory/zone_writer_unittest.cc
@@ -19,8 +19,8 @@
#include <dns/rrclass.h>
#include <dns/name.h>
-#include <datasrc/tests/memory/memory_segment_test.h>
-#include <datasrc/tests/memory/zone_table_segment_test.h>
+#include <datasrc/tests/memory/memory_segment_mock.h>
+#include <datasrc/tests/memory/zone_table_segment_mock.h>
#include <gtest/gtest.h>
@@ -88,11 +88,11 @@ public:
}
};
-class ReadOnlySegment : public ZoneTableSegmentTest {
+class ReadOnlySegment : public ZoneTableSegmentMock {
public:
ReadOnlySegment(const isc::dns::RRClass& rrclass,
isc::util::MemorySegment& mem_sgmt) :
- ZoneTableSegmentTest(rrclass, mem_sgmt)
+ ZoneTableSegmentMock(rrclass, mem_sgmt)
{}
// Returns false indicating it is a read-only segment. It is used in
@@ -103,7 +103,7 @@ public:
};
TEST_F(ZoneWriterTest, constructForReadOnlySegment) {
- MemorySegmentTest mem_sgmt;
+ MemorySegmentMock mem_sgmt;
ReadOnlySegment ztable_segment(RRClass::IN(), mem_sgmt);
EXPECT_THROW(ZoneWriter(ztable_segment,
bind(&ZoneWriterTest::loadAction, this, _1),
More information about the bind10-changes
mailing list