]> git.ipfire.org Git - thirdparty/kea.git/commitdiff
[3113] Fix hooks unit test failures when --enable-static-link is used.
authorMarcin Siodelski <marcin@isc.org>
Fri, 30 Aug 2013 17:26:55 +0000 (19:26 +0200)
committerMarcin Siodelski <marcin@isc.org>
Fri, 30 Aug 2013 17:26:55 +0000 (19:26 +0200)
src/bin/dhcp4/tests/Makefile.am
src/bin/dhcp4/tests/test_libraries.h.in
src/bin/dhcp6/tests/Makefile.am
src/bin/dhcp6/tests/test_libraries.h.in
src/lib/asiodns/Makefile.am
src/lib/dhcpsrv/tests/Makefile.am
src/lib/dhcpsrv/tests/test_libraries.h.in
src/lib/hooks/tests/Makefile.am
src/lib/hooks/tests/test_libraries.h.in
src/lib/resolve/Makefile.am
src/lib/testutils/Makefile.am

index fc7eabf70081808fb956091e9c3cfddb7581c701..3b7691f0940ff2bdfe8928129cb7bdc745020189 100644 (file)
@@ -40,25 +40,35 @@ if USE_CLANGPP
 AM_CXXFLAGS += -Wno-unused-parameter
 endif
 
-if USE_STATIC_LINK
-AM_LDFLAGS = -static
-endif
-
 TESTS_ENVIRONMENT = \
         $(LIBTOOL) --mode=execute $(VALGRIND_COMMAND)
 
 TESTS =
 if HAVE_GTEST
-# Build shared libraries for testing.
+# Build shared libraries for testing. The libtool way to create a shared library
+# is to specify "-avoid-version -export-dynamic -module" in the library LDFLAGS
+# (see http://www.gnu.org/software/libtool/manual/html_node/Link-mode.html).
+# Use of these switches will guarantee that the .so files are created in the
+# .libs folder and they can be dlopened.
+# Note that the shared libraries with callouts should not be used together with
+# the --enable-static-link option. With this option, the bind10 libraries are
+# statically linked with the program and if the callout invokes the methods
+# which belong to these libraries, the library with the callout will get its
+# own copy of the static objects (e.g. logger, ServerHooks) and that will lead
+# to unexpected errors. For this reason, the --enable-static-link option is
+# ignored for unit tests built here.
+
 lib_LTLIBRARIES = libco1.la libco2.la
 
 libco1_la_SOURCES  = callout_library_1.cc callout_library_common.h
 libco1_la_CXXFLAGS = $(AM_CXXFLAGS)
 libco1_la_CPPFLAGS = $(AM_CPPFLAGS)
+libco1_la_LDFLAGS = -avoid-version -export-dynamic -module
 
 libco2_la_SOURCES  = callout_library_2.cc callout_library_common.h
 libco2_la_CXXFLAGS = $(AM_CXXFLAGS)
 libco2_la_CPPFLAGS = $(AM_CPPFLAGS)
+libco2_la_LDFLAGS = -avoid-version -export-dynamic -module
 
 TESTS += dhcp4_unittests
 
index 8b03dc2dcd5140a17d0bc2b0eb35fad45cd279c4..1cddf006e559f31300015ea059236d0331421246 100644 (file)
 
 namespace {
 
-
-// Take care of differences in DLL naming between operating systems.
-
-#ifdef OS_OSX
-#define DLL_SUFFIX ".dylib"
-
-#else
 #define DLL_SUFFIX ".so"
 
-#endif
-
-
 // Names of the libraries used in these tests.  These libraries are built using
 // libtool, so we need to look in the hidden ".libs" directory to locate the
 // shared library.
 
 // Library with load/unload functions creating marker files to check their
 // operation.
-const char* const CALLOUT_LIBRARY_1 = "@abs_builddir@/.libs/libco1"
-                                           DLL_SUFFIX;
-const char* const CALLOUT_LIBRARY_2 = "@abs_builddir@/.libs/libco2"
-                                           DLL_SUFFIX;
+const char* const CALLOUT_LIBRARY_1 = "@abs_builddir@/.libs/libco1.so";
+const char* const CALLOUT_LIBRARY_2 = "@abs_builddir@/.libs/libco2.so";
 
 // Name of a library which is not present.
-const char* const NOT_PRESENT_LIBRARY = "@abs_builddir@/.libs/libnothere"
-                                         DLL_SUFFIX;
+const char* const NOT_PRESENT_LIBRARY = "@abs_builddir@/.libs/libnothere.so";
+
 } // anonymous namespace
 
 
