Commit 1fda1251 authored by JINMEI Tatuya's avatar JINMEI Tatuya
Browse files

trac #354: dynamically generate wiredata when possible.

adjusted the generator script a bit for this purpose.
also fixed a distcheck failure in lib/dns/python tests.

git-svn-id: svn://bind10.isc.org/svn/bind10/branches/trac354@3047 e5f2f494-b856-4b98-b285-d166d9295462
parent a2e58bdc
......@@ -443,6 +443,7 @@ AC_CONFIG_FILES([Makefile
src/bin/msgq/tests/Makefile
src/bin/auth/Makefile
src/bin/auth/tests/Makefile
src/bin/auth/tests/testdata/Makefile
src/bin/auth/benchmarks/Makefile
src/bin/xfrin/Makefile
src/bin/xfrin/tests/Makefile
......
SUBDIRS = testdata .
AM_CPPFLAGS = -I$(top_srcdir)/src/lib -I$(top_builddir)/src/lib
AM_CPPFLAGS += -I$(top_builddir)/src/lib/dns -I$(top_srcdir)/src/bin
AM_CPPFLAGS += -I$(top_builddir)/src/lib/cc
AM_CPPFLAGS += -DTEST_DATA_DIR=\"$(srcdir)/testdata\"
AM_CPPFLAGS += -DTEST_DATA_BUILDDIR=\"$(top_builddir)/src/bin/auth/tests/testdata\"
AM_CXXFLAGS = $(B10_CXXFLAGS)
......@@ -36,25 +39,3 @@ run_unittests_LDADD += $(top_builddir)/src/lib/xfr/libxfr.la
endif
noinst_PROGRAMS = $(TESTS)
EXTRA_DIST = testdata/badExampleQuery_fromWire
EXTRA_DIST += testdata/badExampleQuery_fromWire.spec
EXTRA_DIST += testdata/example.com
EXTRA_DIST += testdata/examplequery_fromWire
EXTRA_DIST += testdata/examplequery_fromWire.spec
EXTRA_DIST += testdata/example.sqlite3
EXTRA_DIST += testdata/iqueryresponse_fromWire
EXTRA_DIST += testdata/iqueryresponse_fromWire.spec
EXTRA_DIST += testdata/multiquestion_fromWire
EXTRA_DIST += testdata/multiquestion_fromWire.spec
EXTRA_DIST += testdata/queryBadEDNS_fromWire
EXTRA_DIST += testdata/queryBadEDNS_fromWire.spec
EXTRA_DIST += testdata/shortanswer_fromWire
EXTRA_DIST += testdata/shortanswer_fromWire.spec
EXTRA_DIST += testdata/shortmessage_fromWire
EXTRA_DIST += testdata/shortquestion_fromWire
EXTRA_DIST += testdata/shortresponse_fromWire
EXTRA_DIST += testdata/simplequery_fromWire
EXTRA_DIST += testdata/simplequery_fromWire.spec
EXTRA_DIST += testdata/simpleresponse_fromWire
EXTRA_DIST += testdata/simpleresponse_fromWire.spec
......@@ -341,7 +341,7 @@ TEST_F(AuthSrvTest, unsupportedRequest) {
i == Opcode::NOTIFY().getCode()) {
continue;
}
createDataFromFile("simplequery_fromWire");
createDataFromFile("simplequery_fromWire.wire");
data[2] = ((i << 3) & 0xff);
parse_message.clear(Message::PARSE);
......@@ -363,7 +363,7 @@ TEST_F(AuthSrvTest, verbose) {
// Multiple questions. Should result in FORMERR.
TEST_F(AuthSrvTest, multiQuestion) {
createDataFromFile("multiquestion_fromWire");
createDataFromFile("multiquestion_fromWire.wire");
EXPECT_EQ(true, server.processMessage(*io_message, parse_message,
response_renderer));
headerCheck(parse_message, default_qid, Rcode::FORMERR(), opcode.getCode(),
......@@ -393,7 +393,7 @@ TEST_F(AuthSrvTest, shortMessage) {
// or malformed or could otherwise cause a protocol error.
TEST_F(AuthSrvTest, response) {
// A valid (although unusual) response
createDataFromFile("simpleresponse_fromWire");
createDataFromFile("simpleresponse_fromWire.wire");
EXPECT_EQ(false, server.processMessage(*io_message, parse_message,
response_renderer));
......@@ -404,7 +404,7 @@ TEST_F(AuthSrvTest, response) {
response_renderer));
// A response to iquery. must be dropped rather than returning NOTIMP.
createDataFromFile("iqueryresponse_fromWire");
createDataFromFile("iqueryresponse_fromWire.wire");
EXPECT_EQ(false, server.processMessage(*io_message, parse_message,
response_renderer));
}
......@@ -422,7 +422,7 @@ TEST_F(AuthSrvTest, shortQuestion) {
// Query with a broken answer section
TEST_F(AuthSrvTest, shortAnswer) {
createDataFromFile("shortanswer_fromWire");
createDataFromFile("shortanswer_fromWire.wire");
EXPECT_EQ(true, server.processMessage(*io_message, parse_message,
response_renderer));
......@@ -441,7 +441,7 @@ TEST_F(AuthSrvTest, shortAnswer) {
// Query with unsupported version of EDNS.
TEST_F(AuthSrvTest, ednsBadVers) {
createDataFromFile("queryBadEDNS_fromWire");
createDataFromFile("queryBadEDNS_fromWire.wire");
EXPECT_EQ(true, server.processMessage(*io_message, parse_message,
response_renderer));
......@@ -722,7 +722,7 @@ TEST_F(AuthSrvTest, updateConfig) {
// query for existent data in the installed data source. The resulting
// response should have the AA flag on, and have an RR in each answer
// and authority section.
createDataFromFile("examplequery_fromWire");
createDataFromFile("examplequery_fromWire.wire");
EXPECT_EQ(true, server.processMessage(*io_message, parse_message,
response_renderer));
headerCheck(parse_message, default_qid, Rcode::NOERROR(), opcode.getCode(),
......@@ -736,7 +736,7 @@ TEST_F(AuthSrvTest, datasourceFail) {
// tool and the data source itself naively accept it). This will result
// in a SERVFAIL response, and the answer and authority sections should
// be empty.
createDataFromFile("badExampleQuery_fromWire");
createDataFromFile("badExampleQuery_fromWire.wire");
EXPECT_EQ(true, server.processMessage(*io_message, parse_message,
response_renderer));
headerCheck(parse_message, default_qid, Rcode::SERVFAIL(),
......@@ -751,7 +751,7 @@ TEST_F(AuthSrvTest, updateConfigFail) {
updateConfig(&server, BADCONFIG_TESTDB, false);
// The original data source should still exist.
createDataFromFile("examplequery_fromWire");
createDataFromFile("examplequery_fromWire.wire");
EXPECT_EQ(true, server.processMessage(*io_message, parse_message,
response_renderer));
headerCheck(parse_message, default_qid, Rcode::NOERROR(), opcode.getCode(),
......
......@@ -23,6 +23,7 @@ main(int argc, char* argv[])
{
::testing::InitGoogleTest(&argc, argv);
isc::UnitTestUtil::addDataPath(TEST_DATA_DIR);
isc::UnitTestUtil::addDataPath(TEST_DATA_BUILDDIR);
return (RUN_ALL_TESTS());
}
###
### This data file was auto-generated from badExampleQuery_fromWire.spec
###
# Header Section
# ID=4149 QR=Query Opcode=QUERY(0) Rcode=NOERROR(0)
1035 0000
# QDCNT=1, ANCNT=0, NSCNT=0, ARCNT=0
0001 0000 0000 0000
# Question Section
# QNAME=broken.example.com QTYPE=AAAA(28) QCLASS=IN(1)
0662726f6b656e076578616d706c6503636f6d00 001c 0001
###
### This data file was auto-generated from examplequery_fromWire.spec
###
# Header Section
# ID=4149 QR=Query Opcode=QUERY(0) Rcode=NOERROR(0)
1035 0000
# QDCNT=1, ANCNT=0, NSCNT=0, ARCNT=0
0001 0000 0000 0000
# Question Section
# QNAME=ns.example.com QTYPE=A(1) QCLASS=IN(1)
026e73076578616d706c6503636f6d00 0001 0001
###
### This data file was auto-generated from iqueryresponse_fromWire.spec
###
# Header Section
# ID=4149 QR=Response Opcode=IQUERY(1) Rcode=NOERROR(0)
1035 c000
# QDCNT=1, ANCNT=0, NSCNT=0, ARCNT=0
0001 0000 0000 0000
# Question Section
# QNAME=example.com. QTYPE=A(1) QCLASS=IN(1)
076578616d706c6503636f6d00 0001 0001
###
### This data file was auto-generated from multiquestion_fromWire.spec
###
# Header Section
# ID=4149 QR=Query Opcode=QUERY(0) Rcode=NOERROR(0)
1035 0000
# QDCNT=2, ANCNT=0, NSCNT=0, ARCNT=0
0002 0000 0000 0000
# Question Section
# QNAME=example.com. QTYPE=A(1) QCLASS=IN(1)
076578616d706c6503636f6d00 0001 0001
# Question Section
# QNAME=example.com. QTYPE=AAAA(28) QCLASS=IN(1)
076578616d706c6503636f6d00 001c 0001
###
### This data file was auto-generated from queryBadEDNS_fromWire.spec
###
# Header Section
# ID=4149 QR=Query Opcode=QUERY(0) Rcode=NOERROR(0)
1035 0000
# QDCNT=1, ANCNT=0, NSCNT=0, ARCNT=1
0001 0000 0000 0001
# Question Section
# QNAME=example.com. QTYPE=A(1) QCLASS=IN(1)
076578616d706c6503636f6d00 0001 0001
# EDNS OPT RR
# NAME=. TYPE=OPT(41) UDPSize=4096 ExtRcode=0 Version=1 DO=1
00 0029 1000 0001 8000
# RDLEN=0
0000
###
### This data file was auto-generated from shortanswer_fromWire.spec
###
# Header Section
# ID=4149 QR=Query Opcode=QUERY(0) Rcode=NOERROR(0)
1035 0000
# QDCNT=1, ANCNT=1, NSCNT=0, ARCNT=0
0001 0001 0000 0000
# Question Section
# QNAME=example.com. QTYPE=A(1) QCLASS=IN(1)
076578616d706c6503636f6d00 0001 0001
###
### This data file was auto-generated from simplequery_fromWire.spec
###
# Header Section
# ID=4149 QR=Query Opcode=QUERY(0) Rcode=NOERROR(0)
1035 0000
# QDCNT=1, ANCNT=0, NSCNT=0, ARCNT=0
0001 0000 0000 0000
# Question Section
# QNAME=example.com. QTYPE=A(1) QCLASS=IN(1)
076578616d706c6503636f6d00 0001 0001
###
### This data file was auto-generated from simpleresponse_fromWire.spec
###
# Header Section
# ID=4149 QR=Response Opcode=QUERY(0) Rcode=NOERROR(0)
1035 8000
# QDCNT=1, ANCNT=0, NSCNT=0, ARCNT=0
0001 0000 0000 0000
# Question Section
# QNAME=example.com. QTYPE=A(1) QCLASS=IN(1)
076578616d706c6503636f6d00 0001 0001
......@@ -10,6 +10,7 @@ PYTESTS += rrttl_python_test.py
PYTESTS += rrtype_python_test.py
EXTRA_DIST = $(PYTESTS)
EXTRA_DIST += testutil.py
# If necessary (rare cases), explicitly specify paths to dynamic libraries
# required by loadable python modules.
......
......@@ -335,7 +335,7 @@ class MessageTest(unittest.TestCase):
self.assertEqual(None, self.p.get_edns())
message_parse = Message(Message.PARSE)
factoryFromFile(message_parse, "message_fromWire10")
factoryFromFile(message_parse, "message_fromWire10.wire")
edns = message_parse.get_edns()
self.assertEqual(0, edns.get_version())
self.assertEqual(4096, edns.get_udp_size())
......@@ -473,12 +473,12 @@ test.example.com. 3600 IN A 192.0.2.2
def test_EDNS0ExtCode(self):
# Extended Rcode = BADVERS
message_parse = Message(Message.PARSE)
factoryFromFile(message_parse, "message_fromWire10")
factoryFromFile(message_parse, "message_fromWire10.wire")
self.assertEqual(Rcode.BADVERS(), message_parse.get_rcode())
# Maximum extended Rcode
message_parse.clear(Message.PARSE)
factoryFromFile(message_parse, "message_fromWire11")
factoryFromFile(message_parse, "message_fromWire11.wire")
self.assertEqual(0xfff, message_parse.get_rcode().get_code())
def test_BadEDNS0(self):
......
......@@ -53,101 +53,3 @@ run_unittests_LDADD += $(top_builddir)/src/lib/exceptions/libexceptions.la
endif
noinst_PROGRAMS = $(TESTS)
# NOTE: keep this in sync with real file listing
# so is included in tarball
EXTRA_DIST = testdata/gen-wiredata.py.in
EXTRA_DIST += testdata/edns_toWire1.spec testdata/edns_toWire2.spec
EXTRA_DIST += testdata/edns_toWire3.spec testdata/edns_toWire4.spec
EXTRA_DIST += testdata/message_fromWire1
EXTRA_DIST += testdata/message_fromWire10
EXTRA_DIST += testdata/message_fromWire10.spec
EXTRA_DIST += testdata/message_fromWire11
EXTRA_DIST += testdata/message_fromWire11.spec
EXTRA_DIST += testdata/message_fromWire2
EXTRA_DIST += testdata/message_fromWire3
EXTRA_DIST += testdata/message_fromWire4
EXTRA_DIST += testdata/message_fromWire5
EXTRA_DIST += testdata/message_fromWire6
EXTRA_DIST += testdata/message_fromWire7
EXTRA_DIST += testdata/message_fromWire8
EXTRA_DIST += testdata/message_fromWire9
EXTRA_DIST += testdata/message_toWire1
EXTRA_DIST += testdata/name_fromWire1
EXTRA_DIST += testdata/name_fromWire10
EXTRA_DIST += testdata/name_fromWire11
EXTRA_DIST += testdata/name_fromWire12
EXTRA_DIST += testdata/name_fromWire13
EXTRA_DIST += testdata/name_fromWire14
EXTRA_DIST += testdata/name_fromWire2
EXTRA_DIST += testdata/name_fromWire3_1
EXTRA_DIST += testdata/name_fromWire3_2
EXTRA_DIST += testdata/name_fromWire4
EXTRA_DIST += testdata/name_fromWire6
EXTRA_DIST += testdata/name_fromWire7
EXTRA_DIST += testdata/name_fromWire8
EXTRA_DIST += testdata/name_fromWire9
EXTRA_DIST += testdata/name_toWire1
EXTRA_DIST += testdata/name_toWire2
EXTRA_DIST += testdata/name_toWire3
EXTRA_DIST += testdata/name_toWire4
EXTRA_DIST += testdata/name_toWire5
EXTRA_DIST += testdata/name_toWire5.spec
EXTRA_DIST += testdata/name_toWire6
EXTRA_DIST += testdata/name_toWire6.spec
EXTRA_DIST += testdata/question_fromWire
EXTRA_DIST += testdata/question_toWire1
EXTRA_DIST += testdata/question_toWire2
EXTRA_DIST += testdata/rdata_cname_fromWire
EXTRA_DIST += testdata/rdata_dname_fromWire
EXTRA_DIST += testdata/rdata_dnskey_fromWire
EXTRA_DIST += testdata/rdata_ds_fromWire
EXTRA_DIST += testdata/rdata_in_a_fromWire
EXTRA_DIST += testdata/rdata_in_aaaa_fromWire
EXTRA_DIST += testdata/rdata_mx_fromWire
EXTRA_DIST += testdata/rdata_mx_toWire1
EXTRA_DIST += testdata/rdata_ns_fromWire
EXTRA_DIST += testdata/rdata_nsec3_fromWire1
EXTRA_DIST += testdata/rdata_nsec3_fromWire2
EXTRA_DIST += testdata/rdata_nsec3_fromWire3
EXTRA_DIST += testdata/rdata_nsec3param_fromWire1
EXTRA_DIST += testdata/rdata_nsec_fromWire1
EXTRA_DIST += testdata/rdata_nsec_fromWire10
EXTRA_DIST += testdata/rdata_nsec_fromWire10.spec
EXTRA_DIST += testdata/rdata_nsec_fromWire2
EXTRA_DIST += testdata/rdata_nsec_fromWire3
EXTRA_DIST += testdata/rdata_nsec_fromWire4
EXTRA_DIST += testdata/rdata_nsec_fromWire4.spec
EXTRA_DIST += testdata/rdata_nsec_fromWire5
EXTRA_DIST += testdata/rdata_nsec_fromWire5.spec
EXTRA_DIST += testdata/rdata_nsec_fromWire6
EXTRA_DIST += testdata/rdata_nsec_fromWire6.spec
EXTRA_DIST += testdata/rdata_nsec_fromWire7
EXTRA_DIST += testdata/rdata_nsec_fromWire7.spec
EXTRA_DIST += testdata/rdata_nsec_fromWire8
EXTRA_DIST += testdata/rdata_nsec_fromWire8.spec
EXTRA_DIST += testdata/rdata_nsec_fromWire9
EXTRA_DIST += testdata/rdata_nsec_fromWire9.spec
EXTRA_DIST += testdata/rdata_opt_fromWire
EXTRA_DIST += testdata/rdata_rrsig_fromWire1
EXTRA_DIST += testdata/rdata_rrsig_fromWire2
EXTRA_DIST += testdata/rdata_rrsig_fromWire2.spec
EXTRA_DIST += testdata/rdata_soa_fromWire
EXTRA_DIST += testdata/rdata_soa_toWireUncompressed
EXTRA_DIST += testdata/rdata_soa_toWireUncompressed.spec
EXTRA_DIST += testdata/rdata_txt_fromWire1
EXTRA_DIST += testdata/rdata_txt_fromWire2
EXTRA_DIST += testdata/rdata_txt_fromWire2.spec
EXTRA_DIST += testdata/rdata_txt_fromWire3
EXTRA_DIST += testdata/rdata_txt_fromWire3.spec
EXTRA_DIST += testdata/rdata_txt_fromWire4
EXTRA_DIST += testdata/rdata_txt_fromWire4.spec
EXTRA_DIST += testdata/rdata_txt_fromWire5
EXTRA_DIST += testdata/rdata_txt_fromWire5.spec
EXTRA_DIST += testdata/rdata_unknown_fromWire
EXTRA_DIST += testdata/rrcode16_fromWire1
EXTRA_DIST += testdata/rrcode16_fromWire2
EXTRA_DIST += testdata/rrcode32_fromWire1
EXTRA_DIST += testdata/rrcode32_fromWire2
EXTRA_DIST += testdata/rrset_toWire1
EXTRA_DIST += testdata/rrset_toWire2
......@@ -97,7 +97,7 @@ TEST_F(MessageTest, RcodeToText) {
TEST_F(MessageTest, getEDNS) {
EXPECT_FALSE(message_parse.getEDNS()); // by default EDNS isn't set
factoryFromFile(message_parse, "message_fromWire10");
factoryFromFile(message_parse, "message_fromWire10.wire");
EXPECT_TRUE(message_parse.getEDNS());
EXPECT_EQ(0, message_parse.getEDNS()->getVersion());
EXPECT_EQ(4096, message_parse.getEDNS()->getUDPSize());
......@@ -149,12 +149,12 @@ TEST_F(MessageTest, fromWire) {
TEST_F(MessageTest, EDNS0ExtRcode) {
// Extended Rcode = BADVERS
factoryFromFile(message_parse, "message_fromWire10");
factoryFromFile(message_parse, "message_fromWire10.wire");
EXPECT_EQ(Rcode::BADVERS(), message_parse.getRcode());
// Maximum extended Rcode
message_parse.clear(Message::PARSE);
factoryFromFile(message_parse, "message_fromWire11");
factoryFromFile(message_parse, "message_fromWire11.wire");
EXPECT_EQ(0xfff, message_parse.getRcode().getCode());
}
......
......@@ -130,7 +130,7 @@ TEST_F(MessageRendererTest, writeNameCaseSensitiveCompress) {
// name compression in case sensitive manner. See the data file
// description for details.
renderer.setCompressMode(MessageRenderer::CASE_SENSITIVE);
UnitTestUtil::readWireData("name_toWire5", data);
UnitTestUtil::readWireData("name_toWire5.wire", data);
renderer.writeName(Name("a.example.com."));
renderer.writeName(Name("b.eXample.com."));
renderer.writeName(Name("c.eXample.com."));
......@@ -140,7 +140,7 @@ TEST_F(MessageRendererTest, writeNameCaseSensitiveCompress) {
TEST_F(MessageRendererTest, writeNameMixedCaseCompress) {
renderer.setCompressMode(MessageRenderer::CASE_SENSITIVE);
UnitTestUtil::readWireData("name_toWire6", data);
UnitTestUtil::readWireData("name_toWire6.wire", data);
renderer.writeName(Name("a.example.com."));
renderer.writeName(Name("b.eXample.com."));
......
......@@ -70,39 +70,39 @@ TEST_F(Rdata_NSEC_Test, createFromWire_NSEC) {
// A malformed NSEC bitmap length field that could cause overflow.
EXPECT_THROW(rdataFactoryFromFile(RRType::NSEC(), RRClass::IN(),
"rdata_nsec_fromWire4"),
"rdata_nsec_fromWire4.wire"),
DNSMessageFORMERR);
// The bitmap field is incomplete (only the first byte is included)
EXPECT_THROW(rdataFactoryFromFile(RRType::NSEC(), RRClass::IN(),
"rdata_nsec_fromWire5"),
"rdata_nsec_fromWire5.wire"),
DNSMessageFORMERR);
// Bitmap length is 0, which is invalid.
EXPECT_THROW(rdataFactoryFromFile(RRType::NSEC(), RRClass::IN(),
"rdata_nsec_fromWire6"),
"rdata_nsec_fromWire6.wire"),
DNSMessageFORMERR);
// A boundary case: longest possible bitmaps (32 maps). This should be
// accepted.
EXPECT_NO_THROW(rdataFactoryFromFile(RRType::NSEC(), RRClass::IN(),
"rdata_nsec_fromWire7"));
"rdata_nsec_fromWire7.wire"));
// Another boundary condition: 33 bitmaps, which should be rejected.
EXPECT_THROW(rdataFactoryFromFile(RRType::NSEC(), RRClass::IN(),
"rdata_nsec_fromWire8"),
"rdata_nsec_fromWire8.wire"),
DNSMessageFORMERR);
// Disordered bitmap window blocks.
EXPECT_THROW(rdataFactoryFromFile(RRType::NSEC(), RRClass::IN(),
"rdata_nsec_fromWire9"),
"rdata_nsec_fromWire9.wire"),
DNSMessageFORMERR);
// Bitmap ending with all-zero bytes. Not necessarily harmful except
// the additional overhead of parsing, but invalid according to the
// spec anyway.
EXPECT_THROW(rdataFactoryFromFile(RRType::NSEC(), RRClass::IN(),
"rdata_nsec_fromWire10"),
"rdata_nsec_fromWire10.wire"),
DNSMessageFORMERR);
}
......
......@@ -131,7 +131,7 @@ TEST_F(Rdata_RRSIG_Test, createFromWire) {
// RDLEN is too short
EXPECT_THROW(rdataFactoryFromFile(RRType::RRSIG(), RRClass::IN(),
"rdata_rrsig_fromWire2"),
"rdata_rrsig_fromWire2.wire"),
InvalidRdataLength);
}
}
......@@ -65,7 +65,7 @@ TEST_F(Rdata_SOA_Test, toWireBuffer) {
obuffer.skip(2);
rdata_soa.toWire(obuffer);
vector<unsigned char> data;
UnitTestUtil::readWireData("rdata_soa_toWireUncompressed", data);
UnitTestUtil::readWireData("rdata_soa_toWireUncompressed.wire", data);
EXPECT_PRED_FORMAT4(UnitTestUtil::matchWireData,
static_cast<const uint8_t *>(obuffer.getData()) + 2,
obuffer.getLength() - 2, &data[2], data.size() - 2);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment