From 108a4c3ced7673fb7369faff2f9612317db67ae2 Mon Sep 17 00:00:00 2001 From: Aki Tuomi Date: Tue, 28 Jan 2014 16:32:03 +0200 Subject: [PATCH] Zoneparser test case --- pdns/Makefile.am | 3 ++- pdns/test-zoneparser_tng_cc.cc | 41 ++++++++++++++++++++++++++++++++ regression-tests/zones/unit.test | 9 +++++++ 3 files changed, 52 insertions(+), 1 deletion(-) create mode 100644 pdns/test-zoneparser_tng_cc.cc create mode 100644 regression-tests/zones/unit.test diff --git a/pdns/Makefile.am b/pdns/Makefile.am index 785f8e653..0ccccdc00 100644 --- a/pdns/Makefile.am +++ b/pdns/Makefile.am @@ -304,7 +304,8 @@ testrunner_SOURCES=testrunner.cc test-misc_hh.cc test-nameserver_cc.cc test-dnsr rcpgenerator.cc ednssubnet.cc nsecrecords.cc sillyrecords.cc dnssecinfra.cc \ test-base64_cc.cc test-iputils_hh.cc test-dns_random_hh.cc dns_random.cc \ test-rcpgenerator_cc.cc responsestats.cc test-bindparser_cc.cc \ - bindparser.cc bindlexer.c dns.cc + bindparser.cc bindlexer.c test-zoneparser_tng_cc.cc zoneparser-tng.hh \ + zoneparser-tng.cc dns.cc testrunner_LDFLAGS= @DYNLINKFLAGS@ @THREADFLAGS@ $(BOOST_UNIT_TEST_FRAMEWORK_LDFLAGS) testrunner_LDADD= $(POLARSSL_LIBS) $(BOOST_UNIT_TEST_FRAMEWORK_LIBS) diff --git a/pdns/test-zoneparser_tng_cc.cc b/pdns/test-zoneparser_tng_cc.cc new file mode 100644 index 000000000..a62957c14 --- /dev/null +++ b/pdns/test-zoneparser_tng_cc.cc @@ -0,0 +1,41 @@ +#define BOOST_TEST_DYN_LINK +#define BOOST_TEST_NO_MAIN +#include +#include +#include +#include +#include +#include +#include +#include "dns.hh" +#include "zoneparser-tng.hh" +#include + +BOOST_AUTO_TEST_SUITE(test_zoneparser_tng_cc) + +BOOST_AUTO_TEST_CASE(test_tng_record_types) { + ZoneParserTNG zp("../regression-tests/zones/unit.test", "unit.test"); + DNSResourceRecord rr; + + boost::iostreams::stream ifs("../regression-tests/zones/unit.test"); + + while(zp.get(rr)) { + // make sure these concur. + std::string host, type, data; + int ttl; + std::getline(ifs, host, ' '); + std::getline(ifs, type, ' '); + ttl = boost::lexical_cast(type); + std::getline(ifs, type, ' '); + std::getline(ifs, type, ' '); + std::getline(ifs, data, '\n'); + // see if these agree + BOOST_CHECK_EQUAL(rr.qname, host); + BOOST_CHECK_EQUAL(rr.ttl, ttl); + BOOST_CHECK_EQUAL(rr.qtype.getName(), type); + BOOST_CHECK_EQUAL(rr.getZoneRepresentation(), data); + } + +} + +BOOST_AUTO_TEST_SUITE_END(); diff --git a/regression-tests/zones/unit.test b/regression-tests/zones/unit.test new file mode 100644 index 000000000..107741d78 --- /dev/null +++ b/regression-tests/zones/unit.test @@ -0,0 +1,9 @@ +unit.test. 300 IN SOA ns.unit.test. hostmaster.unit.test. 1 3600 1200 604800 300 +unit.test. 300 IN NS ns.unit.test. +unit.test. 300 IN MX 30 mx.unit.test. +unit.test. 300 IN A 1.2.3.4 +root.mx.unit.test. 300 IN MX 20 . +root.srv.unit.test. 300 IN SRV 10 10 5060 . +naptr-a.unit.test. 300 IN NAPTR 100 10 "" "" "/urn:cid:.+@([^\.]+\.)(.*)$/\2/i" . +naptr-b.unit.test. 300 IN NAPTR 100 50 "s" "http+I2L+I2C+I2R" "" _http._tcp.rec.test. +unit.test. 300 IN SOA ns.unit.test. hostmaster.unit.test. 1 3600 1200 604800 300 -- 2.40.0