Commit 1ba16e4d authored by Michal 'vorner' Vaner's avatar Michal 'vorner' Vaner
Browse files

[2377] Check for EOF on recover from problem

parent d7b4201a
......@@ -82,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);
}
......@@ -139,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);
......@@ -221,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");
......@@ -255,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());
}
}
}
......
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