BIND 10 master, updated. c16b3ab523860ccca5e8e9648b58801c3eefae29 [master] applied the proposed fix of #906 to fix failure in MessageTest::toText

BIND 10 source code commits bind10-changes at lists.isc.org
Fri May 6 21:52:27 UTC 2011


The branch, master has been updated
       via  c16b3ab523860ccca5e8e9648b58801c3eefae29 (commit)
      from  434719dc9b7eeee0d0901fa6f5e1847bc40691c2 (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 c16b3ab523860ccca5e8e9648b58801c3eefae29
Author: JINMEI Tatuya <jinmei at isc.org>
Date:   Fri May 6 14:51:36 2011 -0700

    [master] applied the proposed fix of #906 to fix failure in MessageTest::toText

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

Summary of changes:
 src/lib/dns/tests/message_unittest.cc |   13 +++++++------
 src/lib/util/unittests/testdata.h     |    8 ++++++++
 2 files changed, 15 insertions(+), 6 deletions(-)

-----------------------------------------------------------------------
diff --git a/src/lib/dns/tests/message_unittest.cc b/src/lib/dns/tests/message_unittest.cc
index 700e2bd..c79ea2c 100644
--- a/src/lib/dns/tests/message_unittest.cc
+++ b/src/lib/dns/tests/message_unittest.cc
@@ -683,11 +683,12 @@ TEST_F(MessageTest, toWireWithoutRcode) {
 TEST_F(MessageTest, toText) {
     // Check toText() output for a typical DNS response with records in
     // all sections
-    ifstream ifs;
-    unittests::openTestData("message_toText1.txt", ifs);
+    
     factoryFromFile(message_parse, "message_toText1.wire");
     {
         SCOPED_TRACE("Message toText test (basic case)");
+        ifstream ifs;
+        unittests::openTestData("message_toText1.txt", ifs);
         unittests::matchTextData(ifs, message_parse.toText());
     }
 
@@ -695,12 +696,12 @@ TEST_F(MessageTest, toText) {
     // from the dig output (other than replacing tabs with a space): adding
     // a newline after the "OPT PSEUDOSECTION".  This is an intentional change
     // in our version for better readability.
-    ifs.close();
     message_parse.clear(Message::PARSE);
-    unittests::openTestData("message_toText2.txt", ifs);
     factoryFromFile(message_parse, "message_toText2.wire");
     {
         SCOPED_TRACE("Message toText test with EDNS");
+        ifstream ifs;
+        unittests::openTestData("message_toText2.txt", ifs);
         unittests::matchTextData(ifs, message_parse.toText());
     }
 
@@ -708,12 +709,12 @@ TEST_F(MessageTest, toText) {
     // from the dig output (other than replacing tabs with a space): removing
     // a redundant white space at the end of TSIG RDATA.  We'd rather consider
     // it a dig's defect than a feature.
-    ifs.close();
     message_parse.clear(Message::PARSE);
-    unittests::openTestData("message_toText3.txt", ifs);
     factoryFromFile(message_parse, "message_toText3.wire");
     {
         SCOPED_TRACE("Message toText test with TSIG");
+        ifstream ifs;
+        unittests::openTestData("message_toText3.txt", ifs);
         unittests::matchTextData(ifs, message_parse.toText());
     }
 }
diff --git a/src/lib/util/unittests/testdata.h b/src/lib/util/unittests/testdata.h
index ed2722e..03bd83a 100644
--- a/src/lib/util/unittests/testdata.h
+++ b/src/lib/util/unittests/testdata.h
@@ -34,6 +34,14 @@ void addTestDataPath(const std::string& path);
 /// addTestDataPath().  On success, ifs will be ready for reading the data
 /// stored in 'datafile'.  If the data file cannot be open with any of the
 /// registered paths, a runtime_error exception will be thrown.
+///
+/// \note Care should be taken if you want to reuse the same single \c ifs
+/// for multiple input data.  Some standard C++ library implementations retain
+/// the failure bit if the first stream reaches the end of the first file,
+/// and make the second call to \c ifstream::open() fail.  The safest way
+/// is to use a different \c ifstream object for a new call to this function;
+/// alternatively make sure you explicitly clear the error bit by calling
+/// \c ifstream::clear() on \c ifs.
 void openTestData(const char* const datafile, std::ifstream& ifs);
 }
 }




More information about the bind10-changes mailing list