Fix: detect dlmopen() and disable corresponding tests if not available
authorPhilippe Proulx <eeppeliteloop@gmail.com>
Mon, 6 Nov 2017 23:46:41 +0000 (18:46 -0500)
committerJérémie Galarneau <jeremie.galarneau@efficios.com>
Mon, 13 Nov 2017 15:27:18 +0000 (10:27 -0500)
musl and uClibc-ng are known not to support dlmopen(). LTTng-UST has
this dlmopen() detection.

Signed-off-by: Philippe Proulx <eeppeliteloop@gmail.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
.gitignore
configure.ac
tests/regression/ust/ust-dl/prog.c
tests/regression/ust/ust-dl/test_ust-dl [deleted file]
tests/regression/ust/ust-dl/test_ust-dl.in [new file with mode: 0644]
tests/regression/ust/ust-dl/test_ust-dl.py
tests/utils/test_utils.py

index 1f748c3c209a8e777dfb79cb69568801ee38cdde..c9927d248f75f6b5203215bc972724c9e3107de7 100644 (file)
@@ -108,6 +108,7 @@ health_check
 /tests/regression/ust/ust-dl/libfoo.so.debug
 /tests/regression/ust/ust-dl/libbar.so.debug
 /tests/regression/ust/ust-dl/libzzz.so.debug
+/tests/regression/ust/ust-dl/test_ust-dl
 /tests/utils/testapp/gen-ust-nevents/gen-ust-nevents
 /tests/utils/testapp/gen-ust-tracef/gen-ust-tracef
 /tests/regression/tools/live/live_test
