Browse Source

[2377] Warn on unexpected EOF after error

When there's an error, we expect there'll be EOLN somewhere, so we can
recover. Warn in case there's EOF.
Michal 'vorner' Vaner 12 years ago
parent
commit
3b1f845a12
2 changed files with 5 additions and 3 deletions
  1. 3 0
      src/lib/dns/master_loader.cc
  2. 2 3
      src/lib/dns/tests/master_loader_unittest.cc

+ 3 - 0
src/lib/dns/master_loader.cc

@@ -204,6 +204,9 @@ MasterLoader::MasterLoaderImpl::loadIncremental(size_t count_limit) {
                 const MasterToken& token(lexer_.getNextToken());
                 switch (token.getType()) {
                     case MasterToken::END_OF_FILE:
+                        callbacks_.warning(lexer_.getSourceName(),
+                                           lexer_.getSourceLine(),
+                                           "Unexpected end ond of file");
                         // TODO: Try pop in case this is not the only
                         // source
                         return (true);

+ 2 - 3
src/lib/dns/tests/master_loader_unittest.cc

@@ -282,9 +282,8 @@ TEST_F(MasterLoaderTest, brokenZone) {
             EXPECT_NO_THROW(loader_->load());
             EXPECT_FALSE(loader_->loadedSucessfully());
             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());
+            // The unexpected EOF warning
+            EXPECT_EQ(1, warnings_.size());
             checkRR("example.org", RRType::SOA(), "ns1.example.org. "
                     "admin.example.org. 1234 3600 1800 2419200 7200");
             EXPECT_TRUE(rrsets_.empty());