summaryrefslogtreecommitdiffstats
path: root/meta/recipes-kernel/lttng/lttng-tools
diff options
context:
space:
mode:
authorJonathan Rajotte <jonathan.rajotte-julien@efficios.com>2019-04-04 21:47:40 +0000
committerRichard Purdie <richard.purdie@linuxfoundation.org>2019-04-05 17:32:50 +0100
commit8e9a0fe61f0ccdad8d88ecf8f46ae90c0c73da97 (patch)
tree01d9bf650a0d9b5524eb7eed975a2957db8ff501 /meta/recipes-kernel/lttng/lttng-tools
parentbb1940a0d65660a967b1f126ce3cbd89314d1e3b (diff)
downloadpoky-8e9a0fe61f0ccdad8d88ecf8f46ae90c0c73da97.tar.gz
lttng-tools: improve ptest and test suite
Multiple patches are to be applied to improve the current ptest suite. 0001-Fix-tests-link-libpause_consumer-on-liblttng-ctl.patch 0002-Fix-test-skip-test_getcpu_override-on-single-thread-.patch 0003-Fix-test-unit-the-tree-origin-can-be-a-symlink-itsel.patch 0006-Tests-check-for-lttng-modules-presence.patch All deal with problem in the test suite. Most of these are already accepted upstream and will be removed on the next recipe update. 0004-Skip-when-testapp-is-not-present.patch Is a OE specific fix that make sure that we skip the test if the test util application (event generator) is not present. We are still unsure on how (upstream) we are going to solve this problem. We already have this problem if a user build lttng without lttng-ust (--without-lttng-ust). We will most probably end up splitting each test into kernel and userspace tests and adjust the makefile accordingly. Another option is to probe lttng for enabled function at runtime. 0005-Tests-use-modprobe-to-test-for-the-presence-of-lttng.patch Is a requirement for 0006 that should be accepted upstream shorlty. 0007-Fix-getgrnam-is-not-MT-Safe-use-getgrnam_r.patch Fixes a race found while testing OE built with musl. This is a legit bug. The fixes or a variant should be accepted soon. (From OE-Core rev: 57db7be54b9ee21b2be33b83782f0636d0702168) Signed-off-by: Jonathan Rajotte <jonathan.rajotte-julien@efficios.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'meta/recipes-kernel/lttng/lttng-tools')
-rw-r--r--meta/recipes-kernel/lttng/lttng-tools/0001-Fix-tests-link-libpause_consumer-on-liblttng-ctl.patch35
-rw-r--r--meta/recipes-kernel/lttng/lttng-tools/0002-Fix-test-skip-test_getcpu_override-on-single-thread-.patch52
-rw-r--r--meta/recipes-kernel/lttng/lttng-tools/0003-Fix-test-unit-the-tree-origin-can-be-a-symlink-itsel.patch80
-rw-r--r--meta/recipes-kernel/lttng/lttng-tools/0004-Skip-when-testapp-is-not-present.patch610
-rw-r--r--meta/recipes-kernel/lttng/lttng-tools/0005-Tests-use-modprobe-to-test-for-the-presence-of-lttng.patch176
-rw-r--r--meta/recipes-kernel/lttng/lttng-tools/0006-Tests-check-for-lttng-modules-presence.patch28
-rw-r--r--meta/recipes-kernel/lttng/lttng-tools/0007-Fix-getgrnam-is-not-MT-Safe-use-getgrnam_r.patch345
7 files changed, 1326 insertions, 0 deletions
diff --git a/meta/recipes-kernel/lttng/lttng-tools/0001-Fix-tests-link-libpause_consumer-on-liblttng-ctl.patch b/meta/recipes-kernel/lttng/lttng-tools/0001-Fix-tests-link-libpause_consumer-on-liblttng-ctl.patch
new file mode 100644
index 0000000000..df18dc842b
--- /dev/null
+++ b/meta/recipes-kernel/lttng/lttng-tools/0001-Fix-tests-link-libpause_consumer-on-liblttng-ctl.patch
@@ -0,0 +1,35 @@
1From 7244eac44be929fabd6ed1333f96929ef8da564f Mon Sep 17 00:00:00 2001
2From: Jonathan Rajotte <jonathan.rajotte-julien@efficios.com>
3Date: Tue, 19 Mar 2019 17:56:49 +0000
4Subject: [PATCH] fix: tests: link libpause_consumer on liblttng-ctl
5
6This preload test library uses symbols from liblttng-ctl which are
7resolved when preloaded by GLIBC but not by MUSL.
8
9Upstream-Status: Accepted [f667fbd7f8b9512f9943edb2597c226fcc424ee9]
10Backported to 2.11 and 2.10.
11
12Signed-off-by: Michael Jeanson <mjeanson@efficios.com>
13---
14 tests/regression/tools/notification/Makefile.am | 5 ++++-
15 1 file changed, 4 insertions(+), 1 deletion(-)
16
17diff --git a/tests/regression/tools/notification/Makefile.am b/tests/regression/tools/notification/Makefile.am
18index 41adc69..a352bb8 100644
19--- a/tests/regression/tools/notification/Makefile.am
20+++ b/tests/regression/tools/notification/Makefile.am
21@@ -20,7 +20,10 @@ FORCE_SHARED_LIB_OPTIONS = -module -shared -avoid-version \
22 -rpath $(abs_builddir)
23
24 libpause_consumer_la_SOURCES = consumer_testpoints.c
25-libpause_consumer_la_LIBADD = $(top_builddir)/src/common/libcommon.la $(DL_LIBS)
26+libpause_consumer_la_LIBADD = \
27+ $(top_builddir)/src/common/libcommon.la \
28+ $(top_builddir)/src/lib/lttng-ctl/liblttng-ctl.la \
29+ $(DL_LIBS)
30 libpause_consumer_la_LDFLAGS = $(FORCE_SHARED_LIB_OPTIONS)
31 noinst_LTLIBRARIES = libpause_consumer.la
32
33--
342.17.1
35
diff --git a/meta/recipes-kernel/lttng/lttng-tools/0002-Fix-test-skip-test_getcpu_override-on-single-thread-.patch b/meta/recipes-kernel/lttng/lttng-tools/0002-Fix-test-skip-test_getcpu_override-on-single-thread-.patch
new file mode 100644
index 0000000000..5bb88d21e5
--- /dev/null
+++ b/meta/recipes-kernel/lttng/lttng-tools/0002-Fix-test-skip-test_getcpu_override-on-single-thread-.patch
@@ -0,0 +1,52 @@
1From e7db27668a9d7fd279d45bc43f3a2d5847374e7b Mon Sep 17 00:00:00 2001
2From: Jonathan Rajotte <jonathan.rajotte-julien@efficios.com>
3Date: Tue, 12 Mar 2019 12:04:58 -0400
4Subject: [PATCH lttng-tools 1/2] Fix: test: skip test_getcpu_override on
5 single thread system
6
7There is no value in performing this test on single thread system
8since the only valid value for the cpu field is 0.
9
10This test currently fails on single thread system (i.e yocto runquemu)
11on the test_getcpu_override_fail test case.
12
13Upstream-Status: Accepted [f87d0ca370c17b597762f5ee218f0e821ed2452d]
14Backported to 2.11 and 2.10
15
16Signed-off-by: Jonathan Rajotte <jonathan.rajotte-julien@efficios.com>
17---
18 .../ust/getcpu-override/test_getcpu_override | 16 +++++++++++-----
19 1 file changed, 11 insertions(+), 5 deletions(-)
20
21diff --git a/tests/regression/ust/getcpu-override/test_getcpu_override b/tests/regression/ust/getcpu-override/test_getcpu_override
22index 4ca385aeb..ee3e31953 100755
23--- a/tests/regression/ust/getcpu-override/test_getcpu_override
24+++ b/tests/regression/ust/getcpu-override/test_getcpu_override
25@@ -157,13 +157,19 @@ plan_tests $NUM_TESTS
26
27 print_test_banner "$TEST_DESC"
28
29-if [ -x "$CURDIR/.libs/lttng-ust-getcpu-override-test.so" ]; then
30- foundobj=1
31-else
32- foundobj=0
33+if [ ! -x "$CURDIR/.libs/lttng-ust-getcpu-override-test.so" ]; then
34+ skip 0 "No shared object generated. Skipping all tests." $NUM_TESTS && exit 0
35+fi
36+
37+if [ "$num_cpus" -eq "1" ]; then
38+ # Skip the test since we cannot perform it as designed since N mod 1
39+ # is always equals to zero. There is no point testing this on a system
40+ # with a single thread. LTTng-UST limits the get_cpu function to return
41+ # value inside the [0, NUM_CPU - 1] range for a valid event (present in
42+ # trace).
43+ skip 0 "Test system only have a single thread. Skipping all tests." $NUM_TESTS && exit 0
44 fi
45
46-skip $foundobj "No shared object generated. Skipping all tests." $NUM_TESTS && exit 0
47
48 TESTS=(
49 test_getcpu_override_fail
50--
512.17.1
52
diff --git a/meta/recipes-kernel/lttng/lttng-tools/0003-Fix-test-unit-the-tree-origin-can-be-a-symlink-itsel.patch b/meta/recipes-kernel/lttng/lttng-tools/0003-Fix-test-unit-the-tree-origin-can-be-a-symlink-itsel.patch
new file mode 100644
index 0000000000..822b26a367
--- /dev/null
+++ b/meta/recipes-kernel/lttng/lttng-tools/0003-Fix-test-unit-the-tree-origin-can-be-a-symlink-itsel.patch
@@ -0,0 +1,80 @@
1From 83d165442d1c3658b6bafa28ddade8ffee7092ad Mon Sep 17 00:00:00 2001
2From: Jonathan Rajotte <jonathan.rajotte-julien@efficios.com>
3Date: Wed, 6 Mar 2019 16:46:49 -0500
4Subject: [PATCH lttng-tools 2/2] Fix: test: unit: the tree origin can be a
5 symlink itself
6
7Problem:
8
9The base tree is defined as "/tmp/.....XXXXXX".
10On systems where "/tmp/" is itself a symlink utils_expand_path will
11expand the tree origin itself.
12
13For example on a base core-image-minimal Yocto build /tmp is a symlink
14to "/var/tmp", which is a symlink to "/var/volatile".
15
16utils_expand_path will return something like this for the symlink test:
17"/var/volative/.....XXXXXX/...." which is the valid result.
18
19Solution:
20
21Simply use realpath on the tree_origin and use this path to perform the
22test validation.
23
24This work was performed in the effort to support yocto fully and be able
25to run the test suite to detect problem as early as possible.
26
27
28Upstream-Status: Accepted [f66e964a2e0c75f5e1a55fbcc963b1c5e2b4519d]
29Backported to 2.11 and 2.10
30
31Signed-off-by: Jonathan Rajotte <jonathan.rajotte-julien@efficios.com>
32---
33 tests/unit/test_utils_expand_path.c | 18 ++++++++++++++----
34 1 file changed, 14 insertions(+), 4 deletions(-)
35
36diff --git a/tests/unit/test_utils_expand_path.c b/tests/unit/test_utils_expand_path.c
37index d5cab002e..d047c207d 100644
38--- a/tests/unit/test_utils_expand_path.c
39+++ b/tests/unit/test_utils_expand_path.c
40@@ -281,8 +281,8 @@ error:
41 static void test_utils_expand_path(void)
42 {
43 char *result;
44- char name[100], tmppath[PATH_MAX];
45- int i;
46+ char name[100], tmppath[PATH_MAX], real_tree_origin[PATH_MAX];
47+ int i, treelen;
48
49 /* Test valid cases */
50 for (i = 0; i < num_valid_tests; i++) {
51@@ -295,14 +295,24 @@ static void test_utils_expand_path(void)
52 free(result);
53 }
54
55+ /*
56+ * Get the realpath for the tree_origin since it can itself be a
57+ * symlink.
58+ */
59+ result = realpath(tree_origin, real_tree_origin);
60+ if (!result) {
61+ fail("realpath failed.");
62+ return;
63+ }
64+
65 /* Test symlink tree cases */
66- int treelen = strlen(tree_origin) + 1;
67+ treelen = strlen(real_tree_origin) + 1;
68 for (i = 0; i < num_symlink_tests; i++) {
69 sprintf(name, "symlink tree test case: [tmppath/]%s",
70 symlink_tests_inputs[i].input);
71
72 snprintf(tmppath, PATH_MAX, "%s/%s",
73- tree_origin, symlink_tests_inputs[i].input);
74+ real_tree_origin, symlink_tests_inputs[i].input);
75 result = utils_expand_path(tmppath);
76 ok(result != NULL && strcmp(result + treelen,
77 symlink_tests_inputs[i].expected_result) == 0, name);
78--
792.17.1
80
diff --git a/meta/recipes-kernel/lttng/lttng-tools/0004-Skip-when-testapp-is-not-present.patch b/meta/recipes-kernel/lttng/lttng-tools/0004-Skip-when-testapp-is-not-present.patch
new file mode 100644
index 0000000000..6c9f7e462c
--- /dev/null
+++ b/meta/recipes-kernel/lttng/lttng-tools/0004-Skip-when-testapp-is-not-present.patch
@@ -0,0 +1,610 @@
1From 95c27e6acceaeda55c729b9e92e594322adef13f Mon Sep 17 00:00:00 2001
2From: Jonathan Rajotte <jonathan.rajotte-julien@efficios.com>
3Date: Wed, 3 Apr 2019 16:31:18 -0400
4Subject: [PATCH lttng-tools] Skip when testapp is not present
5
6We expect lttng-ust do be present, this is a wrong assumptions.
7
8This is a quick fix. The real fix is to either detect at runtime
9lttng-ust support or at build time (HAVE_LIBLTTNG_UST_CTL).
10
11This prevent hang for make check done on a build configured with
12--without-lttng-ust.
13
14Upstream-Status: Inappropriate [other]
15Reason: This patch is inappropriate for upstream for 2.10 stable release
16since we do not backport "superficial" fix to the test suite. We do
17backport when a test is broken. The fact that on --without-lttng-ust
18hang is not a "broken" test per-see. Still, a variation of this fix will
19be upstreamed in our master branch and possibly 2.11. The upstreamed
20version will split the test in kernel/ust test and skip them at the
21build system level. This patch is more succinct.
22
23Signed-off-by: Jonathan Rajotte <jonathan.rajotte-julien@efficios.com>
24---
25 tests/regression/tools/crash/test_crash | 4 ++
26 .../regression/tools/exclusion/test_exclusion | 4 ++
27 .../tools/filtering/test_valid_filter | 21 ++++--
28 tests/regression/tools/health/test_thread_ok | 29 +++++---
29 tests/regression/tools/live/Makefile.am | 2 -
30 tests/regression/tools/live/test_lttng_ust | 4 ++
31 tests/regression/tools/live/test_ust | 4 ++
32 .../tools/live/test_ust_tracefile_count | 4 ++
33 tests/regression/tools/mi/test_mi | 4 ++
34 .../notification/test_notification_multi_app | 18 +++--
35 .../tools/notification/test_notification_ust | 4 ++
36 .../regression/tools/regen-metadata/test_ust | 2 +-
37 .../regression/tools/regen-statedump/test_ust | 2 +-
38 .../regression/tools/save-load/test_autoload | 7 ++
39 tests/regression/tools/save-load/test_load | 8 +++
40 tests/regression/tools/save-load/test_save | 7 ++
41 .../regression/tools/snapshots/test_ust_fast | 2 +-
42 .../regression/tools/snapshots/test_ust_long | 2 +-
43 .../tools/snapshots/test_ust_streaming | 2 +-
44 tests/regression/tools/snapshots/ust_test | 2 +-
45 .../streaming/test_high_throughput_limits | 2 +-
46 tests/regression/tools/streaming/test_ust | 2 +-
47 .../tracefile-limits/test_tracefile_count | 2 +-
48 .../tracefile-limits/test_tracefile_size | 2 +-
49 .../tools/wildcard/test_event_wildcard | 67 ++++++++++---------
50 25 files changed, 147 insertions(+), 60 deletions(-)
51
52diff --git a/tests/regression/tools/crash/test_crash b/tests/regression/tools/crash/test_crash
53index 8c62c513d..3cbe97688 100755
54--- a/tests/regression/tools/crash/test_crash
55+++ b/tests/regression/tools/crash/test_crash
56@@ -35,6 +35,10 @@ NUM_TESTS=77
57
58 source $TESTDIR/utils/utils.sh
59
60+if [ ! -x "$TESTAPP_BIN" ]; then
61+ plan_skip_all "No UST events binary detected."
62+fi
63+
64 # Global declaration for simplification
65 LTTNG_CRASH=$TESTDIR/../src/bin/lttng-crash/$CRASH_BIN
66
67diff --git a/tests/regression/tools/exclusion/test_exclusion b/tests/regression/tools/exclusion/test_exclusion
68index 949cd41df..42e4d72fb 100755
69--- a/tests/regression/tools/exclusion/test_exclusion
70+++ b/tests/regression/tools/exclusion/test_exclusion
71@@ -30,6 +30,10 @@ NUM_TESTS=149
72
73 source $TESTDIR/utils/utils.sh
74
75+if [ ! -x "$TESTAPP_BIN" ]; then
76+ plan_skip_all "No UST events binary detected."
77+fi
78+
79 function enable_ust_lttng_all_event_exclusion()
80 {
81 sess_name="$1"
82diff --git a/tests/regression/tools/filtering/test_valid_filter b/tests/regression/tools/filtering/test_valid_filter
83index 163b32182..1e8da630b 100755
84--- a/tests/regression/tools/filtering/test_valid_filter
85+++ b/tests/regression/tools/filtering/test_valid_filter
86@@ -418,12 +418,18 @@ issue_356_filter+="intfield > 4 && intfield > 5 && "
87 issue_356_filter+="intfield > 6 && intfield > 7 && "
88 issue_356_filter+="intfield > 8 || intfield > 0"
89
90+BIN_NAME="gen-ust-events"
91+
92+skip_ust=1
93+if [ ! -x "$CURDIR/$BIN_NAME" ]; then
94+ skip_ust=0
95+ skip 0 "No UST nevents binary detected." $NUM_UST_TESTS
96+fi
97+
98 start_lttng_sessiond
99
100 ### UST TESTS
101
102-BIN_NAME="gen-ust-events"
103-
104 KIRK_KRAUSS_TESTS=(
105 # the tests below were written by Kirk Krauss in this article:
106 # http://www.drdobbs.com/architecture-and-design/matching-wildcards-an-empirical-way-to-t/240169123
107@@ -897,9 +903,6 @@ UST_STR_FILTERS=(
108 END
109 )
110
111-if [ ! -x "$CURDIR/$BIN_NAME" ]; then
112- BAIL_OUT "No UST nevents binary detected."
113-fi
114
115 IFS="$OLDIFS"
116
117@@ -910,6 +913,10 @@ i=0
118 while true; do
119 validator="${UST_FILTERS[$i]}"
120
121+ if [ $skip_ust -eq 0 ]; then
122+ break
123+ fi
124+
125 if [ "$validator" = END ]; then
126 break
127 fi
128@@ -929,6 +936,10 @@ i=0
129 while true; do
130 validator="${UST_STR_FILTERS[$i]}"
131
132+ if [ $skip_ust -eq 0 ]; then
133+ break
134+ fi
135+
136 if [ "$validator" = END ]; then
137 break
138 fi
139diff --git a/tests/regression/tools/health/test_thread_ok b/tests/regression/tools/health/test_thread_ok
140index e81d6ed24..849b7e71f 100755
141--- a/tests/regression/tools/health/test_thread_ok
142+++ b/tests/regression/tools/health/test_thread_ok
143@@ -27,6 +27,9 @@ CHANNEL_NAME="testchan"
144 HEALTH_CHECK_BIN="health_check"
145 NUM_TESTS=17
146 SLEEP_TIME=30
147+TESTAPP_PATH="$TESTDIR/utils/testapp"
148+TESTAPP_NAME="gen-ust-events"
149+TESTAPP_BIN="$TESTAPP_PATH/$TESTAPP_NAME/$TESTAPP_NAME"
150
151 source $TESTDIR/utils/utils.sh
152
153@@ -76,15 +79,19 @@ function test_thread_ok
154 $CURDIR/$HEALTH_CHECK_BIN > ${STDOUT_PATH} 2> ${STDERR_PATH}
155 report_errors
156
157- diag "With UST consumer daemons"
158- create_lttng_session_no_output $SESSION_NAME
159- enable_ust_lttng_event_ok $SESSION_NAME $UST_EVENT_NAME $CHANNEL_NAME
160- start_lttng_tracing_ok $SESSION_NAME
161- destroy_lttng_session_ok $SESSION_NAME
162+ skip $skip_ust "Ust does not seems to be supported" "5" ||
163+ {
164+ diag "With UST consumer daemons"
165+ create_lttng_session_no_output $SESSION_NAME
166+ enable_ust_lttng_event_ok $SESSION_NAME $UST_EVENT_NAME $CHANNEL_NAME
167+ start_lttng_tracing_ok $SESSION_NAME
168+ destroy_lttng_session_ok $SESSION_NAME
169
170- # Check health status
171- $CURDIR/$HEALTH_CHECK_BIN > ${STDOUT_PATH} 2> ${STDERR_PATH}
172- report_errors
173+
174+ # Check health status
175+ $CURDIR/$HEALTH_CHECK_BIN > ${STDOUT_PATH} 2> ${STDERR_PATH}
176+ report_errors
177+ }
178
179 skip $isroot "Root access is needed. Skipping kernel consumer health check test." "5" ||
180 {
181@@ -141,6 +148,12 @@ else
182 isroot=0
183 fi
184
185+if [ ! -x "$TESTAPP_BIN" ]; then
186+ skip_ust=0
187+else
188+ skip_ust=1
189+fi
190+
191 test_thread_ok
192
193 rm -rf ${HEALTH_PATH}
194diff --git a/tests/regression/tools/live/Makefile.am b/tests/regression/tools/live/Makefile.am
195index 46186d383..db74de8d5 100644
196--- a/tests/regression/tools/live/Makefile.am
197+++ b/tests/regression/tools/live/Makefile.am
198@@ -16,9 +16,7 @@ LIVE=$(top_builddir)/src/bin/lttng-sessiond/session.$(OBJEXT) \
199 noinst_PROGRAMS = live_test
200 EXTRA_DIST = test_kernel test_lttng_kernel
201
202-if HAVE_LIBLTTNG_UST_CTL
203 EXTRA_DIST += test_ust test_ust_tracefile_count test_lttng_ust
204-endif
205
206 live_test_SOURCES = live_test.c
207 live_test_LDADD = $(LIBTAP) $(LIBCOMMON) $(LIBRELAYD) $(LIBSESSIOND_COMM) \
208diff --git a/tests/regression/tools/live/test_lttng_ust b/tests/regression/tools/live/test_lttng_ust
209index 06017d01d..be9b3d7f7 100755
210--- a/tests/regression/tools/live/test_lttng_ust
211+++ b/tests/regression/tools/live/test_lttng_ust
212@@ -38,6 +38,10 @@ NUM_TESTS=12
213
214 source $TESTDIR/utils/utils.sh
215
216+if [ ! -x "$TESTAPP_BIN" ]; then
217+ plan_skip_all "No UST events binary detected."
218+fi
219+
220 # MUST set TESTDIR before calling those functions
221 plan_tests $NUM_TESTS
222
223diff --git a/tests/regression/tools/live/test_ust b/tests/regression/tools/live/test_ust
224index 0384a706f..add521bfc 100755
225--- a/tests/regression/tools/live/test_ust
226+++ b/tests/regression/tools/live/test_ust
227@@ -36,6 +36,10 @@ DIR=$(readlink -f $TESTDIR)
228
229 source $TESTDIR/utils/utils.sh
230
231+if [ ! -x "$TESTAPP_BIN" ]; then
232+ plan_skip_all "No UST events binary detected."
233+fi
234+
235 echo "$TEST_DESC"
236
237 function setup_live_tracing()
238diff --git a/tests/regression/tools/live/test_ust_tracefile_count b/tests/regression/tools/live/test_ust_tracefile_count
239index 6da368fc6..10504f8c6 100755
240--- a/tests/regression/tools/live/test_ust_tracefile_count
241+++ b/tests/regression/tools/live/test_ust_tracefile_count
242@@ -36,6 +36,10 @@ DIR=$(readlink -f $TESTDIR)
243
244 source $TESTDIR/utils/utils.sh
245
246+if [ ! -x "$TESTAPP_BIN" ]; then
247+ plan_skip_all "No UST events binary detected."
248+fi
249+
250 echo "$TEST_DESC"
251
252 function setup_live_tracing()
253diff --git a/tests/regression/tools/mi/test_mi b/tests/regression/tools/mi/test_mi
254index 48dda7da6..2cc30b29a 100755
255--- a/tests/regression/tools/mi/test_mi
256+++ b/tests/regression/tools/mi/test_mi
257@@ -61,6 +61,10 @@ NUM_TESTS=228
258
259 source $TESTDIR/utils/utils.sh
260
261+if [ ! -x "$TESTAPP_BIN" ]; then
262+ plan_skip_all "No UST events binary detected."
263+fi
264+
265 #Overwrite the lttng_bin to get mi output
266 LTTNG_BIN="lttng --mi xml"
267
268diff --git a/tests/regression/tools/notification/test_notification_multi_app b/tests/regression/tools/notification/test_notification_multi_app
269index 0a05ea6a0..29b0f62fa 100755
270--- a/tests/regression/tools/notification/test_notification_multi_app
271+++ b/tests/regression/tools/notification/test_notification_multi_app
272@@ -52,6 +52,11 @@ plan_tests $NUM_TESTS
273
274 print_test_banner "$TEST_DESC"
275
276+skip_ust=1
277+if [ ! -x "$TESTAPP_BIN" ]; then
278+ skip_ust=0
279+fi
280+
281 app_pids=()
282
283 function kernel_event_generator_toogle_state
284@@ -468,10 +473,15 @@ function test_on_register_evaluation ()
285 }
286
287
288-TESTS=(
289- test_multi_app_ust
290- test_on_register_evaluation_ust
291-)
292+TESTS=()
293+if [ $skip_ust -eq "1" ]; then
294+ TESTS+=(
295+ test_multi_app_ust
296+ test_on_register_evaluation_ust
297+ )
298+else
299+ skip 0 "No UST events binary detected." $NUM_TEST_UST
300+fi
301
302 if [ "$(id -u)" == "0" ]; then
303 TESTS+=(
304diff --git a/tests/regression/tools/notification/test_notification_ust b/tests/regression/tools/notification/test_notification_ust
305index 8941e476d..eb2e15cad 100755
306--- a/tests/regression/tools/notification/test_notification_ust
307+++ b/tests/regression/tools/notification/test_notification_ust
308@@ -46,6 +46,10 @@ DIR=$(readlink -f $TESTDIR)
309
310 source $TESTDIR/utils/utils.sh
311
312+if [ ! -x "$TESTAPP_BIN" ]; then
313+ plan_skip_all "No UST events binary detected."
314+fi
315+
316 function ust_event_generator_toogle_state
317 {
318 ust_event_generator_suspended=$((ust_event_generator_suspended==0))
319diff --git a/tests/regression/tools/regen-metadata/test_ust b/tests/regression/tools/regen-metadata/test_ust
320index b7f1af1d8..312c8a40d 100755
321--- a/tests/regression/tools/regen-metadata/test_ust
322+++ b/tests/regression/tools/regen-metadata/test_ust
323@@ -34,7 +34,7 @@ NUM_TESTS=33
324 source $TESTDIR/utils/utils.sh
325
326 if [ ! -x "$TESTAPP_BIN" ]; then
327- BAIL_OUT "No UST events binary detected."
328+ plan_skip_all "No UST events binary detected."
329 fi
330
331 function lttng_create_session_uri
332diff --git a/tests/regression/tools/regen-statedump/test_ust b/tests/regression/tools/regen-statedump/test_ust
333index 486b9a560..8d455b26a 100755
334--- a/tests/regression/tools/regen-statedump/test_ust
335+++ b/tests/regression/tools/regen-statedump/test_ust
336@@ -34,7 +34,7 @@ NUM_TESTS=11
337 source $TESTDIR/utils/utils.sh
338
339 if [ ! -x "$TESTAPP_BIN" ]; then
340- BAIL_OUT "No UST events binary detected."
341+ plan_skip_all "No UST events binary detected."
342 fi
343
344 function test_ust_local ()
345diff --git a/tests/regression/tools/save-load/test_autoload b/tests/regression/tools/save-load/test_autoload
346index 7ee5e9906..ec376cfb3 100755
347--- a/tests/regression/tools/save-load/test_autoload
348+++ b/tests/regression/tools/save-load/test_autoload
349@@ -21,6 +21,9 @@ CURDIR=$(dirname $0)/
350 CONFIG_DIR="${CURDIR}/configuration"
351 TESTDIR=$CURDIR/../../../
352 export LTTNG_SESSION_CONFIG_XSD_PATH=$(readlink -m ${TESTDIR}../src/common/config/)
353+TESTAPP_PATH="$TESTDIR/utils/testapp"
354+TESTAPP_NAME="gen-ust-events"
355+TESTAPP_BIN="$TESTAPP_PATH/$TESTAPP_NAME/$TESTAPP_NAME"
356
357 DIR=$(readlink -f $TESTDIR)
358
359@@ -28,6 +31,10 @@ NUM_TESTS=9
360
361 source $TESTDIR/utils/utils.sh
362
363+if [ ! -x "$TESTAPP_BIN" ]; then
364+ plan_skip_all "No UST events binary detected."
365+fi
366+
367 # MUST set TESTDIR before calling those functions
368 plan_tests $NUM_TESTS
369
370diff --git a/tests/regression/tools/save-load/test_load b/tests/regression/tools/save-load/test_load
371index 5e38b46b6..b6fdd8192 100755
372--- a/tests/regression/tools/save-load/test_load
373+++ b/tests/regression/tools/save-load/test_load
374@@ -20,6 +20,10 @@ TEST_DESC="Load session(s)"
375 CURDIR=$(dirname $0)/
376 CONFIG_DIR="${CURDIR}/configuration"
377 TESTDIR=$CURDIR/../../../
378+TESTAPP_PATH="$TESTDIR/utils/testapp"
379+TESTAPP_NAME="gen-ust-events"
380+TESTAPP_BIN="$TESTAPP_PATH/$TESTAPP_NAME/$TESTAPP_NAME"
381+
382 export LTTNG_SESSION_CONFIG_XSD_PATH=$(readlink -m ${TESTDIR}../src/common/config/)
383
384 SESSION_NAME="load-42"
385@@ -31,6 +35,10 @@ NUM_TESTS=67
386
387 source $TESTDIR/utils/utils.sh
388
389+if [ ! -x "$TESTAPP_BIN" ]; then
390+ plan_skip_all "No UST events binary detected."
391+fi
392+
393 # MUST set TESTDIR before calling those functions
394 plan_tests $NUM_TESTS
395
396diff --git a/tests/regression/tools/save-load/test_save b/tests/regression/tools/save-load/test_save
397index c5f6b1341..cfaf67b7a 100755
398--- a/tests/regression/tools/save-load/test_save
399+++ b/tests/regression/tools/save-load/test_save
400@@ -23,6 +23,9 @@ TESTDIR=$CURDIR/../../../
401 SESSION_NAME="save-42"
402 CHANNEL_NAME="chan-save"
403 EVENT_NAME="tp:tptest"
404+TESTAPP_PATH="$TESTDIR/utils/testapp"
405+TESTAPP_NAME="gen-ust-events"
406+TESTAPP_BIN="$TESTAPP_PATH/$TESTAPP_NAME/$TESTAPP_NAME"
407
408 DIR=$(readlink -f $TESTDIR)
409
410@@ -30,6 +33,10 @@ NUM_TESTS=41
411
412 source $TESTDIR/utils/utils.sh
413
414+if [ ! -x "TESTAPP_BIN" ]; then
415+ plan_skip_all "No UST events binary detected."
416+fi
417+
418 # MUST set TESTDIR before calling those functions
419 plan_tests $NUM_TESTS
420
421diff --git a/tests/regression/tools/snapshots/test_ust_fast b/tests/regression/tools/snapshots/test_ust_fast
422index edb435c52..5a68ec56d 100755
423--- a/tests/regression/tools/snapshots/test_ust_fast
424+++ b/tests/regression/tools/snapshots/test_ust_fast
425@@ -23,7 +23,7 @@ TEST_BIN="ust_test"
426 source $TESTDIR/utils/utils.sh
427
428 if [ ! -x "$CURDIR/$TEST_BIN" ]; then
429- BAIL_OUT "No UST test found: $TEST_BIN"
430+ plan_skip_all "No UST test found: $TEST_BIN"
431 fi
432
433 ./$CURDIR/$TEST_BIN $NR_SNAPSHOT
434diff --git a/tests/regression/tools/snapshots/test_ust_long b/tests/regression/tools/snapshots/test_ust_long
435index 9e1a0c262..afa019f6a 100755
436--- a/tests/regression/tools/snapshots/test_ust_long
437+++ b/tests/regression/tools/snapshots/test_ust_long
438@@ -23,7 +23,7 @@ TEST_BIN="ust_test"
439 source $TESTDIR/utils/utils.sh
440
441 if [ ! -x "$CURDIR/$TEST_BIN" ]; then
442- BAIL_OUT "No UST test found: $TEST_BIN"
443+ plan_skip_all "No UST test found: $TEST_BIN"
444 fi
445
446 ./$CURDIR/$TEST_BIN $NR_SNAPSHOT
447diff --git a/tests/regression/tools/snapshots/test_ust_streaming b/tests/regression/tools/snapshots/test_ust_streaming
448index 93b0957f3..69291ab4d 100755
449--- a/tests/regression/tools/snapshots/test_ust_streaming
450+++ b/tests/regression/tools/snapshots/test_ust_streaming
451@@ -37,7 +37,7 @@ NUM_TESTS=75
452 source $TESTDIR/utils/utils.sh
453
454 if [ ! -x "$TESTAPP_BIN" ]; then
455- BAIL_OUT "No UST events binary detected."
456+ plan_skip_all "No UST events binary detected."
457 fi
458
459 function snapshot_add_output ()
460diff --git a/tests/regression/tools/snapshots/ust_test b/tests/regression/tools/snapshots/ust_test
461index 755cef9e0..92f9f6cff 100755
462--- a/tests/regression/tools/snapshots/ust_test
463+++ b/tests/regression/tools/snapshots/ust_test
464@@ -34,7 +34,7 @@ TRACE_PATH=$(mktemp -d)
465 source $TESTDIR/utils/utils.sh
466
467 if [ ! -x "$TESTAPP_BIN" ]; then
468- BAIL_OUT "No UST events binary detected."
469+ plan_skip_all "No UST events binary detected."
470 fi
471
472 # Need the number of snapshot to do.
473diff --git a/tests/regression/tools/streaming/test_high_throughput_limits b/tests/regression/tools/streaming/test_high_throughput_limits
474index 32c3f1f2b..f54178923 100755
475--- a/tests/regression/tools/streaming/test_high_throughput_limits
476+++ b/tests/regression/tools/streaming/test_high_throughput_limits
477@@ -38,7 +38,7 @@ NUM_TESTS=104
478 source $TESTDIR/utils/utils.sh
479
480 if [ ! -x "$TESTAPP_BIN" ]; then
481- BAIL_OUT "No UST events binary detected."
482+ plan_skip_all "No UST events binary detected."
483 fi
484
485 function set_bw_limit
486diff --git a/tests/regression/tools/streaming/test_ust b/tests/regression/tools/streaming/test_ust
487index a5d5b5e92..e1dd98ee7 100755
488--- a/tests/regression/tools/streaming/test_ust
489+++ b/tests/regression/tools/streaming/test_ust
490@@ -34,7 +34,7 @@ NUM_TESTS=16
491 source $TESTDIR/utils/utils.sh
492
493 if [ ! -x "$TESTAPP_BIN" ]; then
494- BAIL_OUT "No UST events binary detected."
495+ plan_skip_all "No UST events binary detected."
496 fi
497
498 function lttng_create_session_uri
499diff --git a/tests/regression/tools/tracefile-limits/test_tracefile_count b/tests/regression/tools/tracefile-limits/test_tracefile_count
500index 6ada8580f..7553c7d1f 100755
501--- a/tests/regression/tools/tracefile-limits/test_tracefile_count
502+++ b/tests/regression/tools/tracefile-limits/test_tracefile_count
503@@ -33,7 +33,7 @@ PAGE_SIZE=$(getconf PAGE_SIZE)
504 source $TESTDIR/utils/utils.sh
505
506 if [ ! -x "$TESTAPP_BIN" ]; then
507- BAIL_OUT "No UST events binary detected."
508+ plan_skip_all "No UST events binary detected."
509 fi
510
511 function enable_lttng_channel_count_limit ()
512diff --git a/tests/regression/tools/tracefile-limits/test_tracefile_size b/tests/regression/tools/tracefile-limits/test_tracefile_size
513index 3dddbe613..1089487ff 100755
514--- a/tests/regression/tools/tracefile-limits/test_tracefile_size
515+++ b/tests/regression/tools/tracefile-limits/test_tracefile_size
516@@ -33,7 +33,7 @@ NUM_TESTS=66
517 source $TESTDIR/utils/utils.sh
518
519 if [ ! -x "$TESTAPP_BIN" ]; then
520- BAIL_OUT "No UST events binary detected."
521+ plan_skip_all "No UST events binary detected."
522 fi
523
524 function enable_lttng_channel_size_limit ()
525diff --git a/tests/regression/tools/wildcard/test_event_wildcard b/tests/regression/tools/wildcard/test_event_wildcard
526index 61ea67a72..921a2301d 100755
527--- a/tests/regression/tools/wildcard/test_event_wildcard
528+++ b/tests/regression/tools/wildcard/test_event_wildcard
529@@ -97,42 +97,47 @@ print_test_banner "$TEST_DESC"
530
531 start_lttng_sessiond
532
533-diag "Test UST wildcard"
534-
535 if [ ! -x "$TESTAPP_BIN" ]; then
536- BAIL_OUT "No UST nevents binary detected."
537+ skip_ust=0
538+else
539+ skip_ust=1
540 fi
541
542-EVENT_NAME="tp:tptest"
543+skip $skip_ust "No UST nevents binary detected." $NUM_UST_TESTS ||
544+{
545+ diag "Test UST wildcard"
546
547-# non-matching
548-test_event_wildcard ust 0 'tp:abc*'
549-test_event_wildcard ust 0 '*abc'
550-test_event_wildcard ust 0 '*z*'
551-test_event_wildcard ust 0 '*\**'
552-test_event_wildcard ust 0 '*\*'
553-test_event_wildcard ust 0 '\**'
554-test_event_wildcard ust 0 '*:*tpte*s'
555-test_event_wildcard ust 0 'tp**tpTest'
556+ EVENT_NAME="tp:tptest"
557
558-# matching
559-test_event_wildcard ust 1 'tp:tp*'
560-test_event_wildcard ust 1 '*'
561-test_event_wildcard ust 1 'tp:tptest*'
562-test_event_wildcard ust 1 '**'
563-test_event_wildcard ust 1 '***'
564-test_event_wildcard ust 1 '*tptest'
565-test_event_wildcard ust 1 '**tptest'
566-test_event_wildcard ust 1 '*tpte*'
567-test_event_wildcard ust 1 '*tp*'
568-test_event_wildcard ust 1 '*tp**'
569-test_event_wildcard ust 1 '*:*tptest'
570-test_event_wildcard ust 1 '*:*tpte*t'
571-test_event_wildcard ust 1 't*p*:*t*e*s*t'
572-test_event_wildcard ust 1 '*t*p*:*t*e*s*t*'
573-test_event_wildcard ust 1 'tp*tptest'
574-test_event_wildcard ust 1 'tp**tptest'
575-test_event_wildcard ust 1 'tp*test'
576+ # non-matching
577+ test_event_wildcard ust 0 'tp:abc*'
578+ test_event_wildcard ust 0 '*abc'
579+ test_event_wildcard ust 0 '*z*'
580+ test_event_wildcard ust 0 '*\**'
581+ test_event_wildcard ust 0 '*\*'
582+ test_event_wildcard ust 0 '\**'
583+ test_event_wildcard ust 0 '*:*tpte*s'
584+ test_event_wildcard ust 0 'tp**tpTest'
585+
586+ # matching
587+ test_event_wildcard ust 1 'tp:tp*'
588+ test_event_wildcard ust 1 '*'
589+ test_event_wildcard ust 1 'tp:tptest*'
590+ test_event_wildcard ust 1 '**'
591+ test_event_wildcard ust 1 '***'
592+ test_event_wildcard ust 1 '*tptest'
593+ test_event_wildcard ust 1 '**tptest'
594+ test_event_wildcard ust 1 '*tpte*'
595+ test_event_wildcard ust 1 '*tp*'
596+ test_event_wildcard ust 1 '*tp**'
597+ test_event_wildcard ust 1 '*:*tptest'
598+ test_event_wildcard ust 1 '*:*tpte*t'
599+ test_event_wildcard ust 1 't*p*:*t*e*s*t'
600+ test_event_wildcard ust 1 '*t*p*:*t*e*s*t*'
601+ test_event_wildcard ust 1 'tp*tptest'
602+ test_event_wildcard ust 1 'tp**tptest'
603+ test_event_wildcard ust 1 'tp*test'
604+}
605
606 if [ "$(id -u)" == "0" ]; then
607 isroot=1
608--
6092.17.1
610
diff --git a/meta/recipes-kernel/lttng/lttng-tools/0005-Tests-use-modprobe-to-test-for-the-presence-of-lttng.patch b/meta/recipes-kernel/lttng/lttng-tools/0005-Tests-use-modprobe-to-test-for-the-presence-of-lttng.patch
new file mode 100644
index 0000000000..16df3e610a
--- /dev/null
+++ b/meta/recipes-kernel/lttng/lttng-tools/0005-Tests-use-modprobe-to-test-for-the-presence-of-lttng.patch
@@ -0,0 +1,176 @@
1From 9bc81a446d0a3ea9a884739eee48d3f14db3283c Mon Sep 17 00:00:00 2001
2From: Jonathan Rajotte <jonathan.rajotte-julien@efficios.com>
3Date: Wed, 28 Mar 2018 15:21:26 -0400
4Subject: [PATCH lttng-tools] Tests: use modprobe to test for the presence of
5 lttng-modules
6MIME-Version: 1.0
7Content-Type: text/plain; charset=UTF-8
8Content-Transfer-Encoding: 8bit
9
10Upstream-Status: Backport [28702730192ae1ded06105c54c5dc]
11
12Signed-off-by: Jonathan Rajotte <jonathan.rajotte-julien@efficios.com>
13Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
14---
15 tests/regression/tools/regen-metadata/test_kernel | 8 ++------
16 tests/regression/tools/regen-statedump/test_kernel | 7 +------
17 tests/regression/tools/snapshots/test_kernel | 9 +++------
18 tests/regression/tools/snapshots/test_kernel_streaming | 8 ++------
19 tests/regression/tools/streaming/test_kernel | 8 ++------
20 tests/utils/utils.sh | 10 ++++++++++
21 6 files changed, 20 insertions(+), 30 deletions(-)
22
23diff --git a/tests/regression/tools/regen-metadata/test_kernel b/tests/regression/tools/regen-metadata/test_kernel
24index fd139aeef..1849b9cd0 100755
25--- a/tests/regression/tools/regen-metadata/test_kernel
26+++ b/tests/regression/tools/regen-metadata/test_kernel
27@@ -28,12 +28,6 @@ NUM_TESTS=18
28
29 source $TESTDIR/utils/utils.sh
30
31-# LTTng kernel modules check
32-out=`ls /lib/modules/$(uname -r)/extra | grep lttng`
33-if [ -z "$out" ]; then
34- BAIL_OUT "LTTng modules not detected."
35-fi
36-
37 function lttng_create_session_uri
38 {
39 # Create session with default path
40@@ -91,6 +85,8 @@ fi
41
42 skip $isroot "Root access is needed. Skipping all kernel streaming tests." $NUM_TESTS ||
43 {
44+ validate_lttng_modules_present
45+
46 start_lttng_relayd "-o $TRACE_PATH"
47 start_lttng_sessiond
48 modprobe lttng-test
49diff --git a/tests/regression/tools/regen-statedump/test_kernel b/tests/regression/tools/regen-statedump/test_kernel
50index 85afe76a1..50054eb07 100755
51--- a/tests/regression/tools/regen-statedump/test_kernel
52+++ b/tests/regression/tools/regen-statedump/test_kernel
53@@ -29,12 +29,6 @@ NUM_TESTS=11
54
55 source $TESTDIR/utils/utils.sh
56
57-# LTTng kernel modules check
58-out=`ls /lib/modules/$(uname -r)/extra | grep lttng`
59-if [ -z "$out" ]; then
60- BAIL_OUT "LTTng modules not detected."
61-fi
62-
63 function test_kernel_local ()
64 {
65 diag "Test kernel local with statedump regeneration"
66@@ -64,6 +58,7 @@ fi
67
68 skip $isroot "Root access is needed. Skipping all kernel streaming tests." $NUM_TESTS ||
69 {
70+ validate_lttng_modules_present
71 start_lttng_sessiond
72 modprobe lttng-test
73
74diff --git a/tests/regression/tools/snapshots/test_kernel b/tests/regression/tools/snapshots/test_kernel
75index 886c4557a..ff563100b 100755
76--- a/tests/regression/tools/snapshots/test_kernel
77+++ b/tests/regression/tools/snapshots/test_kernel
78@@ -29,12 +29,6 @@ NUM_TESTS=2060
79
80 source $TESTDIR/utils/utils.sh
81
82-# LTTng kernel modules check
83-out=`ls /lib/modules/$(uname -r)/extra | grep lttng`
84-if [ -z "$out" ]; then
85- BAIL_OUT "LTTng modules not detected."
86-fi
87-
88 function test_kernel_local_snapshot ()
89 {
90 diag "Test local kernel snapshots"
91@@ -241,6 +235,9 @@ fi
92
93 skip $isroot "Root access is needed. Skipping all kernel snapshot tests." $NUM_TESTS ||
94 {
95+
96+ validate_lttng_modules_present
97+
98 start_lttng_sessiond
99
100 #tests=( test_kernel_1000_local_snapshots )
101diff --git a/tests/regression/tools/snapshots/test_kernel_streaming b/tests/regression/tools/snapshots/test_kernel_streaming
102index 7b96ef270..1d97519aa 100755
103--- a/tests/regression/tools/snapshots/test_kernel_streaming
104+++ b/tests/regression/tools/snapshots/test_kernel_streaming
105@@ -29,12 +29,6 @@ NUM_TESTS=61
106
107 source $TESTDIR/utils/utils.sh
108
109-# LTTng kernel modules check
110-out=`ls /lib/modules/$(uname -r)/extra | grep lttng`
111-if [ -z "$out" ]; then
112- BAIL_OUT "LTTng modules not detected."
113-fi
114-
115 function snapshot_add_output ()
116 {
117 local sess_name=$1
118@@ -169,6 +163,8 @@ fi
119
120 skip $isroot "Root access is needed. Skipping all kernel streaming tests." $NUM_TESTS ||
121 {
122+ validate_lttng_modules_present
123+
124 start_lttng_relayd "-o $TRACE_PATH"
125 start_lttng_sessiond
126
127diff --git a/tests/regression/tools/streaming/test_kernel b/tests/regression/tools/streaming/test_kernel
128index d54bcedf5..6bb23d9f5 100755
129--- a/tests/regression/tools/streaming/test_kernel
130+++ b/tests/regression/tools/streaming/test_kernel
131@@ -28,12 +28,6 @@ NUM_TESTS=10
132
133 source $TESTDIR/utils/utils.sh
134
135-# LTTng kernel modules check
136-out=`ls /lib/modules/$(uname -r)/extra | grep lttng`
137-if [ -z "$out" ]; then
138- BAIL_OUT "LTTng modules not detected."
139-fi
140-
141 function lttng_create_session_uri
142 {
143 # Create session with default path
144@@ -80,6 +74,8 @@ fi
145
146 skip $isroot "Root access is needed. Skipping all kernel streaming tests." $NUM_TESTS ||
147 {
148+ validate_lttng_modules_present
149+
150 start_lttng_relayd "-o $TRACE_PATH"
151 start_lttng_sessiond
152
153diff --git a/tests/utils/utils.sh b/tests/utils/utils.sh
154index af63824ce..26e59e383 100644
155--- a/tests/utils/utils.sh
156+++ b/tests/utils/utils.sh
157@@ -125,6 +125,16 @@ function conf_proc_count()
158 echo
159 }
160
161+# Check if base lttng-modules are present.
162+# Bail out on failure
163+function validate_lttng_modules_present ()
164+{
165+ modprobe -n lttng-tracer 2>/dev/null
166+ if [ $? -ne 0 ]; then
167+ BAIL_OUT "LTTng modules not detected."
168+ fi
169+}
170+
171 function enable_kernel_lttng_event
172 {
173 local withtap="$1"
174--
1752.17.1
176
diff --git a/meta/recipes-kernel/lttng/lttng-tools/0006-Tests-check-for-lttng-modules-presence.patch b/meta/recipes-kernel/lttng/lttng-tools/0006-Tests-check-for-lttng-modules-presence.patch
new file mode 100644
index 0000000000..e07c227f46
--- /dev/null
+++ b/meta/recipes-kernel/lttng/lttng-tools/0006-Tests-check-for-lttng-modules-presence.patch
@@ -0,0 +1,28 @@
1From 92f93238f1df005aadc98e105c0dd0e04a5955a7 Mon Sep 17 00:00:00 2001
2From: Jonathan Rajotte <jonathan.rajotte-julien@efficios.com>
3Date: Mon, 25 Mar 2019 14:24:51 -0400
4Subject: [2/2] tests: check for lttng-modules presence
5
6Upstream-status: Accepted [5da3fc8579a9f93ea4767729a107784bf2d034ae]
7Backported to 2.11 and 2.10
8
9Signed-off-by: Jonathan Rajotte <jonathan.rajotte-julien@efficios.com>
10---
11 tests/regression/tools/notification/test_notification_kernel | 1 +
12 1 file changed, 1 insertion(+)
13
14diff --git a/tests/regression/tools/notification/test_notification_kernel b/tests/regression/tools/notification/test_notification_kernel
15index 6d7f256ae..e7368df26 100755
16--- a/tests/regression/tools/notification/test_notification_kernel
17+++ b/tests/regression/tools/notification/test_notification_kernel
18@@ -108,6 +108,7 @@ function kernel_test
19 }
20
21 if [ "$(id -u)" == "0" ]; then
22+ validate_lttng_modules_present
23 kernel_test
24 else
25 # Kernel tests are skipped.
26--
272.17.1
28
diff --git a/meta/recipes-kernel/lttng/lttng-tools/0007-Fix-getgrnam-is-not-MT-Safe-use-getgrnam_r.patch b/meta/recipes-kernel/lttng/lttng-tools/0007-Fix-getgrnam-is-not-MT-Safe-use-getgrnam_r.patch
new file mode 100644
index 0000000000..5437de26e8
--- /dev/null
+++ b/meta/recipes-kernel/lttng/lttng-tools/0007-Fix-getgrnam-is-not-MT-Safe-use-getgrnam_r.patch
@@ -0,0 +1,345 @@
1From 10e8001ad876d8cb3b5a17c7492e713bbc047975 Mon Sep 17 00:00:00 2001
2From: Jonathan Rajotte <jonathan.rajotte-julien@efficios.com>
3Date: Thu, 28 Mar 2019 18:31:29 -0400
4Subject: [PATCH] Fix: getgrnam is not MT-Safe, use getgrnam_r
5
6Running the test suite under a Yocto musl build resulted in musl
7coredump due to double freeing.
8
9We get the following backtraces:
10
110 a_crash () at ./arch/x86_64/atomic_arch.h:108
121 unmap_chunk (self=<optimized out>) at src/malloc/malloc.c:515
132 free (p=<optimized out>) at src/malloc/malloc.c:526
143 0x00007f46d9dc3849 in __getgrent_a (f=f@entry=0x7f46d9d1f7e0, gr=gr@entry=0x7f46d9e24460 <gr>, line=line@entry=0x7f46d9e26058 <line>, size=size@entry=0x7f46d92db550, mem=mem@entry=0x7f46d9e26050 <mem>, nmem=nmem@entry=0x7f46d92db558, res=0x7f46d92db548) at src/passwd/getgrent_a.c:45
154 0x00007f46d9dc2e6b in __getgr_a (name=0x487242 "tracing", gid=gid@entry=0, gr=gr@entry=0x7f46d9e24460 <gr>, buf=buf@entry=0x7f46d9e26058 <line>, size=size@entry=0x7f46d92db550, mem=mem@entry=0x7f46d9e26050 <mem>, nmem=0x7f46d92db558, res=0x7f46d92db548) at src/passwd/getgr_a.c:30
165 0x00007f46d9dc3733 in getgrnam (name=<optimized out>) at src/passwd/getgrent.c:37
176 0x0000000000460b29 in utils_get_group_id (name=<optimized out>) at ../../../lttng-tools-2.10.6/src/common/utils.c:1241
187 0x000000000044ee69 in thread_manage_health (data=<optimized out>) at ../../../../lttng-tools-2.10.6/src/bin/lttng-sessiond/main.c:4115
198 0x00007f46d9de1541 in start (p=<optimized out>) at src/thread/pthread_create.c:195
209 0x00007f46d9dee661 in __clone () at src/thread/x86_64/clone.s:22
21
22From another run:
23
240 a_crash () at ./arch/x86_64/atomic_arch.h:108
251 unmap_chunk (self=<optimized out>) at src/malloc/malloc.c:515
262 free (p=<optimized out>) at src/malloc/malloc.c:526
273 0x00007f5abc210849 in __getgrent_a (f=f@entry=0x7f5abc2733e0, gr=gr@entry=0x7f5abc271460 <gr>, line=line@entry=0x7f5abc273058 <line>, size=size@entry=0x7f5abaef5510, mem=mem@entry=0x7f5abc273050 <mem>, nmem=nmem@entry=0x7f5abaef5518, res=0x7f5abaef5508) at src/passwd/getgrent_a.c:45
284 0x00007f5abc20fe6b in __getgr_a (name=0x487242 "tracing", gid=gid@entry=0, gr=gr@entry=0x7f5abc271460 <gr>, buf=buf@entry=0x7f5abc273058 <line>, size=size@entry=0x7f5abaef5510, mem=mem@entry=0x7f5abc273050 <mem>, nmem=0x7f5abaef5518, res=0x7f5abaef5508) at src/passwd/getgr_a.c:30
295 0x00007f5abc210733 in getgrnam (name=<optimized out>) at src/passwd/getgrent.c:37
306 0x0000000000460b29 in utils_get_group_id (name=<optimized out>) at ../../../lttng-tools-2.10.6/src/common/utils.c:1241
317 0x000000000042dee4 in notification_channel_socket_create () at ../../../../lttng-tools-2.10.6/src/bin/lttng-sessiond/notification-thread.c:238
328 init_thread_state (state=0x7f5abaef5560, handle=0x7f5abbf9be40) at ../../../../lttng-tools-2.10.6/src/bin/lttng-sessiond/notification-thread.c:375
339 thread_notification (data=0x7f5abbf9be40) at ../../../../lttng-tools-2.10.6/src/bin/lttng-sessiond/notification-thread.c:495
3410 0x00007f5abc22e541 in start (p=<optimized out>) at src/thread/pthread_create.c:195
3511 0x00007f5abc23b661 in __clone () at src/thread/x86_64/clone.s:22
36
37The problem was easily reproducible (~6 crash on ~300 runs). A prototype fix
38using mutex around the getgrnam yielded no crash in over 1000 runs. This
39patch yielded the same results as the prototype fix.
40
41Unfortunately we cannot rely on a mutex in liblttng-ctl since we cannot
42enforce the locking for the application using the lib.
43
44Use getgrnam_r instead.
45
46The previous implementation of utils_get_group_id returned the gid of
47the root group (0) on error/not found. lttng_check_tracing_group needs
48to know if an error/not found occured, returning the root group is not
49enough. We now return the gid via the passed parameter. The caller is
50responsible for either defaulting to the root group or propagating the
51error.
52
53We also do not want to warn when used in liblttng-ctl context. We might
54want to move the warning elsewhere in the future. For now, pass a bool
55if we need to warn or not.
56
57Signed-off-by: Jonathan Rajotte <jonathan.rajotte-julien@efficios.com>
58---
59 src/bin/lttng-consumerd/health-consumerd.c | 10 ++-
60 src/bin/lttng-relayd/health-relayd.c | 20 ++++--
61 src/bin/lttng-sessiond/main.c | 24 +++++--
62 src/bin/lttng-sessiond/notification-thread.c | 10 ++-
63 src/common/utils.c | 75 +++++++++++++++++---
64 src/common/utils.h | 4 +-
65 src/lib/lttng-ctl/lttng-ctl.c | 8 +--
66 7 files changed, 122 insertions(+), 29 deletions(-)
67
68diff --git a/src/bin/lttng-consumerd/health-consumerd.c b/src/bin/lttng-consumerd/health-consumerd.c
69index 1e2f31e4..6045401a 100644
70--- a/src/bin/lttng-consumerd/health-consumerd.c
71+++ b/src/bin/lttng-consumerd/health-consumerd.c
72@@ -184,8 +184,14 @@ void *thread_manage_health(void *data)
73 is_root = !getuid();
74 if (is_root) {
75 /* lttng health client socket path permissions */
76- ret = chown(health_unix_sock_path, 0,
77- utils_get_group_id(tracing_group_name));
78+ gid_t gid;
79+
80+ ret = utils_get_group_id(tracing_group_name, true, &gid);
81+ if (ret) {
82+ gid = 0; /* Default to root group. */
83+ }
84+
85+ ret = chown(health_unix_sock_path, 0, gid);
86 if (ret < 0) {
87 ERR("Unable to set group on %s", health_unix_sock_path);
88 PERROR("chown");
89diff --git a/src/bin/lttng-relayd/health-relayd.c b/src/bin/lttng-relayd/health-relayd.c
90index ba996621..962e88c4 100644
91--- a/src/bin/lttng-relayd/health-relayd.c
92+++ b/src/bin/lttng-relayd/health-relayd.c
93@@ -105,8 +105,14 @@ static int create_lttng_rundir_with_perm(const char *rundir)
94 int is_root = !getuid();
95
96 if (is_root) {
97- ret = chown(rundir, 0,
98- utils_get_group_id(tracing_group_name));
99+ gid_t gid;
100+
101+ ret = utils_get_group_id(tracing_group_name, true, &gid);
102+ if (ret) {
103+ gid = 0; /* Default to root group.*/
104+ }
105+
106+ ret = chown(rundir, 0, gid);
107 if (ret < 0) {
108 ERR("Unable to set group on %s", rundir);
109 PERROR("chown");
110@@ -256,8 +262,14 @@ void *thread_manage_health(void *data)
111 is_root = !getuid();
112 if (is_root) {
113 /* lttng health client socket path permissions */
114- ret = chown(health_unix_sock_path, 0,
115- utils_get_group_id(tracing_group_name));
116+ gid_t gid;
117+
118+ ret = utils_get_group_id(tracing_group_name, true, &gid);
119+ if (ret) {
120+ gid = 0; /* Default to root group */
121+ }
122+
123+ ret = chown(health_unix_sock_path, 0, gid);
124 if (ret < 0) {
125 ERR("Unable to set group on %s", health_unix_sock_path);
126 PERROR("chown");
127diff --git a/src/bin/lttng-sessiond/main.c b/src/bin/lttng-sessiond/main.c
128index fa6fa483..49307064 100644
129--- a/src/bin/lttng-sessiond/main.c
130+++ b/src/bin/lttng-sessiond/main.c
131@@ -4112,8 +4112,14 @@ static void *thread_manage_health(void *data)
132
133 if (is_root) {
134 /* lttng health client socket path permissions */
135- ret = chown(config.health_unix_sock_path.value, 0,
136- utils_get_group_id(config.tracing_group_name.value));
137+ gid_t gid;
138+
139+ ret = utils_get_group_id(config.tracing_group_name.value, true, &gid);
140+ if (ret) {
141+ gid = 0; /* Default to root group */
142+ }
143+
144+ ret = chown(config.health_unix_sock_path.value, 0, &gid);
145 if (ret < 0) {
146 ERR("Unable to set group on %s", config.health_unix_sock_path.value);
147 PERROR("chown");
148@@ -5238,7 +5244,10 @@ static int set_permissions(char *rundir)
149 int ret;
150 gid_t gid;
151
152- gid = utils_get_group_id(config.tracing_group_name.value);
153+ ret = utils_get_group_id(config.tracing_group_name.value, true, &gid);
154+ if (ret) {
155+ gid = 0; /* Default to root group */
156+ }
157
158 /* Set lttng run dir */
159 ret = chown(rundir, 0, gid);
160@@ -5349,7 +5358,14 @@ static int set_consumer_sockets(struct consumer_data *consumer_data)
161 goto error;
162 }
163 if (is_root) {
164- ret = chown(path, 0, utils_get_group_id(config.tracing_group_name.value));
165+ gid_t gid;
166+
167+ ret = utils_get_group_id(config.tracing_group_name.value, true, &gid);
168+ if (ret) {
169+ gid = 0; /* Default to root group */
170+ }
171+
172+ ret = chown(path, 0, gid);
173 if (ret < 0) {
174 ERR("Unable to set group on %s", path);
175 PERROR("chown");
176diff --git a/src/bin/lttng-sessiond/notification-thread.c b/src/bin/lttng-sessiond/notification-thread.c
177index 92ac597f..18a264d9 100644
178--- a/src/bin/lttng-sessiond/notification-thread.c
179+++ b/src/bin/lttng-sessiond/notification-thread.c
180@@ -235,8 +235,14 @@ int notification_channel_socket_create(void)
181 }
182
183 if (getuid() == 0) {
184- ret = chown(sock_path, 0,
185- utils_get_group_id(config.tracing_group_name.value));
186+ gid_t gid;
187+
188+ ret = utils_get_group_id(config.tracing_group_name.value, true, &gid);
189+ if (ret) {
190+ gid = 0; /* Default to root group. */
191+ }
192+
193+ ret = chown(sock_path, 0, gid);
194 if (ret) {
195 ERR("Failed to set the notification channel socket's group");
196 ret = -1;
197diff --git a/src/common/utils.c b/src/common/utils.c
198index c0bb031e..778bc00f 100644
199--- a/src/common/utils.c
200+++ b/src/common/utils.c
201@@ -1231,24 +1231,77 @@ size_t utils_get_current_time_str(const char *format, char *dst, size_t len)
202 }
203
204 /*
205- * Return the group ID matching name, else 0 if it cannot be found.
206+ * Return 0 on success and set *gid to the group_ID matching the passed name.
207+ * Else -1 if it cannot be found or an error occurred.
208 */
209 LTTNG_HIDDEN
210-gid_t utils_get_group_id(const char *name)
211+int utils_get_group_id(const char *name, bool warn, gid_t *gid)
212 {
213- struct group *grp;
214+ static volatile int warn_once;
215
216- grp = getgrnam(name);
217- if (!grp) {
218- static volatile int warn_once;
219+ int ret;
220+ long sys_len;
221+ size_t len;
222+ struct group grp;
223+ struct group *result;
224+ char *buffer = NULL;
225
226- if (!warn_once) {
227- WARN("No tracing group detected");
228- warn_once = 1;
229+ /* Get the system limit if it exists */
230+ sys_len = sysconf(_SC_GETGR_R_SIZE_MAX);
231+ if (sys_len == -1) {
232+ len = 1024;
233+ } else {
234+ len = (size_t) sys_len;
235+ }
236+
237+ buffer = malloc(len);
238+ if (!buffer) {
239+ PERROR("getgrnam_r malloc");
240+ ret = -1;
241+ goto error;
242+ }
243+
244+ while ((ret = getgrnam_r(name, &grp, buffer, len, &result)) == ERANGE)
245+ {
246+ /* Buffer is not big enough, increase its size. */
247+ size_t new_len = 2 * len;
248+ char *new_buffer = NULL;
249+ if (new_len < len) {
250+ ERR("getgrnam_r buffer size overflow");
251+ ret = -1;
252+ goto error;
253+ }
254+ len = new_len;
255+ new_buffer = realloc(buffer, len);
256+ if (!new_buffer) {
257+ PERROR("getgrnam_r realloc");
258+ ret = -1;
259+ goto error;
260 }
261- return 0;
262+ buffer = new_buffer;
263+ }
264+ if (ret != 0) {
265+ PERROR("getgrnam_r");
266+ ret = -1;
267+ goto error;
268+ }
269+
270+ /* Group not found. */
271+ if (!result) {
272+ ret = -1;
273+ goto error;
274+ }
275+
276+ *gid = result->gr_gid;
277+ ret = 0;
278+
279+error:
280+ free(buffer);
281+ if (ret && warn && !warn_once) {
282+ WARN("No tracing group detected");
283+ warn_once = 1;
284 }
285- return grp->gr_gid;
286+ return ret;
287 }
288
289 /*
290diff --git a/src/common/utils.h b/src/common/utils.h
291index 18f19ef1..9c72431d 100644
292--- a/src/common/utils.h
293+++ b/src/common/utils.h
294@@ -22,6 +22,8 @@
295 #include <unistd.h>
296 #include <stdint.h>
297 #include <getopt.h>
298+#include <stdbool.h>
299+#include <sys/types.h>
300
301 #define KIBI_LOG2 10
302 #define MEBI_LOG2 20
303@@ -52,7 +54,7 @@ int utils_get_count_order_u64(uint64_t x);
304 char *utils_get_home_dir(void);
305 char *utils_get_user_home_dir(uid_t uid);
306 size_t utils_get_current_time_str(const char *format, char *dst, size_t len);
307-gid_t utils_get_group_id(const char *name);
308+int utils_get_group_id(const char *name, bool warn, gid_t *gid);
309 char *utils_generate_optstring(const struct option *long_options,
310 size_t opt_count);
311 int utils_create_lock_file(const char *filepath);
312diff --git a/src/lib/lttng-ctl/lttng-ctl.c b/src/lib/lttng-ctl/lttng-ctl.c
313index 2d84aad9..561b0bcf 100644
314--- a/src/lib/lttng-ctl/lttng-ctl.c
315+++ b/src/lib/lttng-ctl/lttng-ctl.c
316@@ -208,15 +208,13 @@ end:
317 LTTNG_HIDDEN
318 int lttng_check_tracing_group(void)
319 {
320- struct group *grp_tracing; /* no free(). See getgrnam(3) */
321- gid_t *grp_list;
322+ gid_t *grp_list, tracing_gid;
323 int grp_list_size, grp_id, i;
324 int ret = -1;
325 const char *grp_name = tracing_group;
326
327 /* Get GID of group 'tracing' */
328- grp_tracing = getgrnam(grp_name);
329- if (!grp_tracing) {
330+ if (utils_get_group_id(grp_name, false, &tracing_gid)) {
331 /* If grp_tracing is NULL, the group does not exist. */
332 goto end;
333 }
334@@ -241,7 +239,7 @@ int lttng_check_tracing_group(void)
335 }
336
337 for (i = 0; i < grp_list_size; i++) {
338- if (grp_list[i] == grp_tracing->gr_gid) {
339+ if (grp_list[i] == tracing_gid) {
340 ret = 1;
341 break;
342 }
343--
3442.17.1
345