index 016c56ece4d97ab5b07a2eb920132922ae82666b..b6ea39c559ef91c81558ca99fb827a32091cd4e1 100644 (file)
@@ -196,6 +196,30 @@ AC_CHECK_FUNCS([ \
 # add -lrt to LIBS
 AC_CHECK_LIB([rt], [clock_gettime, timer_create, timer_settime, timer_delete])
 
+# Checks for dl.
+AC_CHECK_LIB([dl], [dlopen], [
+       have_libdl=yes
+       libdl_name=dl
+], [
+       # libdl not found, check for dlopen in libc.
+       AC_CHECK_LIB([c], [dlopen], [
+               have_libc_dl=yes
+               libdl_name=c
+       ], [
+               AC_MSG_ERROR([Cannot find dlopen in libdl nor libc. Use [LDFLAGS]=-Ldir to specify their location.])
+       ])
+])
+
+# Check if libdl has dlmopen support.
+AH_TEMPLATE([HAVE_DLMOPEN], ["Define to 1 if dlmopen is available."])
+AC_CHECK_LIB([$libdl_name], [dlmopen], [
+       AC_DEFINE([HAVE_DLMOPEN], [1])
+       HAVE_DLMOPEN=1
+], [
+       HAVE_DLMOPEN=0
+])
+AC_SUBST(HAVE_DLMOPEN)
+
 # Babeltrace viewer check
 AC_ARG_WITH([babeltrace-bin],
        AS_HELP_STRING([--with-babeltrace-bin],
@@ -1100,6 +1124,7 @@ AC_CONFIG_FILES([
 AC_CONFIG_FILES([tests/regression/ust/python-logging/test_python_logging],[chmod +x tests/regression/ust/python-logging/test_python_logging])
 # Inject LTTNG_TOOLS_BUILD_WITH_LIBPFM variable in test script.
 AC_CONFIG_FILES([tests/perf/test_perf_raw],[chmod +x tests/perf/test_perf_raw])
+AC_CONFIG_FILES([tests/regression/ust/ust-dl/test_ust-dl],[chmod +x tests/regression/ust/ust-dl/test_ust-dl])
 
 AC_OUTPUT
 
index e8e4b2641a1c6a0437c0e94ca6933eda741e30fc..669792d9d97a7c0158886052279d4a4e5e724dfd 100644 (file)
  */
 int main(int argc, char **argv)
 {
-       void *h0, *h1, *h2, *h3, *h4;
+       void *h0, *h2, *h3, *h4;
+
+#ifdef HAVE_DLMOPEN
+       void *h1;
+#endif
+
        char *error;
        int (*foo)(void);
 
@@ -21,10 +26,14 @@ int main(int argc, char **argv)
        if (!h0) {
                goto get_error;
        }
+
+#ifdef HAVE_DLMOPEN
        h1 = dlmopen(LM_ID_BASE, "libfoo.so", RTLD_LAZY);
        if (!h1) {
                goto get_error;
        }
+#endif
+
        h2 = dlopen("libzzz.so", RTLD_LAZY);
        if (!h2) {
                goto get_error;
@@ -38,7 +47,7 @@ int main(int argc, char **argv)
                goto get_error;
        }
 
-       foo = dlsym(h1, "foo");
+       foo = dlsym(h3, "foo");
        error = dlerror();
        if (error != NULL) {
                goto error;
@@ -49,9 +58,13 @@ int main(int argc, char **argv)
        if (dlclose(h0)) {
                goto get_error;
        }
+
+#ifdef HAVE_DLMOPEN
        if (dlclose(h1)) {
                goto get_error;
        }
+#endif
+
        if (dlclose(h2)) {
                goto get_error;
        }
diff --git a/tests/regression/ust/ust-dl/test_ust-dl b/tests/regression/ust/ust-dl/test_ust-dl
deleted file mode 100755 (executable)
index 1f2934d..0000000
+++ /dev/null
@@ -1,32 +0,0 @@
-#!/bin/bash
-#
-# Copyright (C) - 2013 Jérémie Galarneau <jeremie.galarneau@efficios.com>
-#
-# This program is free software; you can redistribute it and/or modify it
-# under the terms of the GNU General Public License, version 2 only, as
-# published by the Free Software Foundation.
-#
-# 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, write to the Free Software Foundation, Inc., 51
-# Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
-
-CURDIR=$(dirname $0)
-TESTDIR=${CURDIR}/../../..
-
-source $TESTDIR/utils/utils.sh
-
-if [ ! -x "$CURDIR/.libs/libfoo.so" ]; then
-       diag "No shared object generated. Skipping all tests."
-       exit 0
-fi
-
-start_lttng_sessiond_notap
-
-python3 ${CURDIR}/test_ust-dl.py
-
-stop_lttng_sessiond_notap
diff --git a/tests/regression/ust/ust-dl/test_ust-dl.in b/tests/regression/ust/ust-dl/test_ust-dl.in
new file mode 100644 (file)
index 0000000..61d00d2
--- /dev/null
@@ -0,0 +1,34 @@
+#!/bin/bash
+#
+# Copyright (C) - 2013 Jérémie Galarneau <jeremie.galarneau@efficios.com>
+#
+# This program is free software; you can redistribute it and/or modify it
+# under the terms of the GNU General Public License, version 2 only, as
+# published by the Free Software Foundation.
+#
+# 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, write to the Free Software Foundation, Inc., 51
+# Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+
+CURDIR=$(dirname $0)
+TESTDIR=${CURDIR}/../../..
+
+source $TESTDIR/utils/utils.sh
+
+if [ ! -x "$CURDIR/.libs/libfoo.so" ]; then
+       diag "No shared object generated. Skipping all tests."
+       exit 0
+fi
+
+export LTTNG_TOOLS_HAVE_DLMOPEN=@HAVE_DLMOPEN@
+
+start_lttng_sessiond_notap
+
+python3 ${CURDIR}/test_ust-dl.py
+
+stop_lttng_sessiond_notap
index 81972a7db90e8ce57ffc6dd35e38a32188fd8e90..724598404ee6b40c63b91f22f716724733e019ae 100644 (file)
@@ -31,6 +31,9 @@ sys.path.append(test_utils_path)
 from test_utils import *
 
 
+have_dlmopen = (os.environ.get('LTTNG_TOOLS_HAVE_DLMOPEN') == '1')
+
+
 NR_TESTS = 14
 current_test = 1
 print("1..{0}".format(NR_TESTS))
@@ -113,7 +116,11 @@ current_test += 1
 print_test_result(dlopen_event_found > 0, current_test, "lttng_ust_dl:dlopen event found in resulting trace")
 current_test += 1
 
-print_test_result(dlmopen_event_found > 0, current_test, "lttng_ust_dl:dlmopen event found in resulting trace")
+if have_dlmopen:
+    print_test_result(dlmopen_event_found > 0, current_test, "lttng_ust_dl:dlmopen event found in resulting trace")
+else:
+    skip_test(current_test, 'dlmopen() is not available')
+
 current_test += 1
 
 print_test_result(build_id_event_found > 0, current_test, "lttng_ust_dl:build_id event found in resulting trace")
index 4b38630c7710652a0782b2f3f8831d95a564c0b5..02e632a26289fa24e7246abdbae481cf3b17c617 100644 (file)
@@ -62,6 +62,9 @@ def print_test_result(result, number, description):
     result_string += " {0} - {1}".format(number, description)
     print(result_string)
 
+def skip_test(number, description):
+    print('ok {} # skip {}'.format(number, description))
+
 def enable_ust_tracepoint_event(session_info, event_name):
     event = Event()
     event.name = event_name
This page took 0.033167 seconds and 5 git commands to generate.