1 From bc1d8ca01415710d40224de312c7ecf6f4223301 Mon Sep 17 00:00:00 2001
2 From: Philippe Proulx <eeppeliteloop@gmail.com>
3 Date: Mon, 6 Nov 2017 18:46:41 -0500
4 Subject: [PATCH] Fix: detect dlmopen() and disable corresponding tests if not
7 Content-Type: text/plain; charset=UTF-8
8 Content-Transfer-Encoding: 8bit
10 musl and uClibc-ng are known not to support dlmopen(). LTTng-UST has
11 this dlmopen() detection.
13 Signed-off-by: Philippe Proulx <eeppeliteloop@gmail.com>
14 [Philippe: backport from upstream commit bc1d8ca0
15 edited to remove .gitignore part]
16 Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
19 configure.ac | 25 ++++++++++++++++++++++
20 tests/regression/ust/ust-dl/prog.c | 17 +++++++++++++--
21 tests/regression/ust/ust-dl/test_ust-dl | 32 ----------------------------
22 tests/regression/ust/ust-dl/test_ust-dl.in | 34 ++++++++++++++++++++++++++++++
23 tests/regression/ust/ust-dl/test_ust-dl.py | 9 +++++++-
24 tests/utils/test_utils.py | 3 +++
25 7 files changed, 86 insertions(+), 35 deletions(-)
26 delete mode 100755 tests/regression/ust/ust-dl/test_ust-dl
27 create mode 100644 tests/regression/ust/ust-dl/test_ust-dl.in
29 diff --git a/configure.ac b/configure.ac
30 index 016c56ec..b6ea39c5 100644
33 @@ -196,6 +196,30 @@ AC_CHECK_FUNCS([ \
35 AC_CHECK_LIB([rt], [clock_gettime, timer_create, timer_settime, timer_delete])
38 +AC_CHECK_LIB([dl], [dlopen], [
42 + # libdl not found, check for dlopen in libc.
43 + AC_CHECK_LIB([c], [dlopen], [
47 + AC_MSG_ERROR([Cannot find dlopen in libdl nor libc. Use [LDFLAGS]=-Ldir to specify their location.])
51 +# Check if libdl has dlmopen support.
52 +AH_TEMPLATE([HAVE_DLMOPEN], ["Define to 1 if dlmopen is available."])
53 +AC_CHECK_LIB([$libdl_name], [dlmopen], [
54 + AC_DEFINE([HAVE_DLMOPEN], [1])
59 +AC_SUBST(HAVE_DLMOPEN)
61 # Babeltrace viewer check
62 AC_ARG_WITH([babeltrace-bin],
63 AS_HELP_STRING([--with-babeltrace-bin],
64 @@ -1100,6 +1124,7 @@ AC_CONFIG_FILES([
65 AC_CONFIG_FILES([tests/regression/ust/python-logging/test_python_logging],[chmod +x tests/regression/ust/python-logging/test_python_logging])
66 # Inject LTTNG_TOOLS_BUILD_WITH_LIBPFM variable in test script.
67 AC_CONFIG_FILES([tests/perf/test_perf_raw],[chmod +x tests/perf/test_perf_raw])
68 +AC_CONFIG_FILES([tests/regression/ust/ust-dl/test_ust-dl],[chmod +x tests/regression/ust/ust-dl/test_ust-dl])
72 diff --git a/tests/regression/ust/ust-dl/prog.c b/tests/regression/ust/ust-dl/prog.c
73 index e8e4b264..669792d9 100644
74 --- a/tests/regression/ust/ust-dl/prog.c
75 +++ b/tests/regression/ust/ust-dl/prog.c
78 int main(int argc, char **argv)
80 - void *h0, *h1, *h2, *h3, *h4;
81 + void *h0, *h2, *h3, *h4;
90 @@ -21,10 +26,14 @@ int main(int argc, char **argv)
96 h1 = dlmopen(LM_ID_BASE, "libfoo.so", RTLD_LAZY);
102 h2 = dlopen("libzzz.so", RTLD_LAZY);
105 @@ -38,7 +47,7 @@ int main(int argc, char **argv)
109 - foo = dlsym(h1, "foo");
110 + foo = dlsym(h3, "foo");
114 @@ -49,9 +58,13 @@ int main(int argc, char **argv)
128 diff --git a/tests/regression/ust/ust-dl/test_ust-dl b/tests/regression/ust/ust-dl/test_ust-dl
129 deleted file mode 100755
130 index 1f2934db..00000000
131 --- a/tests/regression/ust/ust-dl/test_ust-dl
136 -# Copyright (C) - 2013 Jérémie Galarneau <jeremie.galarneau@efficios.com>
138 -# This program is free software; you can redistribute it and/or modify it
139 -# under the terms of the GNU General Public License, version 2 only, as
140 -# published by the Free Software Foundation.
142 -# This program is distributed in the hope that it will be useful, but WITHOUT
143 -# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
144 -# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
147 -# You should have received a copy of the GNU General Public License along with
148 -# this program; if not, write to the Free Software Foundation, Inc., 51
149 -# Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
151 -CURDIR=$(dirname $0)
152 -TESTDIR=${CURDIR}/../../..
154 -source $TESTDIR/utils/utils.sh
156 -if [ ! -x "$CURDIR/.libs/libfoo.so" ]; then
157 - diag "No shared object generated. Skipping all tests."
161 -start_lttng_sessiond_notap
163 -python3 ${CURDIR}/test_ust-dl.py
165 -stop_lttng_sessiond_notap
166 diff --git a/tests/regression/ust/ust-dl/test_ust-dl.in b/tests/regression/ust/ust-dl/test_ust-dl.in
168 index 00000000..61d00d21
170 +++ b/tests/regression/ust/ust-dl/test_ust-dl.in
174 +# Copyright (C) - 2013 Jérémie Galarneau <jeremie.galarneau@efficios.com>
176 +# This program is free software; you can redistribute it and/or modify it
177 +# under the terms of the GNU General Public License, version 2 only, as
178 +# published by the Free Software Foundation.
180 +# This program is distributed in the hope that it will be useful, but WITHOUT
181 +# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
182 +# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
185 +# You should have received a copy of the GNU General Public License along with
186 +# this program; if not, write to the Free Software Foundation, Inc., 51
187 +# Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
189 +CURDIR=$(dirname $0)
190 +TESTDIR=${CURDIR}/../../..
192 +source $TESTDIR/utils/utils.sh
194 +if [ ! -x "$CURDIR/.libs/libfoo.so" ]; then
195 + diag "No shared object generated. Skipping all tests."
199 +export LTTNG_TOOLS_HAVE_DLMOPEN=@HAVE_DLMOPEN@
201 +start_lttng_sessiond_notap
203 +python3 ${CURDIR}/test_ust-dl.py
205 +stop_lttng_sessiond_notap
206 diff --git a/tests/regression/ust/ust-dl/test_ust-dl.py b/tests/regression/ust/ust-dl/test_ust-dl.py
207 index 81972a7d..72459840 100644
208 --- a/tests/regression/ust/ust-dl/test_ust-dl.py
209 +++ b/tests/regression/ust/ust-dl/test_ust-dl.py
210 @@ -31,6 +31,9 @@ sys.path.append(test_utils_path)
211 from test_utils import *
214 +have_dlmopen = (os.environ.get('LTTNG_TOOLS_HAVE_DLMOPEN') == '1')
219 print("1..{0}".format(NR_TESTS))
220 @@ -113,7 +116,11 @@ current_test += 1
221 print_test_result(dlopen_event_found > 0, current_test, "lttng_ust_dl:dlopen event found in resulting trace")
224 -print_test_result(dlmopen_event_found > 0, current_test, "lttng_ust_dl:dlmopen event found in resulting trace")
226 + print_test_result(dlmopen_event_found > 0, current_test, "lttng_ust_dl:dlmopen event found in resulting trace")
228 + skip_test(current_test, 'dlmopen() is not available')
232 print_test_result(build_id_event_found > 0, current_test, "lttng_ust_dl:build_id event found in resulting trace")
233 diff --git a/tests/utils/test_utils.py b/tests/utils/test_utils.py
234 index 4b38630c..02e632a2 100644
235 --- a/tests/utils/test_utils.py
236 +++ b/tests/utils/test_utils.py
237 @@ -62,6 +62,9 @@ def print_test_result(result, number, description):
238 result_string += " {0} - {1}".format(number, description)
241 +def skip_test(number, description):
242 + print('ok {} # skip {}'.format(number, description))
244 def enable_ust_tracepoint_event(session_info, event_name):
246 event.name = event_name