BIND 10 trac2377, updated. 1ba16e4d72f4923946981997fed48eccb786a0e0 [2377] Check for EOF on recover from problem
BIND 10 source code commits
bind10-changes at lists.isc.org
Fri Dec 7 19:43:36 UTC 2012
The branch, trac2377 has been updated
via 1ba16e4d72f4923946981997fed48eccb786a0e0 (commit)
via d7b4201a3b8daa0937883569b86085c42a8dbe1a (commit)
via 3b1307a0711edb6adb6e2e5532e302b5ce898537 (commit)
via 27597c6b64f541464113088eeac038b33d794096 (commit)
via 612e52448e93d3d5f0645117a0263428a4d5c7ae (commit)
via 1261088d77d3be53d8bc088abe4d4c5d9253dc40 (commit)
via d5137a32591ee4e832354607dea8627ebe1e089c (commit)
from 80de8b943cba0596032073ed443c573b341106af (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
commit 1ba16e4d72f4923946981997fed48eccb786a0e0
Author: Michal 'vorner' Vaner <michal.vaner at nic.cz>
Date: Fri Dec 7 19:51:41 2012 +0100
[2377] Check for EOF on recover from problem
commit d7b4201a3b8daa0937883569b86085c42a8dbe1a
Author: Michal 'vorner' Vaner <michal.vaner at nic.cz>
Date: Fri Dec 7 19:34:47 2012 +0100
[2377] More broken cases
Some quoted strings where they can't happen and some broken tokens.
commit 3b1307a0711edb6adb6e2e5532e302b5ce898537
Author: Michal 'vorner' Vaner <michal.vaner at nic.cz>
Date: Fri Dec 7 19:26:04 2012 +0100
[2377] Check the implementation accepts quoted names
This is questionable if it should be allowed (at least vim marks it in
red as error), but bind9 accepts it, so shall we too.
commit 27597c6b64f541464113088eeac038b33d794096
Author: Michal 'vorner' Vaner <michal.vaner at nic.cz>
Date: Fri Dec 7 19:24:25 2012 +0100
[2377] Document fields of ErrorCase in tests
commit 612e52448e93d3d5f0645117a0263428a4d5c7ae
Author: Michal 'vorner' Vaner <michal.vaner at nic.cz>
Date: Fri Dec 7 19:22:10 2012 +0100
[2377] Use rdata::compare to check equality of Rdata
commit 1261088d77d3be53d8bc088abe4d4c5d9253dc40
Author: Michal 'vorner' Vaner <michal.vaner at nic.cz>
Date: Fri Dec 7 19:13:47 2012 +0100
[2377] Pass string by reference
It was obviously forgotten (and cppcheck complained).
commit d5137a32591ee4e832354607dea8627ebe1e089c
Author: Michal 'vorner' Vaner <michal.vaner at nic.cz>
Date: Fri Dec 7 19:12:28 2012 +0100
[2377] cleanup: Simplify the test callback
-----------------------------------------------------------------------
Summary of changes:
src/lib/dns/tests/master_loader_unittest.cc | 59 +++++++++++++++++++--------
src/lib/dns/tests/testdata/example.org | 3 +-
2 files changed, 44 insertions(+), 18 deletions(-)
-----------------------------------------------------------------------
diff --git a/src/lib/dns/tests/master_loader_unittest.cc b/src/lib/dns/tests/master_loader_unittest.cc
index 1fe9a02..fea7664 100644
--- a/src/lib/dns/tests/master_loader_unittest.cc
+++ b/src/lib/dns/tests/master_loader_unittest.cc
@@ -18,6 +18,7 @@
#include <dns/rrset.h>
#include <dns/rrclass.h>
#include <dns/name.h>
+#include <dns/rdata.h>
#include <gtest/gtest.h>
#include <boost/bind.hpp>
@@ -40,23 +41,19 @@ class MasterLoaderTest : public ::testing::Test {
public:
MasterLoaderTest() :
callbacks_(boost::bind(&MasterLoaderTest::callback, this,
- true, _1, _2, _3),
+ &errors_, _1, _2, _3),
boost::bind(&MasterLoaderTest::callback, this,
- false, _1, _2, _3))
+ &warnings_, _1, _2, _3))
{}
/// Concatenate file, line, and reason, and add it to either errors
/// or warnings
- void callback(bool error, const std::string& file, size_t line,
- const std::string reason)
+ void callback(vector<string>* target, const std::string& file, size_t line,
+ const std::string& reason)
{
std::stringstream ss;
ss << reason << " [" << file << ":" << line << "]";
- if (error) {
- errors_.push_back(ss.str());
- } else {
- warnings_.push_back(ss.str());
- }
+ target->push_back(ss.str());
}
void addRRset(const Name& name, const RRClass& rrclass,
@@ -85,12 +82,15 @@ public:
options));
}
- string prepareZone(const string& line) {
+ string prepareZone(const string& line, bool include_last) {
string result;
result += "example.org. 3600 IN SOA ns1.example.org. "
"admin.example.org. 1234 3600 1800 2419200 7200\n";
- result += line + "\n";
- result += "correct 3600 IN A 192.0.2.2\n";
+ result += line;
+ if (include_last) {
+ result += "\n";
+ result += "correct 3600 IN A 192.0.2.2\n";
+ }
return (result);
}
@@ -109,8 +109,10 @@ public:
EXPECT_EQ(Name(name), current->getName());
ASSERT_EQ(type, current->getType());
+ EXPECT_EQ(RRClass::IN(), current->getClass());
ASSERT_EQ(1, current->getRdataCount());
- EXPECT_EQ(data, current->getRdataIterator()->getCurrent().toText());
+ EXPECT_EQ(0, isc::dns::rdata::createRdata(type, RRClass::IN(), data)->
+ compare(current->getRdataIterator()->getCurrent()));
}
MasterLoaderCallbacks callbacks_;
@@ -140,7 +142,7 @@ TEST_F(MasterLoaderTest, basicLoad) {
// Check it works the same when created based on a stream, not filename
TEST_F(MasterLoaderTest, streamConstructor) {
- stringstream zone_stream(prepareZone(""));
+ stringstream zone_stream(prepareZone("", true));
setLoader(zone_stream, Name("example.org."), RRClass::IN(),
MasterLoader::MANY_ERRORS);
@@ -200,8 +202,8 @@ TEST_F(MasterLoaderTest, invalidFile) {
}
struct ErrorCase {
- const char* const line;
- const char* const problem;
+ const char* const line; // The broken line in master file
+ const char* const problem; // Description of the problem for SCOPED_TRACE
} const error_cases[] = {
{ "www... 3600 IN A 192.0.2.1", "Invalid name" },
{ "www FORTNIGHT IN A 192.0.2.1", "Invalid TTL" },
@@ -209,6 +211,11 @@ struct ErrorCase {
{ "www 3600 IN A bad_ip", "Invalid Rdata" },
{ "www 3600 IN", "Unexpected EOLN" },
{ "www 3600 CH TXT nothing", "Class mismatch" },
+ { "www \"3600\" IN A 192.0.2.1", "Quoted TTL" },
+ { "www 3600 \"IN\" A 192.0.2.1", "Quoted class" },
+ { "www 3600 IN \"A\" 192.0.2.1", "Quoted type" },
+ { "unbalanced)paren 3600 IN A 192.0.2.1", "Token error 1" },
+ { "www 3600 unbalanced)paren A 192.0.2.1", "Token error 2" },
{ NULL, NULL }
};
@@ -217,7 +224,7 @@ struct ErrorCase {
TEST_F(MasterLoaderTest, brokenZone) {
for (const ErrorCase* ec = error_cases; ec->line != NULL; ++ec) {
SCOPED_TRACE(ec->problem);
- const string zone(prepareZone(ec->line));
+ const string zone(prepareZone(ec->line, true));
{
SCOPED_TRACE("Strict mode");
@@ -251,6 +258,24 @@ TEST_F(MasterLoaderTest, brokenZone) {
checkRR("correct.example.org", RRType::A(), "192.0.2.2");
EXPECT_TRUE(rrsets_.empty());
}
+
+ {
+ SCOPED_TRACE("Error at EOF");
+ // This case is interesting only in the lenient mode.
+ const string zoneEOF(prepareZone(ec->line, false));
+ clear();
+ stringstream zone_stream(zoneEOF);
+ setLoader(zone_stream, Name("example.org."), RRClass::IN(),
+ MasterLoader::MANY_ERRORS);
+ EXPECT_NO_THROW(loader_->load());
+ EXPECT_EQ(1, errors_.size());
+ // FIXME: The invalid rdata generates a warning.
+ // And we may want to generate warning ourself here too.
+ // EXPECT_TRUE(warnings_.empty());
+ checkRR("example.org", RRType::SOA(), "ns1.example.org. "
+ "admin.example.org. 1234 3600 1800 2419200 7200");
+ EXPECT_TRUE(rrsets_.empty());
+ }
}
}
diff --git a/src/lib/dns/tests/testdata/example.org b/src/lib/dns/tests/testdata/example.org
index deef7d5..2f2edf3 100644
--- a/src/lib/dns/tests/testdata/example.org
+++ b/src/lib/dns/tests/testdata/example.org
@@ -7,7 +7,8 @@ example.org. 3600 IN SOA ( ; The SOA, split across lines for testing
2419200
7200
)
-example.org. 3600 IN NS ns1.example.org.
+; Check it accepts quoted name too
+"\101xample.org." 3600 IN NS ns1.example.org.
; Some empty lines here. They are to make sure the loader can skip them.
More information about the bind10-changes
mailing list