Commit 4822e033 authored by JINMEI Tatuya's avatar JINMEI Tatuya
Browse files

made test data paths dynamically configurable with the default path of...

made test data paths dynamically configurable with the default path of @srcdir@/testdata.  This will allow testdata to be referred to from a non-src build directory.

We can also specify mulitiple directories, which may happen if we generate some data files from spec at build time and run tests under a non-src directory.


git-svn-id: svn://bind10.isc.org/svn/bind10/trunk@1709 e5f2f494-b856-4b98-b285-d166d9295462
parent 3e235c59
AM_CPPFLAGS = -I$(top_builddir)/src/lib -I$(top_srcdir)/src/lib
AM_CPPFLAGS += -I$(top_srcdir)/src/lib/dns -I$(top_builddir)/src/lib/dns
AM_CPPFLAGS += -DTEST_DATA_DIR=\"$(srcdir)/testdata\"
CLEANFILES = *.gcno *.gcda
......
......@@ -95,7 +95,7 @@ TEST_F(MessageTest, RcodeToText) {
TEST_F(MessageTest, fromWire) {
factoryFromFile(message_parse, "testdata/message_fromWire1");
factoryFromFile(message_parse, "message_fromWire1");
EXPECT_EQ(0x1035, message_parse.getQid());
EXPECT_EQ(Opcode::QUERY(), message_parse.getOpcode());
EXPECT_EQ(Rcode::NOERROR(), message_parse.getRcode());
......@@ -129,17 +129,17 @@ TEST_F(MessageTest, fromWire) {
TEST_F(MessageTest, GetEDNS0DOBit) {
// Without EDNS0, DNSSEC is considered to be unsupported.
factoryFromFile(message_parse, "testdata/message_fromWire1");
factoryFromFile(message_parse, "message_fromWire1");
EXPECT_FALSE(message_parse.isDNSSECSupported());
// If DO bit is on, DNSSEC is considered to be supported.
message_parse.clear(Message::PARSE);
factoryFromFile(message_parse, "testdata/message_fromWire2");
factoryFromFile(message_parse, "message_fromWire2");
EXPECT_TRUE(message_parse.isDNSSECSupported());
// If DO bit is off, DNSSEC is considered to be unsupported.
message_parse.clear(Message::PARSE);
factoryFromFile(message_parse, "testdata/message_fromWire3");
factoryFromFile(message_parse, "message_fromWire3");
EXPECT_FALSE(message_parse.isDNSSECSupported());
}
......@@ -165,17 +165,17 @@ TEST_F(MessageTest, SetEDNS0DOBit) {
TEST_F(MessageTest, GetEDNS0UDPSize) {
// Without EDNS0, the default max UDP size is used.
factoryFromFile(message_parse, "testdata/message_fromWire1");
factoryFromFile(message_parse, "message_fromWire1");
EXPECT_EQ(Message::DEFAULT_MAX_UDPSIZE, message_parse.getUDPSize());
// If the size specified in EDNS0 > default max, use it.
message_parse.clear(Message::PARSE);
factoryFromFile(message_parse, "testdata/message_fromWire2");
factoryFromFile(message_parse, "message_fromWire2");
EXPECT_EQ(4096, message_parse.getUDPSize());
// If the size specified in EDNS0 < default max, keep using the default.
message_parse.clear(Message::PARSE);
factoryFromFile(message_parse, "testdata/message_fromWire8");
factoryFromFile(message_parse, "message_fromWire8");
EXPECT_EQ(Message::DEFAULT_MAX_UDPSIZE, message_parse.getUDPSize());
}
......@@ -204,36 +204,35 @@ TEST_F(MessageTest, SetEDNS0UDPSize) {
TEST_F(MessageTest, EDNS0ExtCode) {
// Extended Rcode = BADVERS
factoryFromFile(message_parse, "testdata/message_fromWire10");
factoryFromFile(message_parse, "message_fromWire10");
EXPECT_EQ(Rcode::BADVERS(), message_parse.getRcode());
// Maximum extended Rcode
message_parse.clear(Message::PARSE);
factoryFromFile(message_parse, "testdata/message_fromWire11");
factoryFromFile(message_parse, "message_fromWire11");
EXPECT_EQ(0xfff, message_parse.getRcode().getCode());
}
TEST_F(MessageTest, BadEDNS0) {
// OPT RR in the answer section
EXPECT_THROW(factoryFromFile(message_parse, "testdata/message_fromWire4"),
EXPECT_THROW(factoryFromFile(message_parse, "message_fromWire4"),
DNSMessageFORMERR);
// multiple OPT RRs (in the additional section)
message_parse.clear(Message::PARSE);
EXPECT_THROW(factoryFromFile(message_parse, "testdata/message_fromWire5"),
EXPECT_THROW(factoryFromFile(message_parse, "message_fromWire5"),
DNSMessageFORMERR);
// OPT RR of a non root name
message_parse.clear(Message::PARSE);
EXPECT_THROW(factoryFromFile(message_parse, "testdata/message_fromWire6"),
EXPECT_THROW(factoryFromFile(message_parse, "message_fromWire6"),
DNSMessageFORMERR);
// Compressed owner name of OPT RR points to a root name.
// Not necessarily bogus, but very unusual and mostly pathological.
// We accept it, but is it okay?
message_parse.clear(Message::PARSE);
EXPECT_NO_THROW(factoryFromFile(message_parse,
"testdata/message_fromWire7"));
EXPECT_NO_THROW(factoryFromFile(message_parse, "message_fromWire7"));
// Unsupported Version
message_parse.clear(Message::PARSE);
EXPECT_THROW(factoryFromFile(message_parse, "testdata/message_fromWire9"),
EXPECT_THROW(factoryFromFile(message_parse, "message_fromWire9"),
DNSMessageBADVERS);
}
......@@ -259,7 +258,7 @@ TEST_F(MessageTest, toWire) {
message_render.toWire(renderer);
vector<unsigned char> data;
UnitTestUtil::readWireData("testdata/message_toWire1", data);
UnitTestUtil::readWireData("message_toWire1", data);
EXPECT_PRED_FORMAT4(UnitTestUtil::matchWireData, obuffer.getData(),
obuffer.getLength(), &data[0], data.size());
}
......
......@@ -58,7 +58,7 @@ TEST_F(MessageRendererTest, writeIntger) {
}
TEST_F(MessageRendererTest, writeName) {
UnitTestUtil::readWireData("testdata/name_toWire1", data);
UnitTestUtil::readWireData("name_toWire1", data);
renderer.writeName(Name("a.example.com."));
renderer.writeName(Name("b.example.com."));
renderer.writeName(Name("a.example.org."));
......@@ -70,7 +70,7 @@ TEST_F(MessageRendererTest, writeNameInLargeBuffer) {
size_t offset = 0x3fff;
buffer.skip(offset);
UnitTestUtil::readWireData("testdata/name_toWire2", data);
UnitTestUtil::readWireData("name_toWire2", data);
renderer.writeName(Name("a.example.com."));
renderer.writeName(Name("a.example.com."));
renderer.writeName(Name("b.example.com."));
......@@ -81,7 +81,7 @@ TEST_F(MessageRendererTest, writeNameInLargeBuffer) {
}
TEST_F(MessageRendererTest, writeNameWithUncompressed) {
UnitTestUtil::readWireData("testdata/name_toWire3", data);
UnitTestUtil::readWireData("name_toWire3", data);
renderer.writeName(Name("a.example.com."));
renderer.writeName(Name("b.example.com."), false);
renderer.writeName(Name("b.example.com."));
......@@ -90,7 +90,7 @@ TEST_F(MessageRendererTest, writeNameWithUncompressed) {
}
TEST_F(MessageRendererTest, writeNamePointerChain) {
UnitTestUtil::readWireData("testdata/name_toWire4", data);
UnitTestUtil::readWireData("name_toWire4", data);
renderer.writeName(Name("a.example.com."));
renderer.writeName(Name("b.example.com."));
renderer.writeName(Name("b.example.com."));
......@@ -117,7 +117,7 @@ TEST_F(MessageRendererTest, compressMode) {
TEST_F(MessageRendererTest, writeNameCaseCompress) {
// By default MessageRenderer performs case insensitive compression.
UnitTestUtil::readWireData("testdata/name_toWire1", data);
UnitTestUtil::readWireData("name_toWire1", data);
renderer.writeName(Name("a.example.com."));
// this should match the first name in terms of compression:
renderer.writeName(Name("b.exAmple.CoM."));
......@@ -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("testdata/name_toWire5", data);
UnitTestUtil::readWireData("name_toWire5", 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("testdata/name_toWire6", data);
UnitTestUtil::readWireData("name_toWire6", data);
renderer.writeName(Name("a.example.com."));
renderer.writeName(Name("b.eXample.com."));
......
......@@ -222,33 +222,29 @@ TEST_F(NameTest, fromWire)
//
// normal case with a compression pointer
EXPECT_PRED_FORMAT2(UnitTestUtil::matchName,
nameFactoryFromWire("testdata/name_fromWire1", 25),
nameFactoryFromWire("name_fromWire1", 25),
Name("vix.com"));
// bogus label character (looks like a local compression pointer)
EXPECT_THROW(nameFactoryFromWire("testdata/name_fromWire2", 25),
DNSMessageFORMERR);
EXPECT_THROW(nameFactoryFromWire("name_fromWire2", 25), DNSMessageFORMERR);
// a bad compression pointer (too big)
EXPECT_THROW(nameFactoryFromWire("testdata/name_fromWire3_1", 25),
EXPECT_THROW(nameFactoryFromWire("name_fromWire3_1", 25),
DNSMessageFORMERR);
// forward reference
EXPECT_THROW(nameFactoryFromWire("testdata/name_fromWire3_2", 25),
EXPECT_THROW(nameFactoryFromWire("name_fromWire3_2", 25),
DNSMessageFORMERR);
// invalid name length
EXPECT_THROW(nameFactoryFromWire("testdata/name_fromWire4", 550),
DNSMessageFORMERR);
EXPECT_THROW(nameFactoryFromWire("name_fromWire4", 550), DNSMessageFORMERR);
// skip test for from Wire5. It's for disabling decompression, but our
// implementation always allows it.
// bad pointer (too big)
EXPECT_THROW(nameFactoryFromWire("testdata/name_fromWire6", 25),
DNSMessageFORMERR);
EXPECT_THROW(nameFactoryFromWire("name_fromWire6", 25), DNSMessageFORMERR);
// input ends unexpectedly
EXPECT_THROW(nameFactoryFromWire("testdata/name_fromWire7", 25),
DNSMessageFORMERR);
EXPECT_THROW(nameFactoryFromWire("name_fromWire7", 25), DNSMessageFORMERR);
// many hops of compression but valid. should succeed.
EXPECT_PRED_FORMAT2(UnitTestUtil::matchName,
nameFactoryFromWire("testdata/name_fromWire8", 383),
nameFactoryFromWire("name_fromWire8", 383),
Name("vix.com"));
//
......@@ -257,25 +253,21 @@ TEST_F(NameTest, fromWire)
// large names, a long but valid one, and invalid (too long) one.
EXPECT_EQ(Name::MAX_WIRE,
nameFactoryFromWire("testdata/name_fromWire9", 0).getLength());
EXPECT_THROW(nameFactoryFromWire("testdata/name_fromWire10", 0).getLength(),
nameFactoryFromWire("name_fromWire9", 0).getLength());
EXPECT_THROW(nameFactoryFromWire("name_fromWire10", 0).getLength(),
DNSMessageFORMERR);
// A name with possible maximum number of labels; awkward but valid
EXPECT_EQ(nameFactoryFromWire("testdata/name_fromWire11",
0).getLabelCount(),
EXPECT_EQ(nameFactoryFromWire("name_fromWire11", 0).getLabelCount(),
Name::MAX_LABELS);
// Wire format including an invalid label length
EXPECT_THROW(nameFactoryFromWire("testdata/name_fromWire12", 0),
DNSMessageFORMERR);
EXPECT_THROW(nameFactoryFromWire("name_fromWire12", 0), DNSMessageFORMERR);
// converting upper-case letters to down-case
EXPECT_EQ("vix.com.", nameFactoryFromWire("testdata/name_fromWire1",
25, true).toText());
EXPECT_EQ(3,
nameFactoryFromWire("testdata/name_fromWire1",
25).getLabelCount());
EXPECT_EQ("vix.com.",
nameFactoryFromWire("name_fromWire1", 25, true).toText());
EXPECT_EQ(3, nameFactoryFromWire("name_fromWire1", 25).getLabelCount());
}
TEST_F(NameTest, copyConstruct)
......@@ -331,7 +323,7 @@ TEST_F(NameTest, toText)
"ABCDEFGHIJKLMNOPQRSTUVWXYZ"
"[\\\\]^_.`abcdefghijklmnopqrstuvwxyz{|}~.");
EXPECT_EQ(all_printable,
nameFactoryFromWire("testdata/name_fromWire13", 0).toText());
nameFactoryFromWire("name_fromWire13", 0).toText());
string all_nonprintable(
"\\000\\001\\002\\003\\004\\005\\006\\007\\008\\009"
......@@ -353,7 +345,7 @@ TEST_F(NameTest, toText)
"\\240\\241\\242\\243\\244\\245\\246\\247\\248\\249"
"\\250\\251\\252\\253\\254\\255.");
EXPECT_EQ(all_nonprintable,
nameFactoryFromWire("testdata/name_fromWire14", 0).toText());
nameFactoryFromWire("name_fromWire14", 0).toText());
}
TEST_F(NameTest, toWireBuffer)
......
......@@ -69,7 +69,7 @@ questionFromWire(const char* datafile, size_t position = 0)
TEST_F(QuestionTest, fromWire)
{
Question q = questionFromWire("testdata/question_fromWire");
Question q = questionFromWire("question_fromWire");
EXPECT_EQ(example_name1, q.getName());
EXPECT_EQ(RRClass::IN(), q.getClass());
......@@ -77,17 +77,15 @@ TEST_F(QuestionTest, fromWire)
// owner name of the second Question is compressed. It's uncommon
// (to have multiple questions), but isn't prohibited by the protocol.
q = questionFromWire("testdata/question_fromWire", 21);
q = questionFromWire("question_fromWire", 21);
EXPECT_EQ(example_name2, q.getName());
EXPECT_EQ(RRClass::CH(), q.getClass());
EXPECT_EQ(RRType::A(), q.getType());
// Pathological cases: Corresponding exceptions will be thrown from
// the underlying parser.
EXPECT_THROW(questionFromWire("testdata/question_fromWire", 31),
DNSMessageFORMERR);
EXPECT_THROW(questionFromWire("testdata/question_fromWire", 36),
IncompleteRRClass);
EXPECT_THROW(questionFromWire("question_fromWire", 31), DNSMessageFORMERR);
EXPECT_THROW(questionFromWire("question_fromWire", 36), IncompleteRRClass);
}
TEST_F(QuestionTest, toText)
......@@ -100,7 +98,7 @@ TEST_F(QuestionTest, toWireBuffer)
{
test_question1.toWire(obuffer);
test_question2.toWire(obuffer);
UnitTestUtil::readWireData("testdata/question_toWire1", wiredata);
UnitTestUtil::readWireData("question_toWire1", wiredata);
EXPECT_PRED_FORMAT4(UnitTestUtil::matchWireData, obuffer.getData(),
obuffer.getLength(), &wiredata[0], wiredata.size());
}
......@@ -109,7 +107,7 @@ TEST_F(QuestionTest, toWireRenderer)
{
test_question1.toWire(renderer);
test_question2.toWire(renderer);
UnitTestUtil::readWireData("testdata/question_toWire2", wiredata);
UnitTestUtil::readWireData("question_toWire2", wiredata);
EXPECT_PRED_FORMAT4(UnitTestUtil::matchWireData, obuffer.getData(),
obuffer.getLength(), &wiredata[0], wiredata.size());
}
......
......@@ -68,25 +68,25 @@ TEST_F(Rdata_CNAME_Test, createFromWire)
{
EXPECT_EQ(0, rdata_cname.compare(
*rdataFactoryFromFile(RRType("CNAME"), RRClass("IN"),
"testdata/rdata_cname_fromWire")));
"rdata_cname_fromWire")));
// RDLENGTH is too short
EXPECT_THROW(rdataFactoryFromFile(RRType("CNAME"), RRClass("IN"),
"testdata/rdata_cname_fromWire", 18),
"rdata_cname_fromWire", 18),
InvalidRdataLength);
// RDLENGTH is too long
EXPECT_THROW(rdataFactoryFromFile(RRType("CNAME"), RRClass("IN"),
"testdata/rdata_cname_fromWire", 36),
"rdata_cname_fromWire", 36),
InvalidRdataLength);
// incomplete name. the error should be detected in the name constructor
EXPECT_THROW(rdataFactoryFromFile(RRType("CNAME"), RRClass("IN"),
"testdata/rdata_cname_fromWire", 71),
"rdata_cname_fromWire", 71),
DNSMessageFORMERR);
EXPECT_EQ(0, generic::CNAME("cn2.example.com").compare(
*rdataFactoryFromFile(RRType("CNAME"), RRClass("IN"),
"testdata/rdata_cname_fromWire", 55)));
"rdata_cname_fromWire", 55)));
EXPECT_THROW(*rdataFactoryFromFile(RRType("CNAME"), RRClass("IN"),
"testdata/rdata_cname_fromWire", 63),
"rdata_cname_fromWire", 63),
InvalidRdataLength);
}
......
......@@ -68,25 +68,25 @@ TEST_F(Rdata_DNAME_Test, createFromWire)
{
EXPECT_EQ(0, rdata_dname.compare(
*rdataFactoryFromFile(RRType("DNAME"), RRClass("IN"),
"testdata/rdata_dname_fromWire")));
"rdata_dname_fromWire")));
// RDLENGTH is too short
EXPECT_THROW(rdataFactoryFromFile(RRType("DNAME"), RRClass("IN"),
"testdata/rdata_dname_fromWire", 18),
"rdata_dname_fromWire", 18),
InvalidRdataLength);
// RDLENGTH is too long
EXPECT_THROW(rdataFactoryFromFile(RRType("DNAME"), RRClass("IN"),
"testdata/rdata_dname_fromWire", 36),
"rdata_dname_fromWire", 36),
InvalidRdataLength);
// incomplete name. the error should be detected in the name constructor
EXPECT_THROW(rdataFactoryFromFile(RRType("DNAME"), RRClass("IN"),
"testdata/rdata_dname_fromWire", 71),
"rdata_dname_fromWire", 71),
DNSMessageFORMERR);
EXPECT_EQ(0, generic::DNAME("dn2.example.com").compare(
*rdataFactoryFromFile(RRType("DNAME"), RRClass("IN"),
"testdata/rdata_dname_fromWire", 55)));
"rdata_dname_fromWire", 55)));
EXPECT_THROW(*rdataFactoryFromFile(RRType("DNAME"), RRClass("IN"),
"testdata/rdata_dname_fromWire", 63),
"rdata_dname_fromWire", 63),
InvalidRdataLength);
}
......
......@@ -91,7 +91,7 @@ TEST_F(Rdata_DNSKEY_Test, toWireRenderer)
rdata_dnskey.toWire(renderer);
vector<unsigned char> data;
UnitTestUtil::readWireData("testdata/rdata_dnskey_fromWire", data);
UnitTestUtil::readWireData("rdata_dnskey_fromWire", data);
EXPECT_PRED_FORMAT4(UnitTestUtil::matchWireData,
static_cast<const uint8_t *>(obuffer.getData()) + 2,
obuffer.getLength() - 2, &data[2], data.size() - 2);
......@@ -108,7 +108,7 @@ TEST_F(Rdata_DNSKEY_Test, createFromWire)
generic::DNSKEY rdata_dnskey(dnskey_txt);
EXPECT_EQ(0, rdata_dnskey.compare(
*rdataFactoryFromFile(RRType("DNSKEY"), RRClass("IN"),
"testdata/rdata_dnskey_fromWire")));
"rdata_dnskey_fromWire")));
}
TEST_F(Rdata_DNSKEY_Test, getTag)
......
......@@ -64,7 +64,7 @@ TEST_F(Rdata_DS_Test, badText_DS) {
TEST_F(Rdata_DS_Test, createFromWire_DS) {
EXPECT_EQ(0, rdata_ds.compare(
*rdataFactoryFromFile(RRType::DS(), RRClass::IN(),
"testdata/rdata_ds_fromWire")));
"rdata_ds_fromWire")));
}
TEST_F(Rdata_DS_Test, getTag_DS) {
......@@ -77,7 +77,7 @@ TEST_F(Rdata_DS_Test, toWireRenderer) {
rdata_ds.toWire(renderer);
vector<unsigned char> data;
UnitTestUtil::readWireData("testdata/rdata_ds_fromWire", data);
UnitTestUtil::readWireData("rdata_ds_fromWire", data);
EXPECT_PRED_FORMAT4(UnitTestUtil::matchWireData,
static_cast<const uint8_t *>(obuffer.getData()) + 2,
obuffer.getLength() - 2, &data[2], data.size() - 2);
......
......@@ -54,18 +54,18 @@ TEST_F(Rdata_IN_A_Test, createFromWire) {
// Valid data
EXPECT_EQ(0, rdata_in_a.compare(
*rdataFactoryFromFile(RRType::A(), RRClass::IN(),
"testdata/rdata_in_a_fromWire")));
"rdata_in_a_fromWire")));
// RDLENGTH is too short
EXPECT_THROW(rdataFactoryFromFile(RRType::A(), RRClass::IN(),
"testdata/rdata_in_a_fromWire", 6),
"rdata_in_a_fromWire", 6),
DNSMessageFORMERR);
// RDLENGTH is too long
EXPECT_THROW(rdataFactoryFromFile(RRType::A(), RRClass::IN(),
"testdata/rdata_in_a_fromWire", 12),
"rdata_in_a_fromWire", 12),
DNSMessageFORMERR);
// buffer too short.
EXPECT_THROW(rdataFactoryFromFile(RRType::A(), RRClass::IN(),
"testdata/rdata_in_a_fromWire", 19),
"rdata_in_a_fromWire", 19),
DNSMessageFORMERR);
}
......
......@@ -52,18 +52,18 @@ TEST_F(Rdata_IN_AAAA_Test, createFromWire) {
// Valid data
EXPECT_EQ(0, rdata_in_aaaa.compare(
*rdataFactoryFromFile(RRType::AAAA(), RRClass::IN(),
"testdata/rdata_in_aaaa_fromWire")));
"rdata_in_aaaa_fromWire")));
// RDLENGTH is too short
EXPECT_THROW(rdataFactoryFromFile(RRType::AAAA(), RRClass::IN(),
"testdata/rdata_in_aaaa_fromWire", 18),
"rdata_in_aaaa_fromWire", 18),
DNSMessageFORMERR);
// RDLENGTH is too long
EXPECT_THROW(rdataFactoryFromFile(RRType::AAAA(), RRClass::IN(),
"testdata/rdata_in_aaaa_fromWire", 36),
"rdata_in_aaaa_fromWire", 36),
DNSMessageFORMERR);
// buffer too short.
EXPECT_THROW(rdataFactoryFromFile(RRType::AAAA(), RRClass::IN(),
"testdata/rdata_in_aaaa_fromWire", 55),
"rdata_in_aaaa_fromWire", 55),
DNSMessageFORMERR);
}
......
......@@ -63,7 +63,7 @@ TEST_F(Rdata_MX_Test, createFromWire)
{
EXPECT_EQ(0, rdata_mx.compare(
*rdataFactoryFromFile(RRType("MX"), RRClass("IN"),
"testdata/rdata_mx_fromWire")));
"rdata_mx_fromWire")));
// TBD: more tests
}
......@@ -73,7 +73,7 @@ TEST_F(Rdata_MX_Test, toWireRenderer)
rdata_mx.toWire(renderer);
vector<unsigned char> data;
UnitTestUtil::readWireData("testdata/rdata_mx_toWire1", data);
UnitTestUtil::readWireData("rdata_mx_toWire1", data);
EXPECT_PRED_FORMAT4(UnitTestUtil::matchWireData, obuffer.getData(),
obuffer.getLength(), &data[0], data.size());
}
......@@ -86,7 +86,7 @@ TEST_F(Rdata_MX_Test, toWireBuffer)
#if 0
// XXX: does not pass
vector<unsigned char> data;
UnitTestUtil::readWireData("testdata/rdata_mx_toWire1", data);
UnitTestUtil::readWireData("rdata_mx_toWire1", data);
EXPECT_PRED_FORMAT4(UnitTestUtil::matchWireData, obuffer.getData(),
obuffer.getLength(), &data[0], data.size());
#endif
......
......@@ -67,25 +67,25 @@ TEST_F(Rdata_NS_Test, createFromWire)
{
EXPECT_EQ(0, rdata_ns.compare(
*rdataFactoryFromFile(RRType("NS"), RRClass("IN"),
"testdata/rdata_ns_fromWire")));
"rdata_ns_fromWire")));
// RDLENGTH is too short
EXPECT_THROW(rdataFactoryFromFile(RRType("NS"), RRClass("IN"),
"testdata/rdata_ns_fromWire", 18),
"rdata_ns_fromWire", 18),
InvalidRdataLength);
// RDLENGTH is too long
EXPECT_THROW(rdataFactoryFromFile(RRType("NS"), RRClass("IN"),
"testdata/rdata_ns_fromWire", 36),
"rdata_ns_fromWire", 36),
InvalidRdataLength);
// incomplete name. the error should be detected in the name constructor
EXPECT_THROW(rdataFactoryFromFile(RRType("NS"), RRClass("IN"),
"testdata/rdata_ns_fromWire", 71),
"rdata_ns_fromWire", 71),
DNSMessageFORMERR);
EXPECT_EQ(0, generic::NS("ns2.example.com").compare(
*rdataFactoryFromFile(RRType("NS"), RRClass("IN"),
"testdata/rdata_ns_fromWire", 55)));
"rdata_ns_fromWire", 55)));
EXPECT_THROW(*rdataFactoryFromFile(RRType("NS"), RRClass("IN"),
"testdata/rdata_ns_fromWire", 63),
"rdata_ns_fromWire", 63),
InvalidRdataLength);
}
......
......@@ -85,16 +85,16 @@ TEST_F(Rdata_NSEC3_Test, createFromWire)
const generic::NSEC3 rdata_nsec3(nsec3_txt);
EXPECT_EQ(0, rdata_nsec3.compare(
*rdataFactoryFromFile(RRType::NSEC3(), RRClass::IN(),
"testdata/rdata_nsec3_fromWire1")));
"rdata_nsec3_fromWire1")));
// Too short RDLENGTH
EXPECT_THROW(rdataFactoryFromFile(RRType::NSEC3(), RRClass::IN(),
"testdata/rdata_nsec3_fromWire2"),
"rdata_nsec3_fromWire2"),
InvalidRdataLength);
// Invalid type bits
EXPECT_THROW(rdataFactoryFromFile(RRType::NSEC3(), RRClass::IN(),
"testdata/rdata_nsec3_fromWire3"),
"rdata_nsec3_fromWire3"),
DNSMessageFORMERR);
}
......@@ -105,7 +105,7 @@ TEST_F(Rdata_NSEC3_Test, toWireRenderer)
rdata_nsec3.toWire(renderer);
vector<unsigned char> data;
UnitTestUtil::readWireData("testdata/rdata_nsec3_fromWire1", data);
UnitTestUtil::readWireData("rdata_nsec3_fromWire1", data);
EXPECT_PRED_FORMAT4(UnitTestUtil::matchWireData,
static_cast<const uint8_t *>(obuffer.getData()) + 2,
obuffer.getLength() - 2, &data[2], data.size() - 2);
......
......@@ -65,7 +65,7 @@ TEST_F(Rdata_NSEC3PARAM_Test, createFromWire)
const generic::NSEC3PARAM rdata_nsec3param(nsec3param_txt);
EXPECT_EQ(0, rdata_nsec3param.compare(
*rdataFactoryFromFile(RRType::NSEC3PARAM(), RRClass::IN(),
"testdata/rdata_nsec3param_fromWire1")));
"rdata_nsec3param_fromWire1")));
}
TEST_F(Rdata_NSEC3PARAM_Test, toWireRenderer)
......@@ -75,7 +75,7 @@ TEST_F(Rdata_NSEC3PARAM_Test, toWireRenderer)
rdata_nsec3param.toWire(renderer);
vector<unsigned char> data;
UnitTestUtil::readWireData("testdata/rdata_nsec3param_fromWire1", data);
UnitTestUtil::readWireData("rdata_nsec3param_fromWire1", data);
EXPECT_PRED_FORMAT4(UnitTestUtil::matchWireData,
static_cast<const uint8_t *>(obuffer.getData()) + 2,
obuffer.getLength() - 2, &data[2], data.size() - 2);
......
......@@ -57,52 +57,52 @@ TEST_F(Rdata_NSEC_Test, createFromWire_NSEC) {
const generic::NSEC rdata_nsec(nsec_txt);
EXPECT_EQ(0, rdata_nsec.compare(
*rdataFactoryFromFile(RRType::NSEC(), RRClass::IN(),
"testdata/rdata_nsec_fromWire1")));
"rdata_nsec_fromWire1")));
// Too short RDLENGTH
EXPECT_THROW(rdataFactoryFromFile(RRType::NSEC(), RRClass::IN(),
"testdata/rdata_nsec_fromWire2"),
"rdata_nsec_fromWire2"),
DNSMessageFORMERR);
EXPECT_THROW(rdataFactoryFromFile(RRType::NSEC(), RRClass::IN(),
"testdata/rdata_nsec_fromWire3"),
"rdata_nsec_fromWire3"),
DNSMessageFORMERR);
// A malformed NSEC bitmap length field that could cause overflow.
EXPECT_THROW(rdataFactoryFromFile(RRType::NSEC(), RRClass::IN(),
"testdata/rdata_nsec_fromWire4"),
"rdata_nsec_fromWire4"),
DNSMessageFORMERR);
// The bitmap field is incomplete (only the first byte is included)
EXPECT_THROW(rdataFactoryFromFile(RRType::NSEC(), RRClass::IN(),
"testdata/rdata_nsec_fromWire5"),
"rdata_nsec_fromWire5"),
DNSMessageFORMERR);