]> rtime.felk.cvut.cz Git - coffee/buildroot.git/blob - package/lttng-tools/0001-Fix-detect-dlmopen-and-disable-corresponding-tests-i.patch
lttng-tools: fix build errors and warnings for musl/uClibc-ng
[coffee/buildroot.git] / package / lttng-tools / 0001-Fix-detect-dlmopen-and-disable-corresponding-tests-i.patch
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
5  available
6 MIME-Version: 1.0
7 Content-Type: text/plain; charset=UTF-8
8 Content-Transfer-Encoding: 8bit
9
10 musl and uClibc-ng are known not to support dlmopen(). LTTng-UST has
11 this dlmopen() detection.
12
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>
17 ---
18  .gitignore                                 |  1 +
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
28
29 diff --git a/configure.ac b/configure.ac
30 index 016c56ec..b6ea39c5 100644
31 --- a/configure.ac
32 +++ b/configure.ac
33 @@ -196,6 +196,30 @@ AC_CHECK_FUNCS([ \
34  # add -lrt to LIBS
35  AC_CHECK_LIB([rt], [clock_gettime, timer_create, timer_settime, timer_delete])
36
37 +# Checks for dl.
38 +AC_CHECK_LIB([dl], [dlopen], [
39 +       have_libdl=yes
40 +       libdl_name=dl
41 +], [
42 +       # libdl not found, check for dlopen in libc.
43 +       AC_CHECK_LIB([c], [dlopen], [
44 +               have_libc_dl=yes
45 +               libdl_name=c
46 +       ], [
47 +               AC_MSG_ERROR([Cannot find dlopen in libdl nor libc. Use [LDFLAGS]=-Ldir to specify their location.])
48 +       ])
49 +])
50 +
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])
55 +       HAVE_DLMOPEN=1
56 +], [
57 +       HAVE_DLMOPEN=0
58 +])
59 +AC_SUBST(HAVE_DLMOPEN)
60 +
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])
69
70  AC_OUTPUT
71
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
76 @@ -13,7 +13,12 @@
77   */
78  int main(int argc, char **argv)
79  {
80 -       void *h0, *h1, *h2, *h3, *h4;
81 +       void *h0, *h2, *h3, *h4;
82 +
83 +#ifdef HAVE_DLMOPEN
84 +       void *h1;
85 +#endif
86 +
87         char *error;
88         int (*foo)(void);
89
90 @@ -21,10 +26,14 @@ int main(int argc, char **argv)
91         if (!h0) {
92                 goto get_error;
93         }
94 +
95 +#ifdef HAVE_DLMOPEN
96         h1 = dlmopen(LM_ID_BASE, "libfoo.so", RTLD_LAZY);
97         if (!h1) {
98                 goto get_error;
99         }
100 +#endif
101 +
102         h2 = dlopen("libzzz.so", RTLD_LAZY);
103         if (!h2) {
104                 goto get_error;
105 @@ -38,7 +47,7 @@ int main(int argc, char **argv)
106                 goto get_error;
107         }
108
109 -       foo = dlsym(h1, "foo");
110 +       foo = dlsym(h3, "foo");
111         error = dlerror();
112         if (error != NULL) {
113                 goto error;
114 @@ -49,9 +58,13 @@ int main(int argc, char **argv)
115         if (dlclose(h0)) {
116                 goto get_error;
117         }
118 +
119 +#ifdef HAVE_DLMOPEN
120         if (dlclose(h1)) {
121                 goto get_error;
122         }
123 +#endif
124 +
125         if (dlclose(h2)) {
126                 goto get_error;
127         }
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
132 +++ /dev/null
133 @@ -1,32 +0,0 @@
134 -#!/bin/bash
135 -#
136 -# Copyright (C) - 2013 Jérémie Galarneau <jeremie.galarneau@efficios.com>
137 -#
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.
141 -#
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
145 -# more details.
146 -#
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.
150 -
151 -CURDIR=$(dirname $0)
152 -TESTDIR=${CURDIR}/../../..
153 -
154 -source $TESTDIR/utils/utils.sh
155 -
156 -if [ ! -x "$CURDIR/.libs/libfoo.so" ]; then
157 -       diag "No shared object generated. Skipping all tests."
158 -       exit 0
159 -fi
160 -
161 -start_lttng_sessiond_notap
162 -
163 -python3 ${CURDIR}/test_ust-dl.py
164 -
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
167 new file mode 100644
168 index 00000000..61d00d21
169 --- /dev/null
170 +++ b/tests/regression/ust/ust-dl/test_ust-dl.in
171 @@ -0,0 +1,34 @@
172 +#!/bin/bash
173 +#
174 +# Copyright (C) - 2013 Jérémie Galarneau <jeremie.galarneau@efficios.com>
175 +#
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.
179 +#
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
183 +# more details.
184 +#
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.
188 +
189 +CURDIR=$(dirname $0)
190 +TESTDIR=${CURDIR}/../../..
191 +
192 +source $TESTDIR/utils/utils.sh
193 +
194 +if [ ! -x "$CURDIR/.libs/libfoo.so" ]; then
195 +       diag "No shared object generated. Skipping all tests."
196 +       exit 0
197 +fi
198 +
199 +export LTTNG_TOOLS_HAVE_DLMOPEN=@HAVE_DLMOPEN@
200 +
201 +start_lttng_sessiond_notap
202 +
203 +python3 ${CURDIR}/test_ust-dl.py
204 +
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 *
212
213
214 +have_dlmopen = (os.environ.get('LTTNG_TOOLS_HAVE_DLMOPEN') == '1')
215 +
216 +
217  NR_TESTS = 14
218  current_test = 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")
222  current_test += 1
223
224 -print_test_result(dlmopen_event_found > 0, current_test, "lttng_ust_dl:dlmopen event found in resulting trace")
225 +if have_dlmopen:
226 +    print_test_result(dlmopen_event_found > 0, current_test, "lttng_ust_dl:dlmopen event found in resulting trace")
227 +else:
228 +    skip_test(current_test, 'dlmopen() is not available')
229 +
230  current_test += 1
231
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)
239      print(result_string)
240
241 +def skip_test(number, description):
242 +    print('ok {} # skip {}'.format(number, description))
243 +
244  def enable_ust_tracepoint_event(session_info, event_name):
245      event = Event()
246      event.name = event_name
247 --
248 2.15.0
249