BIND 10 master, updated. 255456507a465ee2cb1b94e386366f259c8e9487 [1880] Style fix

BIND 10 source code commits bind10-changes at lists.isc.org
Fri May 4 09:54:55 UTC 2012


The branch, master has been updated
       via  255456507a465ee2cb1b94e386366f259c8e9487 (commit)
       via  491896718f86b7514c661b7964cd92673f7e037f (commit)
       via  8b0e391e3a838b2d76d87e87088f025491802c8b (commit)
       via  408043d940134c7e7c301e762888f10a4184a400 (commit)
       via  d7191f1b7ae74dc696c386576c422582800aa5b2 (commit)
      from  56083b82568a61b2fc48afd95b7e998568216894 (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 255456507a465ee2cb1b94e386366f259c8e9487
Author: Michal 'vorner' Vaner <michal.vaner at nic.cz>
Date:   Fri May 4 09:53:15 2012 +0200

    [1880] Style fix
    
    We use anonymous namespace instead of static before a function.

commit 491896718f86b7514c661b7964cd92673f7e037f
Author: Mukund Sivaraman <muks at isc.org>
Date:   Fri May 4 08:57:16 2012 +0530

    [1880] Move dontCreateCoreDumps() definition to the header due to dependency issues

commit 8b0e391e3a838b2d76d87e87088f025491802c8b
Author: Mukund Sivaraman <muks at isc.org>
Date:   Fri May 4 08:37:22 2012 +0530

    [1880] Untabify file

commit 408043d940134c7e7c301e762888f10a4184a400
Author: Mukund Sivaraman <muks at isc.org>
Date:   Thu May 3 09:43:57 2012 +0530

    [1880] Use a helper function instead of repeating code

commit d7191f1b7ae74dc696c386576c422582800aa5b2
Author: Mukund Sivaraman <muks at isc.org>
Date:   Wed May 2 10:45:56 2012 +0530

    [1880] Don't create core files when EXPECT_DEATH is used

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

Summary of changes:
 src/lib/log/tests/logger_unittest.cc               |   10 +++-
 .../log/tests/message_initializer_2_unittest.cc    |    5 ++-
 src/lib/server_common/tests/portconfig_unittest.cc |   39 ++++++++------
 src/lib/testutils/resource.h                       |   58 ++++++++++++++++++++
 src/lib/util/tests/buffer_unittest.cc              |    3 +
 5 files changed, 94 insertions(+), 21 deletions(-)
 create mode 100644 src/lib/testutils/resource.h

-----------------------------------------------------------------------
diff --git a/src/lib/log/tests/logger_unittest.cc b/src/lib/log/tests/logger_unittest.cc
index d60bcb0..3be706a 100644
--- a/src/lib/log/tests/logger_unittest.cc
+++ b/src/lib/log/tests/logger_unittest.cc
@@ -17,6 +17,8 @@
 
 #include <gtest/gtest.h>
 
+#include <testutils/resource.h>
+
 #include <log/logger.h>
 #include <log/logger_manager.h>
 #include <log/logger_name.h>
@@ -370,8 +372,10 @@ TEST_F(LoggerTest, LoggerNameLength) {
     // Note that we just check that it dies - we don't check what message is
     // output.
     EXPECT_DEATH({
-                    string ok3(Logger::MAX_LOGGER_NAME_SIZE + 1, 'x');
-                    Logger l3(ok3.c_str());
-                 }, ".*");
+        isc::testutils::dontCreateCoreDumps();
+
+        string ok3(Logger::MAX_LOGGER_NAME_SIZE + 1, 'x');
+        Logger l3(ok3.c_str());
+    }, ".*");
 #endif
 }
diff --git a/src/lib/log/tests/message_initializer_2_unittest.cc b/src/lib/log/tests/message_initializer_2_unittest.cc
index ca34b36..8a338f4 100644
--- a/src/lib/log/tests/message_initializer_2_unittest.cc
+++ b/src/lib/log/tests/message_initializer_2_unittest.cc
@@ -14,6 +14,7 @@
 
 #include <log/message_initializer.h>
 #include <gtest/gtest.h>
+#include <testutils/resource.h>
 
 using namespace isc::log;
 
@@ -42,7 +43,9 @@ TEST(MessageInitializerTest2, MessageLoadTest) {
 #ifdef EXPECT_DEATH
     // Adding one more should take us over the limit.
     EXPECT_DEATH({
+        isc::testutils::dontCreateCoreDumps();
+
         MessageInitializer initializer2(values);
-        }, ".*");
+      }, ".*");
 #endif
 }
diff --git a/src/lib/server_common/tests/portconfig_unittest.cc b/src/lib/server_common/tests/portconfig_unittest.cc
index 6563815..3910e6b 100644
--- a/src/lib/server_common/tests/portconfig_unittest.cc
+++ b/src/lib/server_common/tests/portconfig_unittest.cc
@@ -15,6 +15,7 @@
 #include <server_common/portconfig.h>
 #include <testutils/socket_request.h>
 #include <testutils/mockups.h>