index 7ea71634bb87c27c0eed477d33629a9d8ce462d3..19c6deae004ba6f2c47d825058410572aadeca3b 100644 (file)
@@ -36,25 +36,35 @@ if USE_CLANGPP
 AM_CXXFLAGS += -Wno-unused-parameter
 endif
 
-if USE_STATIC_LINK
-AM_LDFLAGS = -static
-endif
-
 TESTS_ENVIRONMENT = \
         $(LIBTOOL) --mode=execute $(VALGRIND_COMMAND)
 
 TESTS =
 if HAVE_GTEST
-# Build shared libraries for testing.
+# Build shared libraries for testing. The libtool way to create a shared library
+# is to specify "-avoid-version -export-dynamic -module" in the library LDFLAGS
+# (see http://www.gnu.org/software/libtool/manual/html_node/Link-mode.html).
+# Use of these switches will guarantee that the .so files are created in the
+# .libs folder and they can be dlopened.
+# Note that the shared libraries with callouts should not be used together with
+# the --enable-static-link option. With this option, the bind10 libraries are
+# statically linked with the program and if the callout invokes the methods
+# which belong to these libraries, the library with the callout will get its
+# own copy of the static objects (e.g. logger, ServerHooks) and that will lead
+# to unexpected errors. For this reason, the --enable-static-link option is
+# ignored for unit tests built here.
+
 lib_LTLIBRARIES = libco1.la libco2.la
 
 libco1_la_SOURCES  = callout_library_1.cc callout_library_common.h
 libco1_la_CXXFLAGS = $(AM_CXXFLAGS)
 libco1_la_CPPFLAGS = $(AM_CPPFLAGS)
+libco1_la_LDFLAGS = -avoid-version -export-dynamic -module
 
 libco2_la_SOURCES  = callout_library_2.cc callout_library_common.h
 libco2_la_CXXFLAGS = $(AM_CXXFLAGS)
 libco2_la_CPPFLAGS = $(AM_CPPFLAGS)
+libco2_la_LDFLAGS = -avoid-version -export-dynamic -module
 
 TESTS += dhcp6_unittests
 dhcp6_unittests_SOURCES  = dhcp6_unittests.cc
index 8b03dc2dcd5140a17d0bc2b0eb35fad45cd279c4..f25d9e2a38ef82a0dd343ec92a31f2bed97ef6e6 100644 (file)
 
 namespace {
 
-
-// Take care of differences in DLL naming between operating systems.
-
-#ifdef OS_OSX
-#define DLL_SUFFIX ".dylib"
-
-#else
-#define DLL_SUFFIX ".so"
-
-#endif
-
-
 // Names of the libraries used in these tests.  These libraries are built using
 // libtool, so we need to look in the hidden ".libs" directory to locate the
 // shared library.
 
 // Library with load/unload functions creating marker files to check their
 // operation.
-const char* const CALLOUT_LIBRARY_1 = "@abs_builddir@/.libs/libco1"
-                                           DLL_SUFFIX;
-const char* const CALLOUT_LIBRARY_2 = "@abs_builddir@/.libs/libco2"
-                                           DLL_SUFFIX;
+const char* const CALLOUT_LIBRARY_1 = "@abs_builddir@/.libs/libco1.so";
+const char* const CALLOUT_LIBRARY_2 = "@abs_builddir@/.libs/libco2.so";
 
 // Name of a library which is not present.
-const char* const NOT_PRESENT_LIBRARY = "@abs_builddir@/.libs/libnothere"
-                                         DLL_SUFFIX;
+const char* const NOT_PRESENT_LIBRARY = "@abs_builddir@/.libs/libnothere.so";
+
 } // anonymous namespace
 
 
