BIND 10 trac2427, updated. a435de0e81e1cde5ad40f5a8699252d31a2a39b7 [2427] Find INITIAL_WS even at the beginning of file

BIND 10 source code commits bind10-changes at lists.isc.org
Mon Dec 17 16:36:31 UTC 2012


The branch, trac2427 has been updated
       via  a435de0e81e1cde5ad40f5a8699252d31a2a39b7 (commit)
       via  f74f25e7b04afb0bb116fcb6023837e47f471a77 (commit)
      from  f8f73869c12d0cc0007618e91b943feab7073840 (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 a435de0e81e1cde5ad40f5a8699252d31a2a39b7
Author: Michal 'vorner' Vaner <michal.vaner at nic.cz>
Date:   Mon Dec 17 17:34:12 2012 +0100

    [2427] Find INITIAL_WS even at the beginning of file

commit f74f25e7b04afb0bb116fcb6023837e47f471a77
Author: Michal 'vorner' Vaner <michal.vaner at nic.cz>
Date:   Mon Dec 17 17:16:56 2012 +0100

    [2427] Check the error message texts
    
    This discovers a bug in the lexer, it doesn't produce initial whitespace
    at the start of file.

-----------------------------------------------------------------------

Summary of changes:
 src/lib/dns/master_lexer.cc                      |    2 +-
 src/lib/dns/master_lexer.h                       |    3 +-
 src/lib/dns/master_loader.cc                     |    4 ---
 src/lib/dns/tests/master_lexer_state_unittest.cc |    5 ++-
 src/lib/dns/tests/master_lexer_unittest.cc       |    4 +--
 src/lib/dns/tests/master_loader_unittest.cc      |   39 +++++++++++++++-------
 6 files changed, 35 insertions(+), 22 deletions(-)

-----------------------------------------------------------------------
diff --git a/src/lib/dns/master_lexer.cc b/src/lib/dns/master_lexer.cc
index e6e2c78..a4f9a9a 100644
--- a/src/lib/dns/master_lexer.cc
+++ b/src/lib/dns/master_lexer.cc
@@ -37,7 +37,7 @@ using namespace master_lexer_internal;
 
 struct MasterLexer::MasterLexerImpl {
     MasterLexerImpl() : source_(NULL), token_(MasterToken::NOT_STARTED),
-                        paren_count_(0), last_was_eol_(false),
+                        paren_count_(0), last_was_eol_(true),
                         has_previous_(false),
                         previous_paren_count_(0),
                         previous_was_eol_(false)
diff --git a/src/lib/dns/master_lexer.h b/src/lib/dns/master_lexer.h
index cdf2866..1aa4255 100644
--- a/src/lib/dns/master_lexer.h
+++ b/src/lib/dns/master_lexer.h
@@ -54,7 +54,8 @@ public:
         END_OF_LINE, ///< End of line detected
         END_OF_FILE, ///< End of file detected
         INITIAL_WS,  ///< White spaces at the beginning of a line after an
-                     ///< end of line (if asked for detecting it)
+                     ///< end of line or at the beginning of file (if asked
+                     //   for detecting it)
         NOVALUE_TYPE_MAX = INITIAL_WS, ///< Max integer corresponding to
                                        /// no-value (type only) types.
                                        /// Mainly for internal use.
diff --git a/src/lib/dns/master_loader.cc b/src/lib/dns/master_loader.cc
index 79c370e..62ca4d9 100644
--- a/src/lib/dns/master_loader.cc
+++ b/src/lib/dns/master_loader.cc
@@ -293,11 +293,7 @@ private:
             doInclude();
         } else if (iequals(directive, "ORIGIN")) {
             doOrigin(false);
-            // The doOrigin doesn't do the cleanup of the line. This is
-            // because it's shared with the doInclude and that one can't do
-            // it.
             eatUntilEOL(true);
-            // TODO: Implement
         } else if (iequals(directive, "TTL")) {
             setDefaultTTL(RRTTL(getString()), false);
             eatUntilEOL(true);
diff --git a/src/lib/dns/tests/master_lexer_state_unittest.cc b/src/lib/dns/tests/master_lexer_state_unittest.cc
index 846c4c2..2be43db 100644
--- a/src/lib/dns/tests/master_lexer_state_unittest.cc
+++ b/src/lib/dns/tests/master_lexer_state_unittest.cc
@@ -190,13 +190,16 @@ TEST_F(MasterLexerStateTest, unbalancedParentheses) {
 }
 
 TEST_F(MasterLexerStateTest, startToComment) {
-    // Begin with 'start', skip space, then encounter a comment.  Skip
+    // Begin with 'start', detect space, then encounter a comment.  Skip
     // the rest of the line, and recognize the new line.  Note that the
     // second ';' is simply ignored.
     ss << "  ;a;\n";
     ss << ";a;";           // Likewise, but the comment ends with EOF.
     lexer.pushSource(ss);
 
+    // Initial whitespace (asked for in common_options)
+    EXPECT_EQ(s_null, State::start(lexer, common_options));
+    EXPECT_EQ(Token::INITIAL_WS, s_crlf.getToken(lexer).getType());
     // Comment ending with EOL
     EXPECT_EQ(s_null, State::start(lexer, common_options));
     EXPECT_EQ(Token::END_OF_LINE, s_crlf.getToken(lexer).getType());
diff --git a/src/lib/dns/tests/master_lexer_unittest.cc b/src/lib/dns/tests/master_lexer_unittest.cc
index 42ed3fb..72dfde3 100644
--- a/src/lib/dns/tests/master_lexer_unittest.cc
+++ b/src/lib/dns/tests/master_lexer_unittest.cc
@@ -238,10 +238,8 @@ TEST_F(MasterLexerTest, ungetToken) {
 // Check ungetting token without overriding the start method. We also
 // check it works well with changing options between the calls.
 TEST_F(MasterLexerTest, ungetRealOptions) {
-    ss << "\n    \n";
+    ss << "    \n";
     lexer.pushSource(ss);
-    // Skip the first newline
-    EXPECT_EQ(MasterToken::END_OF_LINE, lexer.getNextToken().getType());
 
     // If we call it the usual way, it skips up to the newline and returns
     // it
diff --git a/src/lib/dns/tests/master_loader_unittest.cc b/src/lib/dns/tests/master_loader_unittest.cc
index 2377a19..2d1f95a 100644
--- a/src/lib/dns/tests/master_loader_unittest.cc
+++ b/src/lib/dns/tests/master_loader_unittest.cc
@@ -342,18 +342,24 @@ struct ErrorCase {
     // Check the unknown directive. The rest looks like ordinary RR,
     // so we see the $ is actually special.
     { "$UNKNOWN 3600    IN  A   192.0.2.1", NULL, "Unknown $ directive" },
-    { "$INCLUD " TEST_DATA_SRCDIR "/example.org", NULL, "Include too short" },
-    { "$INCLUDES " TEST_DATA_SRCDIR "/example.org", NULL, "Include too long" },
-    { "$INCLUDE", NULL, "Missing include path" },
+    { "$INCLUD " TEST_DATA_SRCDIR "/example.org", "Unknown directive 'INCLUD'",
+        "Include too short" },
+    { "$INCLUDES " TEST_DATA_SRCDIR "/example.org",
+        "Unknown directive 'INCLUDES'", "Include too long" },
+    { "$INCLUDE", "unexpected end of input", "Missing include path" },
+    // The following two error messages are system dependant, omitting
     { "$INCLUDE /file/not/found", NULL, "Include file not found" },
     { "$INCLUDE /file/not/found example.org. and here goes bunch of garbage",
         NULL, "Include file not found and garbage at the end of line" },
-    { "$ORIGIN", NULL, "Missing origin name" },
-    { "$ORIGIN invalid...name", NULL, "Invalid name for origin" },
-    { "$ORIGIN )brokentoken", NULL, "Broken token in origin" },
-    { "$ORIGIN example.org. garbage", NULL, "Garbage after origin" },
-    { "$ORIGI name.", NULL, "$ORIGIN too short" },
-    { "$ORIGINAL name.", NULL, "$ORIGIN too long" },
+    { "$ORIGIN", "unexpected end of input", "Missing origin name" },
+    { "$ORIGIN invalid...name", "duplicate period in invalid...name",
+        "Invalid name for origin" },
+    { "$ORIGIN )brokentoken", "unbalanced parentheses",
+        "Broken token in origin" },
+    { "$ORIGIN example.org. garbage", "Extra tokens at the end of line",
+        "Garbage after origin" },
+    { "$ORIGI name.", "Unknown directive 'ORIGI'", "$ORIGIN too short" },
+    { "$ORIGINAL name.", "Unknown directive 'ORIGINAL'", "$ORIGIN too long" },
     { "$TTL 100 extra-garbage", "Extra tokens at the end of line",
       "$TTL with extra token" },
     { "$TTL", "unexpected end of input", "missing TTL" },
@@ -375,7 +381,9 @@ checkCallbackMessage(const string& actual_msg, const string& expected_msg,
 
     // and it should end with "...:<line_num>]"
     const string line_desc = ":" + lexical_cast<string>(expected_line) + "]";
-    EXPECT_EQ(actual_msg.size() - line_desc.size(), actual_msg.find(line_desc));
+    EXPECT_EQ(actual_msg.size() - line_desc.size(),
+              actual_msg.find(line_desc)) << "Expected on line " <<
+        expected_line;
 }
 
 // Test a broken zone is handled properly. We test several problems,
@@ -461,6 +469,7 @@ TEST_F(MasterLoaderTest, includeWithGarbage) {
     EXPECT_NO_THROW(loader_->load());
     EXPECT_FALSE(loader_->loadedSucessfully());
     ASSERT_EQ(1, errors_.size());
+    checkCallbackMessage(errors_.at(0), "Extra tokens at the end of line", 1);
     // It says something about extra tokens at the end
     EXPECT_NE(string::npos, errors_[0].find("Extra"));
     EXPECT_TRUE(warnings_.empty());
@@ -479,8 +488,7 @@ TEST_F(MasterLoaderTest, originWithGarbage) {
     EXPECT_NO_THROW(loader_->load());
     EXPECT_FALSE(loader_->loadedSucessfully());
     ASSERT_EQ(1, errors_.size());
-    // It says something about extra tokens at the end
-    EXPECT_NE(string::npos, errors_[0].find("Extra"));
+    checkCallbackMessage(errors_.at(0), "Extra tokens at the end of line", 1);
     EXPECT_TRUE(warnings_.empty());
     checkARR("www.example.org");
 }
@@ -522,6 +530,8 @@ TEST_F(MasterLoaderTest, includeAndBadOrigin) {
     loader_->load();
     EXPECT_FALSE(loader_->loadedSucessfully());
     EXPECT_EQ(1, errors_.size());
+    checkCallbackMessage(errors_.at(0), "duplicate period in example..org.",
+                         1);
     EXPECT_TRUE(warnings_.empty());
     // And check it's the correct data
     checkARR("www.example.org");
@@ -558,6 +568,9 @@ TEST_F(MasterLoaderTest, includeAndInitialWS) {
     EXPECT_TRUE(loader_->loadedSucessfully());
     EXPECT_TRUE(errors_.empty());
     EXPECT_EQ(1, warnings_.size());
+    checkCallbackMessage(warnings_.at(0),
+                         "Ambiguous previous name previous name for use in "
+                         "place of initial whitespace", 3);
     checkARR("xyz.example.org");
     checkBasicRRs();
     checkARR("xyz.example.org");
@@ -776,6 +789,8 @@ TEST_F(MasterLoaderTest, noPreviousName) {
     loader_->load();
     EXPECT_FALSE(loader_->loadedSucessfully());
     EXPECT_EQ(1, errors_.size());
+    checkCallbackMessage(errors_.at(0), "No previous name to use in place of "
+                         "initial whitespace", 1);
     EXPECT_TRUE(warnings_.empty());
 }
 



More information about the bind10-changes mailing list