+#include <testutils/resource.h>
 
 #include <cc/data.h>
 #include <exceptions/exceptions.h>
@@ -313,13 +314,15 @@ TEST_F(InstallListenAddressesDeathTest, inconsistent) {
     // Make sure it actually kills the application (there should be an abort
     // in this case)
     EXPECT_DEATH({
-                    try {
-                        installListenAddresses(deathAddresses, store_, dnss_);
-                    } catch (...) {
-                        // Prevent exceptions killing the application, we need
-                        // to make sure it dies the real hard way
-                    };
-                 }, "");
+        isc::testutils::dontCreateCoreDumps();
+
+        try {
+          installListenAddresses(deathAddresses, store_, dnss_);
+        } catch (...) {
+          // Prevent exceptions killing the application, we need
+          // to make sure it dies the real hard way
+        };
+      }, "");
 }
 
 // If we are unable to tell the boss we closed a socket, we abort, as we are
@@ -330,16 +333,18 @@ TEST_F(InstallListenAddressesDeathTest, cantClose) {
     // Instruct it to fail on close
     sock_requestor_.break_release_ = true;
     EXPECT_DEATH({
-                    try {
-                        // Setting to empty will close all current sockets.
-                        // And thanks to the break_release_, the close will
-                        // throw, which will make it crash.
-                        installListenAddresses(empty, store_, dnss_);
-                    } catch (...) {
-                        // To make sure it is killed by abort, not by some
-                        // (unhandled) exception
-                    };
-                }, "");
+        isc::testutils::dontCreateCoreDumps();
+
+        try {
+          // Setting to empty will close all current sockets.
+          // And thanks to the break_release_, the close will
+          // throw, which will make it crash.
+          installListenAddresses(empty, store_, dnss_);
+        } catch (...) {
+          // To make sure it is killed by abort, not by some
+          // (unhandled) exception
+        };
+      }, "");
     // And reset it back, so it can safely clean up itself.
     sock_requestor_.break_release_ = false;
 }
diff --git a/src/lib/testutils/resource.h b/src/lib/testutils/resource.h
new file mode 100644
index 0000000..192d4a6
--- /dev/null
+++ b/src/lib/testutils/resource.h
@@ -0,0 +1,58 @@
+// Copyright (C) 2012  Internet Systems Consortium, Inc. ("ISC")
+//
+// Permission to use, copy, modify, and/or distribute this software for any
+// purpose with or without fee is hereby granted, provided that the above
+// copyright notice and this permission notice appear in all copies.
+//
+// THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH
+// REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
+// AND FITNESS.  IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT,
+// INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
+// LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
+// OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
+// PERFORMANCE OF THIS SOFTWARE.
+
+#ifndef __ISC_TESTUTILS_RESOURCE_H
+#define __ISC_TESTUTILS_RESOURCE_H
+
+#include <sys/time.h>
+#include <sys/resource.h>
+
+#include <gtest/gtest.h>
+
+namespace isc {
+namespace testutils {
+
+/// Don't create core dumps.
+///
+/// This function sets the core size to 0, inhibiting the creation of
+/// core dumps. It is meant to be used in testcases where EXPECT_DEATH
+/// is used, where processes abort (and create cores in the process).
+/// As a new process is forked to run EXPECT_DEATH tests, the rlimits of
+/// the parent process that runs the other tests should be unaffected.
+///
+/// This function definition is in the header file as otherwise there'd
+/// be a circular dependency from
+/// testutils->asiolink->log->testutils. See bug #1880.
+
+namespace {
+
+inline void
+dontCreateCoreDumps(void)
+{
+    /* Set rlimits so that no coredumps are created. As a new
+       process is forked to run this EXPECT_DEATH test, the rlimits
+       of the parent process that runs the other tests should be
+       unaffected. */
+
+    rlimit core_limit = {0, 0};
+
+    EXPECT_EQ(setrlimit(RLIMIT_CORE, &core_limit), 0);
+}
+
+} // end of anonymous namespace
+
+} // end of namespace testutils
+} // end of namespace isc
+
+#endif /* __ISC_TESTUTILS_RESOURCE_H */
diff --git a/src/lib/util/tests/buffer_unittest.cc b/src/lib/util/tests/buffer_unittest.cc
index 8cccd28..7caa586 100644
--- a/src/lib/util/tests/buffer_unittest.cc
+++ b/src/lib/util/tests/buffer_unittest.cc
@@ -13,6 +13,7 @@
 // PERFORMANCE OF THIS SOFTWARE.
 
 #include <exceptions/exceptions.h>
+#include <testutils/resource.h>
 
 #include <util/buffer.h>
 
@@ -185,6 +186,8 @@ TEST_F(BufferTest, outputBufferReadat) {
 #ifdef EXPECT_DEATH
     // We use assert now, so we check it dies
     EXPECT_DEATH({
+        isc::testutils::dontCreateCoreDumps();
+
         try {
             obuffer[sizeof(testdata)];
         } catch (...) {



More information about the bind10-changes mailing list