index 321de8b9d1819808b041e644c8f2b1838ab36b1d..9164ac0b782e6c980352d3feac514598061374f7 100644 (file)
@@ -40,4 +40,5 @@ if USE_CLANGPP
 libb10_asiodns_la_CXXFLAGS += -Wno-error
 endif
 libb10_asiodns_la_CPPFLAGS = $(AM_CPPFLAGS)
-libb10_asiodns_la_LIBADD = $(top_builddir)/src/lib/log/libb10-log.la
+libb10_asiodns_la_LIBADD  = $(top_builddir)/src/lib/asiolink/libb10-asiolink.la
+libb10_asiodns_la_LIBADD += $(top_builddir)/src/lib/log/libb10-log.la
index 087b28d3771a64830ce2c353b2c4bbf5ee1e1063..546ced98c5ef8d128bfc10afbd92580be1551fcb 100644 (file)
@@ -13,11 +13,6 @@ AM_CXXFLAGS = $(B10_CXXFLAGS)
 # But older GCC compilers don't have the flag.
 AM_CXXFLAGS += $(WARNING_NO_MISSING_FIELD_INITIALIZERS_CFLAG)
 
-if USE_STATIC_LINK
-AM_LDFLAGS = -static
-TEST_LIBS_LDFLAGS = -Bshareable
-endif
-
 CLEANFILES = *.gcno *.gcda
 
 TESTS_ENVIRONMENT = \
@@ -25,19 +20,30 @@ TESTS_ENVIRONMENT = \
 
 TESTS =
 if HAVE_GTEST
-# Build shared libraries for testing.
+# Build shared libraries for testing. The libtool way to create a shared library
+# is to specify "-avoid-version -export-dynamic -module" in the library LDFLAGS
+# (see http://www.gnu.org/software/libtool/manual/html_node/Link-mode.html).
+# Use of these switches will guarantee that the .so files are created in the
+# .libs folder and they can be dlopened.
+# Note that the shared libraries with callouts should not be used together with
+# the --enable-static-link option. With this option, the bind10 libraries are
+# statically linked with the program and if the callout invokes the methods
+# which belong to these libraries, the library with the callout will get its
+# own copy of the static objects (e.g. logger, ServerHooks) and that will lead
+# to unexpected errors. For this reason, the --enable-static-link option is
+# ignored for unit tests built here.
+
 lib_LTLIBRARIES = libco1.la libco2.la
 
 libco1_la_SOURCES  = callout_library.cc
 libco1_la_CXXFLAGS = $(AM_CXXFLAGS)
 libco1_la_CPPFLAGS = $(AM_CPPFLAGS) $(LOG4CPLUS_INCLUDES)
-libco1_la_LDFLAGS = $(TEST_LIBS_LDFLAGS)
+libco1_la_LDFLAGS = -avoid-version -export-dynamic -module
 
 libco2_la_SOURCES  = callout_library.cc
 libco2_la_CXXFLAGS = $(AM_CXXFLAGS)
 libco2_la_CPPFLAGS = $(AM_CPPFLAGS) $(LOG4CPLUS_INCLUDES)
-libco2_la_LDFLAGS = $(TEST_LIBS_LDFLAGS)
-
+libco2_la_LDFLAGS = -avoid-version -export-dynamic -module
 
 TESTS += libdhcpsrv_unittests
 
