BIND 10 trac1895, updated. 55b8698caa42aeaf183075f70bde4384484887c9 [1895] editorial: added a missing space in an error message.

BIND 10 source code commits bind10-changes at lists.isc.org
Tue Apr 17 16:11:50 UTC 2012


The branch, trac1895 has been updated
       via  55b8698caa42aeaf183075f70bde4384484887c9 (commit)
       via  4a42a85c8f8f53049076e303bbef7f5eab2e5eff (commit)
      from  be2d4ee977b32721e4c6194eafb786f53322c34a (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 55b8698caa42aeaf183075f70bde4384484887c9
Author: JINMEI Tatuya <jinmei at isc.org>
Date:   Tue Apr 17 09:10:43 2012 -0700

    [1895] editorial: added a missing space in an error message.
    
    not directly related to this branch, but the review comment on this point
    for the previous change should actually apply to this.

commit 4a42a85c8f8f53049076e303bbef7f5eab2e5eff
Author: JINMEI Tatuya <jinmei at isc.org>
Date:   Tue Apr 17 09:07:37 2012 -0700

    [1895] set B10_FROM_BUILD in main(), and globally for all tests.
    
    instead of doing it locally in MemoryDatasrcConfigTest because it doesn't
    seem to cause disruption, will probably be necessary for some other tests,
    and will make the set up much simpler.
    also explained the intent in more detail.
    previous change to config_unittest.cc was canceled accordingly.

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

Summary of changes:
 src/bin/auth/tests/common_unittest.cc |    2 +-
 src/bin/auth/tests/config_unittest.cc |   42 +--------------------------------
 src/bin/auth/tests/run_unittests.cc   |   15 +++++++++++-
 3 files changed, 16 insertions(+), 43 deletions(-)

-----------------------------------------------------------------------
diff --git a/src/bin/auth/tests/common_unittest.cc b/src/bin/auth/tests/common_unittest.cc
index 9b18142..184988d 100644
--- a/src/bin/auth/tests/common_unittest.cc
+++ b/src/bin/auth/tests/common_unittest.cc
@@ -36,7 +36,7 @@ public:
         BOOST_FOREACH(const Environ &env, restoreEnviron) {
             if (env.second == NULL) {
                 EXPECT_EQ(0, unsetenv(env.first.c_str())) <<
-                    "Couldn't restore environment, results of other tests"
+                    "Couldn't restore environment, results of other tests "
                     "are uncertain";
             } else {
                 EXPECT_EQ(0, setenv(env.first.c_str(), env.second->c_str(),
diff --git a/src/bin/auth/tests/config_unittest.cc b/src/bin/auth/tests/config_unittest.cc
index 1144703..d471a53 100644
--- a/src/bin/auth/tests/config_unittest.cc
+++ b/src/bin/auth/tests/config_unittest.cc
@@ -36,8 +36,6 @@
 #include <testutils/portconfig.h>
 #include <testutils/socket_request.h>
 
-#include <boost/foreach.hpp>
-
 #include <sstream>
 
 using namespace std;
@@ -50,10 +48,6 @@ using namespace isc::testutils;
 
 namespace {
 class AuthConfigTest : public ::testing::Test {
-private:
-    typedef pair<string, string> Environ;
-    vector<Environ> restoreEnviron;
-
 protected:
     AuthConfigTest() :
         dnss_(),
@@ -66,37 +60,6 @@ protected:
     {
         server.setDNSService(dnss_);
     }
-
-    void TearDown() {
-        // Restore the original environment
-        BOOST_FOREACH(const Environ &env, restoreEnviron) {
-            if (env.second.empty()) {
-                EXPECT_EQ(0, unsetenv(env.first.c_str())) <<
-                    "Couldn't restore environment, results of other tests"
-                    "are uncertain";
-            } else {
-                EXPECT_EQ(0, setenv(env.first.c_str(), env.second.c_str(),
-                                    1)) << "Couldn't restore environment, "
-                    "results of other tests are uncertain";
-            }
-        }
-    }
-
-    // Borrowed from common_unittest
-    void setEnv(const string& name, const string& value) {
-        // Backup the original environment (for simplicity we assume an empty
-        // value means the variable isn't set).
-        const char* env = getenv(name.c_str());
-        restoreEnviron.push_back(Environ(name,
-                                         env == NULL ? "" : string(env)));
-        // Set the new value
-        if (value.empty()) {
-            EXPECT_EQ(0, unsetenv(name.c_str()));
-        } else {
-            EXPECT_EQ(0, setenv(name.c_str(), value.c_str(), 1));
-        }
-    }
-
     MockDNSService dnss_;
     const RRClass rrclass;
     MockXfroutClient xfrout;
@@ -246,8 +209,7 @@ TEST_F(MemoryDatasrcConfigTest, addOneZone) {
 }
 
 // This test uses dynamic load of a data source module, and won't work when
-// statically linked.  We also need to set B10_FROM_BUILD so the data source
-// factory can identify the correct location of the module.
+// statically linked.
 TEST_F(MemoryDatasrcConfigTest,
 #ifdef USE_STATIC_LINK
        DISABLED_addOneWithFiletypeSQLite3
@@ -256,8 +218,6 @@ TEST_F(MemoryDatasrcConfigTest,
 #endif
     )
 {
-    setEnv("B10_FROM_BUILD", TOP_BUILD_DIR);
-
     const string test_db = TEST_DATA_BUILDDIR "/auth_test.sqlite3.copied";
     stringstream ss("example.org. 3600 IN SOA . . 0 0 0 0 0\n");
     createSQLite3DB(rrclass, Name("example.org"), test_db.c_str(), ss);
diff --git a/src/bin/auth/tests/run_unittests.cc b/src/bin/auth/tests/run_unittests.cc
index d3bbab7..30fc70b 100644
--- a/src/bin/auth/tests/run_unittests.cc
+++ b/src/bin/auth/tests/run_unittests.cc
@@ -12,12 +12,15 @@
 // OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
 // PERFORMANCE OF THIS SOFTWARE.
 
-#include <gtest/gtest.h>
 #include <log/logger_support.h>
 #include <util/unittests/run_all.h>
 
 #include <dns/tests/unittest_util.h>
 
+#include <gtest/gtest.h>
+
+#include <cstdlib>
+
 int
 main(int argc, char* argv[]) {
     ::testing::InitGoogleTest(&argc, argv);
@@ -25,5 +28,15 @@ main(int argc, char* argv[]) {
     isc::UnitTestUtil::addDataPath(TEST_DATA_BUILDDIR);
     isc::log::initLogger();
 
+    // Some tests require loading data source module dynamically, and to do
+    // that within the source/build tree we need to set this environment
+    // variable.  We hardcode it here so it works even if the test is invoked
+    // by hand (not via a makefile rule).  If we add a test that doesn't work
+    // with this variable defined, it should temporarily unset it for that
+    // specific test.
+    // We ignore the return value of setenv(3); we'd notice it via test
+    // failure that requires this variable.
+    setenv("B10_FROM_BUILD", TOP_BUILD_DIR, 1);
+
     return (isc::util::unittests::run_all());
 }



More information about the bind10-changes mailing list