BIND 10 trac1880, updated. bf72a7e8ea8b182a8b416095eb66958969d260f6 [1880] Use a helper function instead of repeating code
BIND 10 source code commits
bind10-changes at lists.isc.org
Thu May 3 04:28:45 UTC 2012
The branch, trac1880 has been updated
via bf72a7e8ea8b182a8b416095eb66958969d260f6 (commit)
from 1423f34716fdffd83bd4434163323074606d9084 (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 bf72a7e8ea8b182a8b416095eb66958969d260f6
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
-----------------------------------------------------------------------
Summary of changes:
src/lib/log/tests/Makefile.am | 2 +
src/lib/log/tests/logger_unittest.cc | 13 +-----
.../log/tests/message_initializer_2_unittest.cc | 12 +-----
src/lib/server_common/tests/Makefile.am | 1 +
src/lib/server_common/tests/portconfig_unittest.cc | 22 +---------
src/lib/testutils/Makefile.am | 1 +
.../{asiodns/logger.cc => testutils/resource.cc} | 23 ++++++++---
.../nsec3hash_python.h => testutils/resource.h} | 42 +++++++-------------
src/lib/util/tests/Makefile.am | 1 +
src/lib/util/tests/buffer_unittest.cc | 13 +-----
10 files changed, 47 insertions(+), 83 deletions(-)
copy src/lib/{asiodns/logger.cc => testutils/resource.cc} (62%)
copy src/lib/{dns/python/nsec3hash_python.h => testutils/resource.h} (56%)
-----------------------------------------------------------------------
diff --git a/src/lib/log/tests/Makefile.am b/src/lib/log/tests/Makefile.am
index c07eb4a..e25c03a 100644
--- a/src/lib/log/tests/Makefile.am
+++ b/src/lib/log/tests/Makefile.am
@@ -67,6 +67,7 @@ run_unittests_CPPFLAGS = $(AM_CPPFLAGS)
run_unittests_CXXFLAGS = $(AM_CXXFLAGS)
run_unittests_LDADD = $(AM_LDADD)
run_unittests_LDFLAGS = $(AM_LDFLAGS)
+run_unittests_LDFLAGS += $(top_builddir)/src/lib/testutils/libtestutils.la
# logging initialization tests. These are put in separate programs to
# ensure that the initialization status at the start of each test is known,
@@ -90,6 +91,7 @@ initializer_unittests_2_CPPFLAGS = $(AM_CPPFLAGS)
initializer_unittests_2_CXXFLAGS = $(AM_CXXFLAGS)
initializer_unittests_2_LDADD = $(AM_LDADD)
initializer_unittests_2_LDFLAGS = $(AM_LDFLAGS)
+initializer_unittests_2_LDFLAGS += $(top_builddir)/src/lib/testutils/libtestutils.la
noinst_PROGRAMS += $(TESTS)
endif
diff --git a/src/lib/log/tests/logger_unittest.cc b/src/lib/log/tests/logger_unittest.cc
index 47b9a47..3be706a 100644
--- a/src/lib/log/tests/logger_unittest.cc
+++ b/src/lib/log/tests/logger_unittest.cc
@@ -14,11 +14,11 @@
#include <iostream>
#include <string>
-#include <sys/time.h>
-#include <sys/resource.h>
#include <gtest/gtest.h>
+#include <testutils/resource.h>
+
#include <log/logger.h>
#include <log/logger_manager.h>
#include <log/logger_name.h>
@@ -372,14 +372,7 @@ TEST_F(LoggerTest, LoggerNameLength) {
// Note that we just check that it dies - we don't check what message is
// output.
EXPECT_DEATH({
- /* 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;
- core_limit.rlim_cur = 0;
- core_limit.rlim_max = 0;
- EXPECT_EQ(setrlimit(RLIMIT_CORE, &core_limit), 0);
+ isc::testutils::dontCreateCoreDumps();
string ok3(Logger::MAX_LOGGER_NAME_SIZE + 1, 'x');
Logger l3(ok3.c_str());
diff --git a/src/lib/log/tests/message_initializer_2_unittest.cc b/src/lib/log/tests/message_initializer_2_unittest.cc
index 2def3e1..8a338f4 100644
--- a/src/lib/log/tests/message_initializer_2_unittest.cc
+++ b/src/lib/log/tests/message_initializer_2_unittest.cc
@@ -12,10 +12,9 @@
// OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
// PERFORMANCE OF THIS SOFTWARE.
-#include <sys/time.h>
-#include <sys/resource.h>
#include <log/message_initializer.h>
#include <gtest/gtest.h>
+#include <testutils/resource.h>
using namespace isc::log;
@@ -44,14 +43,7 @@ TEST(MessageInitializerTest2, MessageLoadTest) {
#ifdef EXPECT_DEATH
// Adding one more should take us over the limit.
EXPECT_DEATH({
- /* 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;
- core_limit.rlim_cur = 0;
- core_limit.rlim_max = 0;
- EXPECT_EQ(setrlimit(RLIMIT_CORE, &core_limit), 0);
+ isc::testutils::dontCreateCoreDumps();
MessageInitializer initializer2(values);
}, ".*");
diff --git a/src/lib/server_common/tests/Makefile.am b/src/lib/server_common/tests/Makefile.am
index b059d47..8edcf12 100644
--- a/src/lib/server_common/tests/Makefile.am
+++ b/src/lib/server_common/tests/Makefile.am
@@ -48,6 +48,7 @@ run_unittests_LDADD += $(top_builddir)/src/lib/util/unittests/libutil_unittests.
run_unittests_LDADD += $(top_builddir)/src/lib/exceptions/libexceptions.la
run_unittests_LDADD += $(top_builddir)/src/lib/config/libcfgclient.la
run_unittests_LDADD += $(top_builddir)/src/lib/config/tests/libfake_session.la
+run_unittests_LDADD += $(top_builddir)/src/lib/testutils/libtestutils.la
endif
noinst_PROGRAMS = $(TESTS)
diff --git a/src/lib/server_common/tests/portconfig_unittest.cc b/src/lib/server_common/tests/portconfig_unittest.cc
index dc664b7..ba5f566 100644
--- a/src/lib/server_common/tests/portconfig_unittest.cc
+++ b/src/lib/server_common/tests/portconfig_unittest.cc
@@ -12,12 +12,10 @@
// OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
// PERFORMANCE OF THIS SOFTWARE.
-#include <sys/time.h>
-#include <sys/resource.h>
-
#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>
@@ -316,14 +314,7 @@ TEST_F(InstallListenAddressesDeathTest, inconsistent) {
// Make sure it actually kills the application (there should be an abort
// in this case)
EXPECT_DEATH({
- /* 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;
- core_limit.rlim_cur = 0;
- core_limit.rlim_max = 0;
- EXPECT_EQ(setrlimit(RLIMIT_CORE, &core_limit), 0);
+ isc::testutils::dontCreateCoreDumps();
try {
installListenAddresses(deathAddresses, store_, dnss_);
@@ -342,14 +333,7 @@ TEST_F(InstallListenAddressesDeathTest, cantClose) {
// Instruct it to fail on close
sock_requestor_.break_release_ = true;
EXPECT_DEATH({
- /* 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;
- core_limit.rlim_cur = 0;
- core_limit.rlim_max = 0;
- EXPECT_EQ(setrlimit(RLIMIT_CORE, &core_limit), 0);
+ isc::testutils::dontCreateCoreDumps();
try {
// Setting to empty will close all current sockets.
diff --git a/src/lib/testutils/Makefile.am b/src/lib/testutils/Makefile.am
index 7a4c8d7..62ae012 100644
--- a/src/lib/testutils/Makefile.am
+++ b/src/lib/testutils/Makefile.am
@@ -9,6 +9,7 @@ noinst_LTLIBRARIES = libtestutils.la
libtestutils_la_SOURCES = srv_test.h srv_test.cc
libtestutils_la_SOURCES += dnsmessage_test.h dnsmessage_test.cc
+libtestutils_la_SOURCES += resource.cc resource.h
libtestutils_la_SOURCES += mockups.h
libtestutils_la_CPPFLAGS = $(AM_CPPFLAGS) $(GTEST_INCLUDES)
libtestutils_la_LIBADD = $(top_builddir)/src/lib/asiolink/libasiolink.la
diff --git a/src/lib/testutils/resource.cc b/src/lib/testutils/resource.cc
new file mode 100644
index 0000000..eb281d6
--- /dev/null
+++ b/src/lib/testutils/resource.cc
@@ -0,0 +1,36 @@
+// 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.
+
+#include <sys/time.h>
+#include <sys/resource.h>
+
+#include <gtest/gtest.h>
+
+namespace isc {
+namespace testutils {
+
+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 namespace testutils
+} // end of namespace isc
diff --git a/src/lib/testutils/resource.h b/src/lib/testutils/resource.h
new file mode 100644
index 0000000..d901816
--- /dev/null
+++ b/src/lib/testutils/resource.h
@@ -0,0 +1,35 @@
+// 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
+
+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.
+
+void
+dontCreateCoreDumps(void);
+
+} // end of namespace testutils
+} // end of namespace isc
+
+#endif /* __ISC_TESTUTILS_RESOURCE_H */
diff --git a/src/lib/util/tests/Makefile.am b/src/lib/util/tests/Makefile.am
index dc144bd..6a5c8a6 100644
--- a/src/lib/util/tests/Makefile.am
+++ b/src/lib/util/tests/Makefile.am
@@ -44,6 +44,7 @@ run_unittests_LDADD += $(top_builddir)/src/lib/util/io/libutil_io.la
run_unittests_LDADD += \
$(top_builddir)/src/lib/util/unittests/libutil_unittests.la
run_unittests_LDADD += $(top_builddir)/src/lib/exceptions/libexceptions.la
+run_unittests_LDADD += $(top_builddir)/src/lib/testutils/libtestutils.la
endif
noinst_PROGRAMS = $(TESTS)
diff --git a/src/lib/util/tests/buffer_unittest.cc b/src/lib/util/tests/buffer_unittest.cc
index a74a2c1..7caa586 100644
--- a/src/lib/util/tests/buffer_unittest.cc
+++ b/src/lib/util/tests/buffer_unittest.cc
@@ -12,10 +12,8 @@
// OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
// PERFORMANCE OF THIS SOFTWARE.
-#include <sys/time.h>
-#include <sys/resource.h>
-
#include <exceptions/exceptions.h>
+#include <testutils/resource.h>
#include <util/buffer.h>
@@ -188,14 +186,7 @@ TEST_F(BufferTest, outputBufferReadat) {
#ifdef EXPECT_DEATH
// We use assert now, so we check it dies
EXPECT_DEATH({
- /* 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;
- core_limit.rlim_cur = 0;
- core_limit.rlim_max = 0;
- EXPECT_EQ(setrlimit(RLIMIT_CORE, &core_limit), 0);
+ isc::testutils::dontCreateCoreDumps();
try {
obuffer[sizeof(testdata)];
More information about the bind10-changes
mailing list