index b5e80a04f73d6a9a9bea180115060d3820c82730..a2843dddefaa8093721c07300e702e956ca329e4 100644 (file)
 
 namespace {
 
-
-// Take care of differences in DLL naming between operating systems.
-
-#ifdef OS_OSX
-#define DLL_SUFFIX ".dylib"
-
-#else
-#define DLL_SUFFIX ".so"
-
-#endif
-
-
 // Names of the libraries used in these tests.  These libraries are built using
 // libtool, so we need to look in the hidden ".libs" directory to locate the
 // shared library.
 
 // Library with load/unload functions creating marker files to check their
 // operation.
-static const char* CALLOUT_LIBRARY_1 = "@abs_builddir@/.libs/libco1"
-                                           DLL_SUFFIX;
-static const char* CALLOUT_LIBRARY_2 = "@abs_builddir@/.libs/libco2"
-                                           DLL_SUFFIX;
+static const char* CALLOUT_LIBRARY_1 = "@abs_builddir@/.libs/libco1.so";
+static const char* CALLOUT_LIBRARY_2 = "@abs_builddir@/.libs/libco2.so";
 
 // Name of a library which is not present.
-static const char* NOT_PRESENT_LIBRARY = "@abs_builddir@/.libs/libnothere"
-                                         DLL_SUFFIX;
+static const char* NOT_PRESENT_LIBRARY = "@abs_builddir@/.libs/libnothere.so";
+
 } // anonymous namespace
 
 
index 37fe2384cb55d37e1325b5a423a9e763f6a40a1b..c7acd2461d817f4938e58c0d829ae7ac80c3ff9a 100644 (file)
@@ -22,7 +22,19 @@ TESTS_ENVIRONMENT = \
 
 TESTS =
 if HAVE_GTEST
-# Build shared libraries for testing.
+# Build shared libraries for testing. The libtool way to create a shared library
+# is to specify "-avoid-version -export-dynamic -module" in the library LDFLAGS
+# (see http://www.gnu.org/software/libtool/manual/html_node/Link-mode.html).
+# Use of these switches will guarantee that the .so files are created in the
+# .libs folder and they can be dlopened.
+# Note that the shared libraries with callouts should not be used together with
+# the --enable-static-link option. With this option, the bind10 libraries are
+# statically linked with the program and if the callout invokes the methods
+# which belong to these libraries, the library with the callout will get its
+# own copy of the static objects (e.g. logger, ServerHooks) and that will lead
+# to unexpected errors. For this reason, the --enable-static-link option is
+# ignored for unit tests built here.
+
 lib_LTLIBRARIES = libnvl.la libivl.la libfxl.la libbcl.la liblcl.la liblecl.la \
                   libucl.la libfcl.la
 
@@ -30,43 +42,53 @@ lib_LTLIBRARIES = libnvl.la libivl.la libfxl.la libbcl.la liblcl.la liblecl.la \
 libnvl_la_SOURCES  = no_version_library.cc
 libnvl_la_CXXFLAGS = $(AM_CXXFLAGS)
 libnvl_la_CPPFLAGS = $(AM_CPPFLAGS) $(LOG4CPLUS_INCLUDES)
+libnvl_la_LDFLAGS = -avoid-version -export-dynamic -module
 
 # Incorrect version function
 libivl_la_SOURCES  = incorrect_version_library.cc
 libivl_la_CXXFLAGS = $(AM_CXXFLAGS)
 libivl_la_CPPFLAGS = $(AM_CPPFLAGS) $(LOG4CPLUS_INCLUDES)
+libivl_la_LDFLAGS = -avoid-version -export-dynamic -module
 
 # All framework functions throw an exception
 libfxl_la_SOURCES = framework_exception_library.cc
 libfxl_la_CXXFLAGS = $(AM_CXXFLAGS)
 libfxl_la_CPPFLAGS = $(AM_CPPFLAGS) $(LOG4CPLUS_INCLUDES)
+libfxl_la_LDFLAGS = -avoid-version -export-dynamic -module
 
 # The basic callout library - contains standard callouts
 libbcl_la_SOURCES  = basic_callout_library.cc
 libbcl_la_CXXFLAGS = $(AM_CXXFLAGS)
 libbcl_la_CPPFLAGS = $(AM_CPPFLAGS) $(LOG4CPLUS_INCLUDES)
