Browse Source

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

Mukund Sivaraman 13 years ago
parent
commit
491896718f

+ 0 - 2
src/lib/log/tests/Makefile.am

@@ -67,7 +67,6 @@ 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,
@@ -91,7 +90,6 @@ 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

+ 0 - 1
src/lib/server_common/tests/Makefile.am

@@ -48,7 +48,6 @@ 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)

+ 0 - 1
src/lib/testutils/Makefile.am

@@ -9,7 +9,6 @@ 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

+ 0 - 36
src/lib/testutils/resource.cc

@@ -1,36 +0,0 @@
-// 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

+ 21 - 2
src/lib/testutils/resource.h

@@ -15,6 +15,11 @@
 #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 {
 
@@ -25,9 +30,23 @@ namespace testutils {
 /// 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.
+
+static 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};
 
-void
-dontCreateCoreDumps(void);
+    EXPECT_EQ(setrlimit(RLIMIT_CORE, &core_limit), 0);
+}
 
 } // end of namespace testutils
 } // end of namespace isc

+ 0 - 1
src/lib/util/tests/Makefile.am

@@ -44,7 +44,6 @@ 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)