Browse Source

[2108] Test for segment leaks due to allocation failures

Mukund Sivaraman 12 years ago
parent
commit
d976012056
1 changed files with 12 additions and 0 deletions
  1. 12 0
      src/lib/datasrc/memory/tests/memory_client_unittest.cc

+ 12 - 0
src/lib/datasrc/memory/tests/memory_client_unittest.cc

@@ -211,6 +211,18 @@ TEST_F(MemoryClientTest, loadFromIterator) {
     EXPECT_THROW(iterator->getNextRRset(), isc::Unexpected);
 }
 
+TEST_F(MemoryClientTest, loadMemoryAllocationFailures) {
+    // Just to check that things get cleaned up
+
+    for (int i = 1; i < 16; i++) {
+        mem_sgmt_.setThrowCount(i);
+        EXPECT_THROW(client_->load(Name("example.org"),
+                                   TEST_DATA_DIR "/example.org.zone"),
+                     std::bad_alloc);
+    }
+    // Teardown checks for memory segment leaks
+}
+
 TEST_F(MemoryClientTest, loadNSEC3Signed) {
     client_->load(Name("example.org"),
                   TEST_DATA_DIR "/example.org-nsec3-signed.zone");