+libbcl_la_LDFLAGS = -avoid-version -export-dynamic -module
 
 # The load callout library - contains a load function
 liblcl_la_SOURCES  = load_callout_library.cc
 liblcl_la_CXXFLAGS = $(AM_CXXFLAGS)
 liblcl_la_CPPFLAGS = $(AM_CPPFLAGS) $(LOG4CPLUS_INCLUDES)
+liblcl_la_LDFLAGS = -avoid-version -export-dynamic -module
 
 # The load error callout library - contains a load function that returns
 # an error.
 liblecl_la_SOURCES  = load_error_callout_library.cc
 liblecl_la_CXXFLAGS = $(AM_CXXFLAGS)
 liblecl_la_CPPFLAGS = $(AM_CPPFLAGS) $(LOG4CPLUS_INCLUDES)
+liblecl_la_LDFLAGS = -avoid-version -export-dynamic -module
 
 # The unload callout library - contains an unload function that
 # creates a marker file.
 libucl_la_SOURCES  = unload_callout_library.cc
 libucl_la_CXXFLAGS = $(AM_CXXFLAGS)
 libucl_la_CPPFLAGS = $(AM_CPPFLAGS) $(LOG4CPLUS_INCLUDES)
+libucl_la_LDFLAGS = -avoid-version -export-dynamic -module
 
 # The full callout library - contains all three framework functions.
 libfcl_la_SOURCES  = full_callout_library.cc
 libfcl_la_CXXFLAGS = $(AM_CXXFLAGS)
 libfcl_la_CPPFLAGS = $(AM_CPPFLAGS) $(LOG4CPLUS_INCLUDES)
+libfcl_la_LDFLAGS = -avoid-version -export-dynamic -module -Bstatic $(top_builddir)/src/lib/exceptions/libb10-exceptions.la -Bstatic $(top_builddir)/src/lib/hooks/libb10-hooks.la
+libfcl_la_LIBADD  = $(top_builddir)/src/lib/exceptions/libb10-exceptions.la
+libfcl_la_LIBADD += $(top_builddir)/src/lib/hooks/libb10-hooks.la
 
 TESTS += run_unittests
 run_unittests_SOURCES  = run_unittests.cc
@@ -83,12 +105,8 @@ nodist_run_unittests_SOURCES  = marker_file.h
 nodist_run_unittests_SOURCES += test_libraries.h
 
 run_unittests_CPPFLAGS = $(AM_CPPFLAGS) $(GTEST_INCLUDES)
+
 run_unittests_LDFLAGS  = $(AM_LDFLAGS)  $(GTEST_LDFLAGS)
-if USE_STATIC_LINK
-# If specified, only link unit tests static - the test libraries must be
-# build as shared libraries.
-run_unittests_LDFLAGS  += -static
-endif
 
 run_unittests_LDADD    = $(AM_LDADD)    $(GTEST_LDADD)
 
