Commit 38d091be authored by Marcin Siodelski's avatar Marcin Siodelski

[3113] Fix hooks unit test failures when --enable-static-link is used.

parent e66020fd
......@@ -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
......
......@@ -19,32 +19,20 @@
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
......
......@@ -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
......
......@@ -19,32 +19,18 @@
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
......
......@@ -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
......@@ -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
......
......@@ -19,32 +19,18 @@
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
......
......@@ -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)
......
......@@ -19,60 +19,41 @@
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
......
......@@ -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
......
......@@ -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
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment