Browse Source

[2108] Test some types of errors in zone files don't cause leaks

Mukund Sivaraman 12 years ago
parent
commit
4f132f4700

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

@@ -95,6 +95,26 @@ TEST_F(MemoryClientTest, loadRRsetDoesntMatchOrigin) {
                  MasterLoadError);
 }
 
+TEST_F(MemoryClientTest, loadErrorsInParsingZoneMustNotLeak1) {
+    // Attempting to load broken example.org zone should result in an
+    // exception. This should not leak ZoneData and other such
+    // allocations.
+    EXPECT_THROW(client_->load(Name("example.org"),
+                               TEST_DATA_DIR "/example.org-broken1.zone"),
+                 MasterLoadError);
+    // Teardown checks for memory segment leaks
+}
+
+TEST_F(MemoryClientTest, loadErrorsInParsingZoneMustNotLeak2) {
+    // Attempting to load broken example.org zone should result in an
+    // exception. This should not leak ZoneData and other such
+    // allocations.
+    EXPECT_THROW(client_->load(Name("example.org"),
+                               TEST_DATA_DIR "/example.org-broken2.zone"),
+                 MasterLoadError);
+    // Teardown checks for memory segment leaks
+}
+
 TEST_F(MemoryClientTest, getZoneCount) {
     EXPECT_EQ(0, client_->getZoneCount());
     client_->load(Name("example.org"), TEST_DATA_DIR "/example.org-empty.zone");

+ 2 - 0
src/lib/datasrc/memory/tests/testdata/Makefile.am

@@ -1,3 +1,5 @@
 CLEANFILES = *.copied
 
 EXTRA_DIST = example.org-empty.zone
+EXTRA_DIST += example.org-broken1.zone
+EXTRA_DIST += example.org-broken2.zone

+ 1 - 0
src/lib/datasrc/memory/tests/testdata/example.org-broken1.zone

@@ -0,0 +1 @@
+This is a broken zone that should not parse.

+ 5 - 0
src/lib/datasrc/memory/tests/testdata/example.org-broken2.zone

@@ -0,0 +1,5 @@
+;; broken example.org zone, where some RRs are OK, but others aren't
+example.org. 3600 IN SOA	ns1.example.org. bugs.x.w.example.org. 73 3600 300 3600000 3600
+ns1.example.org.		      3600 IN A		192.0.2.1
+ns2.example.org.		      3600 IN A		192.0.2.2
+ns2.a.example.com.		      3600 IN AAAA