index bb6a24a33d63f97caf6b15d5e3657a3259ffd45a..7b5e0e4554a2ca8016c5d568c5d442bf3421d073 100644 (file)
 
 namespace {
 
-
-// Take care of differences in DLL naming between operating systems.
-
-#ifdef OS_OSX
-#define DLL_SUFFIX ".dylib"
-
-#else
-#define DLL_SUFFIX ".so"
-
-#endif
-
-
 // Names of the libraries used in these tests.  These libraries are built using
 // libtool, so we need to look in the hidden ".libs" directory to locate the
 // .so file.  Note that we access the .so file - libtool creates this as a
 // like to the real shared library.
 
 // Basic library with context_create and three "standard" callouts.
-static const char* BASIC_CALLOUT_LIBRARY = "@abs_builddir@/.libs/libbcl"
-                                           DLL_SUFFIX;
+static const char* BASIC_CALLOUT_LIBRARY = "@abs_builddir@/.libs/libbcl.so";
 
 // Library with context_create and three "standard" callouts, as well as
 // load() and unload() functions.
-static const char* FULL_CALLOUT_LIBRARY = "@abs_builddir@/.libs/libfcl"
-                                          DLL_SUFFIX;
+static const char* FULL_CALLOUT_LIBRARY = "@abs_builddir@/.libs/libfcl.so";
 
 // Library where the all framework functions throw an exception
-static const char* FRAMEWORK_EXCEPTION_LIBRARY = "@abs_builddir@/.libs/libfxl"
-                                                 DLL_SUFFIX;
+static const char* FRAMEWORK_EXCEPTION_LIBRARY = "@abs_builddir@/.libs/libfxl.so";
 
 // Library where the version() function returns an incorrect result.
-static const char* INCORRECT_VERSION_LIBRARY = "@abs_builddir@/.libs/libivl"
-                                               DLL_SUFFIX;
+static const char* INCORRECT_VERSION_LIBRARY = "@abs_builddir@/.libs/libivl.so";
 
 // Library where some of the callout registration is done with the load()
 // function.
-static const char* LOAD_CALLOUT_LIBRARY = "@abs_builddir@/.libs/liblcl"
-                                          DLL_SUFFIX;
+static const char* LOAD_CALLOUT_LIBRARY = "@abs_builddir@/.libs/liblcl.so";
 
 // Library where the load() function returns an error.
 static const char* LOAD_ERROR_CALLOUT_LIBRARY =
-    "@abs_builddir@/.libs/liblecl" DLL_SUFFIX;
+    "@abs_builddir@/.libs/liblecl.so";
 
 // Name of a library which is not present.
-static const char* NOT_PRESENT_LIBRARY = "@abs_builddir@/.libs/libnothere"
-                                         DLL_SUFFIX;
+static const char* NOT_PRESENT_LIBRARY = "@abs_builddir@/.libs/libnothere.so";
 
 // Library that does not include a version function.
-static const char* NO_VERSION_LIBRARY = "@abs_builddir@/.libs/libnvl"
-                                        DLL_SUFFIX;
+static const char* NO_VERSION_LIBRARY = "@abs_builddir@/.libs/libnvl.so";
 
 // Library where there is an unload() function.
-static const char* UNLOAD_CALLOUT_LIBRARY = "@abs_builddir@/.libs/libucl"
-                                            DLL_SUFFIX;
+static const char* UNLOAD_CALLOUT_LIBRARY = "@abs_builddir@/.libs/libucl.so";
+
 } // anonymous namespace
 
 
index 0016684d851e41c56629ee36730f7116224c184b..21e69c4c08fcadcf049375d15185e52bd228151e 100644 (file)
@@ -35,6 +35,7 @@ libb10_resolve_la_LIBADD = $(top_builddir)/src/lib/dns/libb10-dns++.la
 libb10_resolve_la_LIBADD += $(top_builddir)/src/lib/exceptions/libb10-exceptions.la
 libb10_resolve_la_LIBADD += $(top_builddir)/src/lib/log/libb10-log.la
 libb10_resolve_la_LIBADD += $(top_builddir)/src/lib/asiodns/libb10-asiodns.la
+libb10_resolve_la_LIBADD += $(top_builddir)/src/lib/nsas/libb10-nsas.la
 
 # The message file should be in the distribution.
 EXTRA_DIST = resolve_messages.mes
index 2281b6d7003da70ffd188e6b2b815b91c53a1e4c..574cc7852030ce27e63eadf03338f68067bd4d18 100644 (file)
@@ -11,7 +11,8 @@ libb10_testutils_la_SOURCES = srv_test.h srv_test.cc
 libb10_testutils_la_SOURCES += dnsmessage_test.h dnsmessage_test.cc
 libb10_testutils_la_SOURCES += mockups.h
 libb10_testutils_la_CPPFLAGS = $(AM_CPPFLAGS) $(GTEST_INCLUDES)
-libb10_testutils_la_LIBADD = $(top_builddir)/src/lib/asiolink/libb10-asiolink.la
+libb10_testutils_la_LIBADD  = $(top_builddir)/src/lib/asiolink/libb10-asiolink.la
+libb10_testutils_la_LIBADD += $(top_builddir)/src/lib/dns/libb10-dns++.la
 endif
 
 EXTRA_DIST = portconfig.h socket_request.h