[SSSD] [PATCH] Check our libraries properly resolve symbols
Lukas Slebodnik
lslebodn at redhat.com
Sat Sep 7 09:42:19 UTC 2013
On (06/09/13 17:13), Simo Sorce wrote:
>On Fri, 2013-09-06 at 15:27 +0200, Lukas Slebodnik wrote:
>> This version works well.
>>
>> I tried to remove some files from library:
>> diff
>> ------------------
>> @@ -1366,7 +1366,6 @@ endif
>>
>> nsslib_LTLIBRARIES = libnss_sss.la
>> libnss_sss_la_SOURCES = \
>> - src/sss_client/common.c \
>> src/sss_client/nss_passwd.c \
>> src/sss_client/nss_group.c \
>> src/sss_client/nss_netgroup.c \
>>
>> And test failed.
>> Running suite(s): dlopen
>> 0%: Checks: 1, Failures: 1, Errors: 0
>> ../sssd/src/tests/dlopen-tests.c:74:F:dlopen:test_dlopen_base:0:
>> dlopen() failed for ./.libs/libnss_sss.so:
>> [./.libs/libnss_sss.so: undefined symbol: sss_nss_lock]
>>
>>
>> Then I tried to remove another file.
>>
>> @@ -1374,8 +1374,6 @@ libnss_sss_la_SOURCES = \
>> src/sss_client/sss_cli.h \
>> src/sss_client/nss_compat.h \
>> src/sss_client/nss_mc_common.c \
>> - src/util/io.c \
>> src/util/murmurhash3.c \
>> src/sss_client/nss_mc_passwd.c \
>> src/sss_client/nss_mc_group.c \
>> src/sss_client/nss_mc.h
>>
>> And test did not fail. I don't know why, because this missing file
>> caused crash in past. https://fedorahosted.org/sssd/ticket/1838
>>
>
>Ok the reason why the second issue was not caught is that in the
>original patch I had to link in a bunch of binaries for the provider
>module case, and those contained the symbol you tried to test.
>
>I have a new patch attached, that spins off the symbols needed by the
>provider modules in their own .so library, so that we load the library
>only when testing the provider modules but not for other libraries.
>
>Now libnss_sss.so fails the dlopen-tests when the io.c file is omitted.
>
>2 points on the new code:
>* I had to add libdlopen_test_providers to lib_LTLIBRARY instead of
>noinst_LTLIBRARY or check_LTLIBRARY because with these last 2 targets
>libtool never builds .so files :-/
>Therefore I had to add an intsall-exec-hook to remove
>libdlopen_test_providers.so file at install time, as we use it only for
>testing.
I found a way how to build dynamic library with check_LTLIBRARY.
comments inline
>
>* I am not sure why libsss_child.so, libsss_crypt.so, libsss_util.so
>need some libraries to be explicitly loaded instead of having them
>encoded as their dependencies, might be a bug in our makefile. If it is
>I think we should still commit this patch as is and then open a bug to
>resolve the issue and adjust the test in the same commit the resolve the
>issue.
It was a problem to build sssd on ubuntu with dynamic libraries.
https://lists.fedorahosted.org/pipermail/sssd-devel/2013-May/015053.html
Problem was with link_all_deplibs="no" on debian/ubuntu.
Here is an explanation:
https://lists.fedorahosted.org/pipermail/sssd-devel/2013-May/015053.html
>
>Simo.
>
>--
>Simo Sorce * Red Hat, Inc * New York
>From be6d1c97c36dd9345358e270ffb00dc89640e288 Mon Sep 17 00:00:00 2001
>From: Simo Sorce <simo at redhat.com>
>Date: Thu, 5 Sep 2013 11:52:08 -0400
>Subject: [PATCH] tests: Add dlopen test to make sure modules works
>
>This tests dlopens and resolves all symbols to make sure there are no missing
>symbols in our provider modules.
>---
> Makefile.am | 35 +++++++++++
> src/tests/dlopen-tests.c | 147 +++++++++++++++++++++++++++++++++++++++++++++++
> 2 files changed, 182 insertions(+)
> create mode 100644 src/tests/dlopen-tests.c
>
>diff --git a/Makefile.am b/Makefile.am
>index b913a12b895d68f1f3e23c185e493e576641d0e2..4d32b174264fb5c61fddd18e13263fe20e045b1f 100644
>--- a/Makefile.am
>+++ b/Makefile.am
>@@ -114,6 +114,7 @@ endif
>
> if HAVE_CHECK
> non_interactive_check_based_tests = \
>+ dlopen-tests \
> sysdb-tests \
> strtonum-tests \
> resolv-tests \
>@@ -886,6 +887,39 @@ if HAVE_CHECK
> libsss_test_common_la_SOURCES += \
> src/tests/common_check.c
>
>+lib_LTLIBRARIES += \
>+ libdlopen_test_providers.la
Please use "check_LTLIBRARIES = \"
>+
>+libdlopen_test_providers_la_DEPENDENCIES = \
>+ $(ldblib_LTLIBRARIES) \
>+ $(SSSD_INTERNAL_LTLIBS)
^^^^^
These lines can be removed with check_LTLIBRARIES =
>+libdlopen_test_providers_la_SOURCES = \
>+ $(sssd_be_SOURCES)
>+libdlopen_test_providers_la_CFLAGS = \
>+ $(AM_CFLAGS) \
>+ $(CHECK_CFLAGS) \
>+ -DUNIT_TESTING
>+libdlopen_test_providers_la_LIBADD = \
>+ $(PAM_LIBS) \
>+ $(SSSD_LIBS) \
>+ $(CARES_LIBS) \
>+ $(SSSD_INTERNAL_LTLIBS)
>+libdlopen_test_providers_la_LDFLAGS = \
>+ -module \
>+ -avoid-version \
>+ -Wl,--version-script,$(srcdir)/src/providers/sssd_be.exports \
add "-rpath $(abs_builddir) \"
libdlopen_test_providers will be dynamic library with this line.
>+ -export-dynamic
>+
>+dlopen_tests_SOURCES = \
>+ src/tests/dlopen-tests.c
>+dlopen_tests_CFLAGS = \
>+ $(AM_CFLAGS) \
>+ $(CHECK_CFLAGS) \
>+ -DDLOPEN_TESTS_BUILDDIR=\"$(builddir)\"
>+dlopen_tests_LDADD = \
>+ -ldl \
>+ $(CHECK_LIBS)
>+
> sysdb_tests_DEPENDENCIES = \
> $(ldblib_LTLIBRARIES)
> sysdb_tests_SOURCES = \
>@@ -1911,6 +1945,7 @@ if BUILD_PYTHON_BINDINGS
> endif
>
> install-exec-hook: installsssddirs
>+ rm -f $(DESTDIR)$(libdir)/libdlopen_test_providers.*
^^^^^^^^
This like can be removed.
> if BUILD_PYTHON_BINDINGS
> if [ "$(DESTDIR)" = "" ]; then \
> cd $(builddir)/src/config; $(PYTHON) setup.py build --build-base $(abs_builddir)/src/config install $(DISTSETUPOPTS) --prefix=$(PYTHON_PREFIX) --record=$(abs_builddir)/src/config/.files; \
>diff --git a/src/tests/dlopen-tests.c b/src/tests/dlopen-tests.c
>new file mode 100644
>index 0000000000000000000000000000000000000000..5d4e77df74cb80dcdebd7b4b34a594d1f6a66de7
>--- /dev/null
>+++ b/src/tests/dlopen-tests.c
>@@ -0,0 +1,147 @@
>+/*
>+ SSSD
>+
>+ debug-tests.c
>+
>+ Authors:
>+ Simo Sorce <simo at redhat.com>
>+
>+ Copyright (C) 2013 Red Hat
>+
>+ This program is free software; you can redistribute it and/or modify
>+ it under the terms of the GNU General Public License as published by
>+ the Free Software Foundation; either version 3 of the License, or
>+ (at your option) any later version.
>+
>+ This program is distributed in the hope that it will be useful,
>+ but WITHOUT ANY WARRANTY; without even the implied warranty of
>+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
>+ GNU General Public License for more details.
>+
>+ You should have received a copy of the GNU General Public License
>+ along with this program. If not, see <http://www.gnu.org/licenses/>.
>+*/
>+
>+#define _GNU_SOURCE
>+#include <stdbool.h>
>+#include <dlfcn.h>
>+#include <stdio.h>
>+#include <stdlib.h>
>+#include <limits.h>
>+#include <check.h>
>+#include "tests/common.h"
>+
>+#define LIBPFX DLOPEN_TESTS_BUILDDIR"/.libs/"
>+
>+struct so {
>+ const char *name;
>+ const char *libs[6];
>+} so[] = {
>+ { "libsss_debug.so", { LIBPFX"libsss_debug.so", NULL } },
>+ { "libsss_sudo.so", { LIBPFX"libsss_sudo.so", NULL } },
>+ { "libipa_hbac.so", { LIBPFX"libipa_hbac.so", NULL } },
>+ { "libsss_autofs.so", { LIBPFX"libsss_autofs.so", NULL } },
>+ { "libsss_idmap.so", { LIBPFX"libsss_idmap.so", NULL } },
>+ { "libsss_nss_idmap.so", { LIBPFX"libsss_nss_idmap.so", NULL } },
>+ { "libnss_sss.so", { LIBPFX"libnss_sss.so", NULL } },
>+ { "pam_sss.so", { LIBPFX"pam_sss.so", NULL } },
>+ { "sssd_pac_plugin.so", { LIBPFX"sssd_pac_plugin.so", NULL } },
>+ { "sssd_krb5_locator_plugin.so", { LIBPFX"sssd_krb5_locator_plugin.so",
>+ NULL } },
>+ { "memberof.so", { LIBPFX"memberof.so", NULL } },
>+ { "pyhbac.so", { LIBPFX"pyhbac.so", NULL } },
>+ { "pysss_nss_idmap.so", { LIBPFX"pysss_nss_idmap.so", NULL } },
{ "pysss_murmur.so", { LIBPFX"pysss_murmur.so", NULL } },
{ "pysss.so", { LIBPFX"pysss.so", NULL } },
I missed these libraries.
Thank you very much for this test.
LS
More information about the sssd-devel
mailing list