]> granicus.if.org Git - pdns/commitdiff
Add unit test for zone file with template
authorOtto Moerbeek <otto.moerbeek@open-xchange.com>
Wed, 9 Oct 2019 14:21:00 +0000 (16:21 +0200)
committerOtto Moerbeek <otto.moerbeek@open-xchange.com>
Wed, 9 Oct 2019 14:21:00 +0000 (16:21 +0200)
pdns/test-zoneparser_tng_cc.cc
regression-tests/zones/unit2.test [new file with mode: 0644]

index d923d52d1ea001cfcfb71d3cd38573bc34b6fbbb..82e8481f2e2621a98b0f26e0e978af0a923df0ed 100644 (file)
@@ -50,7 +50,48 @@ BOOST_AUTO_TEST_CASE(test_tng_record_types) {
       BOOST_CHECK_EQUAL(rr.content, std::string(data.begin(),data.end()-1));
     else
       BOOST_CHECK_EQUAL(rr.content, data);
-  } 
+  }
+}
+
+BOOST_AUTO_TEST_CASE(test_tng_record_generate) {
+  reportAllTypes();
+
+  std::ostringstream pathbuf;
+  const char* p = std::getenv("SRCDIR");
+  if(!p)
+    p = ".";
+  pathbuf << p << "/../regression-tests/zones/unit2.test";
+  ZoneParserTNG zp(pathbuf.str(), DNSName("unit2.test"));
+
+  string expected[] = {
+    "0.01.0003.000005.00000007.unit2.test.",
+    "1.02.0004.000006.00000008.unit2.test.",
+    "2.03.0005.000007.00000009.unit2.test.",
+    "3.04.0006.000008.0000000a.unit2.test.",
+    "4.05.0007.000009.0000000b.unit2.test.",
+    "5.06.0008.00000A.0000000c.unit2.test.",
+    "6.07.0009.00000B.0000000d.unit2.test.",
+    "7.10.0010.00000C.0000000e.unit2.test.",
+    "8.11.0011.00000D.0000000f.unit2.test.",
+    "9.12.0012.00000E.00000010.unit2.test.",
+    "10.13.0013.00000F.00000011.unit2.test.",
+    "11.14.0014.000010.00000012.unit2.test.",
+    "12.15.0015.000011.00000013.unit2.test.",
+    "13.16.0016.000012.00000014.unit2.test.",
+    "14.17.0017.000013.00000015.unit2.test.",
+    "15.20.0018.000014.00000016.unit2.test.",
+    "16.21.0019.000015.00000017.unit2.test."
+  };
+
+  for (size_t i = 0; i < sizeof(expected) / sizeof(expected[0]); i++) {
+    DNSResourceRecord rr;
+    zp.get(rr);
+    BOOST_CHECK_EQUAL(rr.qname.toString(), expected[i]);
+    BOOST_CHECK_EQUAL(rr.ttl, 86400U);
+    BOOST_CHECK_EQUAL(rr.qclass, 1U);
+    BOOST_CHECK_EQUAL(rr.qtype.getName(), "A");
+    BOOST_CHECK_EQUAL(rr.content, "1.2.3.4");
+  }
 
 }
 
diff --git a/regression-tests/zones/unit2.test b/regression-tests/zones/unit2.test
new file mode 100644 (file)
index 0000000..041e66b
--- /dev/null
@@ -0,0 +1 @@
+$GENERATE 0-16 $.${1,2,o}.${3,4,d}.${5,6,X}.${7,8,x}   86400   IN      A 1.2.3.4