diff options
author | Alexander Kanavin <alex.kanavin@gmail.com> | 2021-10-11 11:40:36 +0200 |
---|---|---|
committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2021-10-29 11:17:26 +0100 |
commit | be011b75c0f67d1dad1dd288de3f697cab79b3a0 (patch) | |
tree | 31e02e06113d3605cfe1689da875d80b5e77d653 /meta/recipes-kernel/lttng | |
parent | 984e5e04aa291baf14c08a33277156db7559385e (diff) | |
download | poky-be011b75c0f67d1dad1dd288de3f697cab79b3a0.tar.gz |
lttng-tools: replace ad hoc ptest fixup with upstream fixes
(From OE-Core rev: e9613ecfcec8b606b05407b6199806df7ac18e9b)
Signed-off-by: Alexander Kanavin <alex@linutronix.de>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
(cherry picked from commit 87fd3080c86f6987e4403a2cb8263564f6e1ac4f)
Signed-off-by: Anuj Mittal <anuj.mittal@intel.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'meta/recipes-kernel/lttng')
4 files changed, 269 insertions, 89 deletions
diff --git a/meta/recipes-kernel/lttng/lttng-tools/0001-Fix-Tests-race-condition-in-test_event_tracker.patch b/meta/recipes-kernel/lttng/lttng-tools/0001-Fix-Tests-race-condition-in-test_event_tracker.patch new file mode 100644 index 0000000000..10020e1ecf --- /dev/null +++ b/meta/recipes-kernel/lttng/lttng-tools/0001-Fix-Tests-race-condition-in-test_event_tracker.patch | |||
@@ -0,0 +1,221 @@ | |||
1 | From d3392e4850532c02e53e3c3ff1cc27df7e51c941 Mon Sep 17 00:00:00 2001 | ||
2 | From: Francis Deslauriers <francis.deslauriers@efficios.com> | ||
3 | Date: Tue, 7 Sep 2021 17:10:31 -0400 | ||
4 | Subject: [PATCH 1/2] Fix: Tests: race condition in test_event_tracker | ||
5 | MIME-Version: 1.0 | ||
6 | Content-Type: text/plain; charset=UTF-8 | ||
7 | Content-Transfer-Encoding: 8bit | ||
8 | |||
9 | Background | ||
10 | ========== | ||
11 | The `test_event_tracker` file contains test cases when the event | ||
12 | generating app in executed in two distinct steps. Those two steps are | ||
13 | preparation and execution. | ||
14 | 1. the preparation is the launching the app in the background, and | ||
15 | 2. the execution is actually generating the event that should or | ||
16 | should not be traced depending on the test case. | ||
17 | |||
18 | This is useful to test the tracker feature since we want to ensure that | ||
19 | already running apps are notified properly when changing their tracking | ||
20 | status. | ||
21 | |||
22 | Issue | ||
23 | ===== | ||
24 | The `test_event_vpid_track_untrack` test case suffers from a race | ||
25 | condition that is easy to reproduce on Yocto. | ||
26 | |||
27 | The issue is that sometimes events are end up the trace when none is | ||
28 | expected. | ||
29 | |||
30 | This is due to the absence of synchronization point at the launch of the | ||
31 | app which leads to the app being scheduled in-between the track-untrack | ||
32 | calls leading to events being recorded to the trace. | ||
33 | |||
34 | It's easy to reproduce this issue on my machine by adding a `sleep 5` | ||
35 | between the track and untrack calls and setting the `NR_USEC_WAIT` | ||
36 | variable to 1. | ||
37 | |||
38 | Fix | ||
39 | === | ||
40 | Using the testapp `--sync-before-last-event-touch` flag to make the app | ||
41 | create a file when all but the last event are executed. We then have the | ||
42 | app wait until we create a file (`--sync-before-last-event`) to generate | ||
43 | that last event. This way, we are sure no event will be generated when | ||
44 | running the track and untrack commands. | ||
45 | |||
46 | Notes | ||
47 | ===== | ||
48 | - This issue affects other test cases in this file. | ||
49 | - This commit fixes a typo in the test header. | ||
50 | - This commit adds `diag` calls to help tracking to what test the output | ||
51 | relates to when reading the log. | ||
52 | |||
53 | Signed-off-by: Francis Deslauriers <francis.deslauriers@efficios.com> | ||
54 | Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com> | ||
55 | Change-Id: Ia2b68128dc9a805526f9748f31ec2c2d95566f31 | ||
56 | Upstream-Status: Backport | ||
57 | Signed-off-by: Alexander Kanavin <alex.kanavin@gmail.com> | ||
58 | --- | ||
59 | .../tools/tracker/test_event_tracker | 56 ++++++++++++++----- | ||
60 | 1 file changed, 42 insertions(+), 14 deletions(-) | ||
61 | |||
62 | diff --git a/tests/regression/tools/tracker/test_event_tracker b/tests/regression/tools/tracker/test_event_tracker | ||
63 | index feb3787..cc0f698 100755 | ||
64 | --- a/tests/regression/tools/tracker/test_event_tracker | ||
65 | +++ b/tests/regression/tools/tracker/test_event_tracker | ||
66 | @@ -5,7 +5,7 @@ | ||
67 | # | ||
68 | # SPDX-License-Identifier: GPL-2.0-only | ||
69 | |||
70 | -TEST_DESC="LTTng - Event traker test" | ||
71 | +TEST_DESC="LTTng - Event tracker test" | ||
72 | |||
73 | CURDIR=$(dirname "$0")/ | ||
74 | TESTDIR="$CURDIR/../../.." | ||
75 | @@ -15,7 +15,7 @@ TESTAPP_KERNEL_NAME="gen-kernel-test-events" | ||
76 | TESTAPP_BIN="$TESTAPP_PATH/$TESTAPP_NAME/$TESTAPP_NAME" | ||
77 | TESTAPP_KERNEL_BIN="$TESTAPP_PATH/$TESTAPP_KERNEL_NAME/$TESTAPP_KERNEL_NAME" | ||
78 | SESSION_NAME="tracker" | ||
79 | -NR_ITER=100 | ||
80 | +NR_ITER=1 | ||
81 | NUM_GLOBAL_TESTS=2 | ||
82 | NUM_UST_TESTS=283 | ||
83 | NUM_KERNEL_TESTS=462 | ||
84 | @@ -30,27 +30,41 @@ SCRIPT_GROUPNAME="$(id -gn)" | ||
85 | |||
86 | CHILD_PID=-1 | ||
87 | WAIT_PATH= | ||
88 | -AFTER_FIRST_PATH= | ||
89 | -BEFORE_LAST_PATH= | ||
90 | +TOUCH_BEFORE_LAST_PATH= | ||
91 | +SYNC_BEFORE_LAST_PATH= | ||
92 | |||
93 | source $TESTDIR/utils/utils.sh | ||
94 | |||
95 | +# Launch the testapp and execute it up until right before the last event. It is | ||
96 | +# useful to do it in two seperate steps in order to test tracking and | ||
97 | +# untracking on an active app. | ||
98 | function prepare_ust_app | ||
99 | { | ||
100 | - AFTER_FIRST_PATH=$(mktemp --tmpdir -u tmp.${FUNCNAME[0]}_sync_after_first.XXXXXX) | ||
101 | - BEFORE_LAST_PATH=$(mktemp --tmpdir -u tmp.${FUNCNAME[0]}_sync_before_last.XXXXXX) | ||
102 | + TOUCH_BEFORE_LAST_PATH=$(mktemp --tmpdir -u tmp.${FUNCNAME[0]}_touch_before_last.XXXXXX) | ||
103 | + SYNC_BEFORE_LAST_PATH=$(mktemp --tmpdir -u tmp.${FUNCNAME[0]}_sync_before_last.XXXXXX) | ||
104 | + | ||
105 | + $TESTAPP_BIN -i $NR_ITER -w $NR_USEC_WAIT \ | ||
106 | + --sync-before-last-event-touch "$TOUCH_BEFORE_LAST_PATH" \ | ||
107 | + --sync-before-last-event "$SYNC_BEFORE_LAST_PATH" & | ||
108 | |||
109 | - $TESTAPP_BIN -i $NR_ITER -w $NR_USEC_WAIT -a "$AFTER_FIRST_PATH" -b "$BEFORE_LAST_PATH" & | ||
110 | CHILD_PID=$! | ||
111 | + | ||
112 | + # Wait for the app to execute all the way to right before the last | ||
113 | + # event. | ||
114 | + while [ ! -f "${TOUCH_BEFORE_LAST_PATH}" ]; do | ||
115 | + sleep 0.5 | ||
116 | + done | ||
117 | } | ||
118 | |||
119 | +# Generate the last event. | ||
120 | function trace_ust_app | ||
121 | { | ||
122 | - touch "$BEFORE_LAST_PATH" | ||
123 | - wait | ||
124 | + # Ask the test app to generate the last event. | ||
125 | + touch "$SYNC_BEFORE_LAST_PATH" | ||
126 | + wait "$CHILD_PID" | ||
127 | ok $? "Traced application stopped." | ||
128 | - rm "$BEFORE_LAST_PATH" | ||
129 | - rm "$AFTER_FIRST_PATH" | ||
130 | + rm "$SYNC_BEFORE_LAST_PATH" | ||
131 | + rm "$TOUCH_BEFORE_LAST_PATH" | ||
132 | } | ||
133 | |||
134 | function prepare_kernel_app | ||
135 | @@ -64,7 +78,7 @@ function prepare_kernel_app | ||
136 | function trace_kernel_app | ||
137 | { | ||
138 | touch "$WAIT_PATH" | ||
139 | - wait | ||
140 | + wait "$CHILD_PID" | ||
141 | ok $? "Traced application stopped." | ||
142 | rm "$WAIT_PATH" | ||
143 | } | ||
144 | @@ -78,6 +92,8 @@ function test_event_tracker() | ||
145 | local tracker="$4" | ||
146 | local channel='' | ||
147 | |||
148 | + diag "${FUNCNAME[0]} $*" | ||
149 | + | ||
150 | trace_path=$(mktemp --tmpdir -d tmp.${FUNCNAME[0]}_trace_path.XXXXXX) | ||
151 | |||
152 | create_lttng_session_ok $SESSION_NAME "$trace_path" | ||
153 | @@ -117,6 +133,8 @@ function test_event_vpid_tracker() | ||
154 | local wildcard="$3" | ||
155 | local channel='' | ||
156 | |||
157 | + diag "${FUNCNAME[0]} $*" | ||
158 | + | ||
159 | trace_path=$(mktemp --tmpdir -d tmp.${FUNCNAME[0]}_trace_path.XXXXXX) | ||
160 | |||
161 | create_lttng_session_ok $SESSION_NAME "$trace_path" | ||
162 | @@ -160,6 +178,8 @@ function test_event_pid_tracker() | ||
163 | local wildcard="$3" | ||
164 | local channel='' | ||
165 | |||
166 | + diag "${FUNCNAME[0]} $*" | ||
167 | + | ||
168 | trace_path=$(mktemp --tmpdir -d tmp.${FUNCNAME[0]}_trace_path.XXXXXX) | ||
169 | |||
170 | create_lttng_session_ok $SESSION_NAME "$trace_path" | ||
171 | @@ -203,6 +223,8 @@ function test_event_tracker_fail() | ||
172 | local wildcard="$2" | ||
173 | local tracker="$3" | ||
174 | |||
175 | + diag "${FUNCNAME[0]} $*" | ||
176 | + | ||
177 | trace_path=$(mktemp --tmpdir -d tmp.${FUNCNAME[0]}_trace_path.XXXXXX) | ||
178 | |||
179 | create_lttng_session_ok $SESSION_NAME "$trace_path" | ||
180 | @@ -222,6 +244,8 @@ function test_event_track_untrack() | ||
181 | local tracker="$4" | ||
182 | local channel='' | ||
183 | |||
184 | + diag "${FUNCNAME[0]} $*" | ||
185 | + | ||
186 | trace_path=$(mktemp --tmpdir -d tmp.${FUNCNAME[0]}_trace_path.XXXXXX) | ||
187 | |||
188 | create_lttng_session_ok $SESSION_NAME "$trace_path" | ||
189 | @@ -262,6 +286,8 @@ function test_event_vpid_track_untrack() | ||
190 | local wildcard="$3" | ||
191 | local channel='' | ||
192 | |||
193 | + diag "${FUNCNAME[0]} $*" | ||
194 | + | ||
195 | trace_path=$(mktemp --tmpdir -d tmp.${FUNCNAME[0]}_trace_path.XXXXXX) | ||
196 | |||
197 | create_lttng_session_ok $SESSION_NAME "$trace_path" | ||
198 | @@ -302,6 +328,8 @@ function test_event_pid_track_untrack() | ||
199 | local wildcard="$3" | ||
200 | local channel='' | ||
201 | |||
202 | + diag "${FUNCNAME[0]} $*" | ||
203 | + | ||
204 | trace_path=$(mktemp --tmpdir -d tmp.${FUNCNAME[0]}_trace_path.XXXXXX) | ||
205 | |||
206 | create_lttng_session_ok $SESSION_NAME "$trace_path" | ||
207 | @@ -336,9 +364,9 @@ function test_event_pid_track_untrack() | ||
208 | |||
209 | function test_event_ust_vpid_untrack_snapshot() | ||
210 | { | ||
211 | - local trace_path=$(mktemp --tmpdir -d tmp.${FUNCNAME[0]}_trace_path.XXXXXX) | ||
212 | + diag "${FUNCNAME[0]} $*" | ||
213 | |||
214 | - diag "Test_event_ust_vpid_untrack_snapshot" | ||
215 | + local trace_path=$(mktemp --tmpdir -d tmp.${FUNCNAME[0]}_trace_path.XXXXXX) | ||
216 | |||
217 | create_lttng_session_ok $SESSION_NAME "$trace_path" "--snapshot" | ||
218 | |||
219 | -- | ||
220 | 2.20.1 | ||
221 | |||
diff --git a/meta/recipes-kernel/lttng/lttng-tools/0001-tests-wait-some-more-before-analysing-traces-or-star.patch b/meta/recipes-kernel/lttng/lttng-tools/0001-tests-wait-some-more-before-analysing-traces-or-star.patch deleted file mode 100644 index c4cac9cc58..0000000000 --- a/meta/recipes-kernel/lttng/lttng-tools/0001-tests-wait-some-more-before-analysing-traces-or-star.patch +++ /dev/null | |||
@@ -1,88 +0,0 @@ | |||
1 | From 8d9daede0882d239b0a47b0f7a6db68ba4934a7d Mon Sep 17 00:00:00 2001 | ||
2 | From: Alexander Kanavin <alex@linutronix.de> | ||
3 | Date: Sat, 4 Sep 2021 13:57:39 +0200 | ||
4 | Subject: [PATCH] tests: wait some more before analysing traces or starting | ||
5 | tracing | ||
6 | |||
7 | Otherwise, there are sporadic race failures where lttng tracing | ||
8 | is stopped before all expected events are collected or is started too soon, e.g.: | ||
9 | |||
10 | PASS: tools/tracker/test_event_tracker 205 - Traced application stopped. | ||
11 | PASS: tools/tracker/test_event_tracker 206 - Stop lttng tracing for session | ||
12 | PASS: tools/tracker/test_event_tracker 207 - Destroy session tracker | ||
13 | FAIL: tools/tracker/test_event_tracker 208 - Validate empty trace | ||
14 | |||
15 | PASS: ust/namespaces/test_ns_contexts_change 42 - Stop lttng tracing for session mnt_ns | ||
16 | PASS: ust/namespaces/test_ns_contexts_change 43 - Destroy session mnt_ns | ||
17 | PASS: ust/namespaces/test_ns_contexts_change 44 - Wait after kill session daemon | ||
18 | PASS: ust/namespaces/test_ns_contexts_change 45 - Validate trace for event mnt_ns = 4026531840, 1000 events | ||
19 | PASS: ust/namespaces/test_ns_contexts_change 46 - Read a total of 1000 events, expected 1000 | ||
20 | PASS: ust/namespaces/test_ns_contexts_change 47 - Validate trace for event mnt_ns = 4026532303, 233 events | ||
21 | FAIL: ust/namespaces/test_ns_contexts_change 48 - Read a total of 233 events, expected 1000 | ||
22 | |||
23 | This is a hack; issue should be fixed upstream with explicit syncs. | ||
24 | It has been reported here: https://bugs.lttng.org/issues/1217 | ||
25 | |||
26 | Upstream-Status: Inappropriate [needs a real fix] | ||
27 | Signed-off-by: Alexander Kanavin <alex@linutronix.de> | ||
28 | --- | ||
29 | tests/regression/tools/tracker/test_event_tracker | 8 ++++++++ | ||
30 | tests/regression/ust/namespaces/test_ns_contexts_change | 2 ++ | ||
31 | 2 files changed, 10 insertions(+) | ||
32 | |||
33 | diff --git a/tests/regression/tools/tracker/test_event_tracker b/tests/regression/tools/tracker/test_event_tracker | ||
34 | index feb3787..a0f2257 100755 | ||
35 | --- a/tests/regression/tools/tracker/test_event_tracker | ||
36 | +++ b/tests/regression/tools/tracker/test_event_tracker | ||
37 | @@ -130,6 +130,8 @@ function test_event_vpid_tracker() | ||
38 | |||
39 | prepare_"$domain"_app | ||
40 | |||
41 | +sleep 5 | ||
42 | + | ||
43 | start_lttng_tracing_ok | ||
44 | |||
45 | if [ "$expect_event" -eq 1 ]; then | ||
46 | @@ -173,6 +175,8 @@ function test_event_pid_tracker() | ||
47 | |||
48 | prepare_"$domain"_app | ||
49 | |||
50 | +sleep 5 | ||
51 | + | ||
52 | start_lttng_tracing_ok | ||
53 | |||
54 | if [ "$expect_event" -eq 1 ]; then | ||
55 | @@ -275,6 +279,8 @@ function test_event_vpid_track_untrack() | ||
56 | |||
57 | prepare_"$domain"_app | ||
58 | |||
59 | +sleep 5 | ||
60 | + | ||
61 | start_lttng_tracing_ok | ||
62 | |||
63 | lttng_track_"$domain"_ok "--vpid ${CHILD_PID}" | ||
64 | @@ -315,6 +321,8 @@ function test_event_pid_track_untrack() | ||
65 | |||
66 | prepare_"$domain"_app | ||
67 | |||
68 | +sleep 5 | ||
69 | + | ||
70 | start_lttng_tracing_ok | ||
71 | |||
72 | lttng_track_"$domain"_ok "--pid ${CHILD_PID}" | ||
73 | diff --git a/tests/regression/ust/namespaces/test_ns_contexts_change b/tests/regression/ust/namespaces/test_ns_contexts_change | ||
74 | index c0af15e..b111bfe 100755 | ||
75 | --- a/tests/regression/ust/namespaces/test_ns_contexts_change | ||
76 | +++ b/tests/regression/ust/namespaces/test_ns_contexts_change | ||
77 | @@ -79,6 +79,8 @@ function test_ns() | ||
78 | |||
79 | touch "$file_sync_before_last" | ||
80 | |||
81 | +sleep 5 | ||
82 | + | ||
83 | # stop and destroy | ||
84 | stop_lttng_tracing_ok "$session_name" | ||
85 | destroy_lttng_session_ok "$session_name" | ||
86 | -- | ||
87 | 2.20.1 | ||
88 | |||
diff --git a/meta/recipes-kernel/lttng/lttng-tools/0002-Fix-Tests-race-condition-in-test_ns_contexts_change.patch b/meta/recipes-kernel/lttng/lttng-tools/0002-Fix-Tests-race-condition-in-test_ns_contexts_change.patch new file mode 100644 index 0000000000..a8d983105a --- /dev/null +++ b/meta/recipes-kernel/lttng/lttng-tools/0002-Fix-Tests-race-condition-in-test_ns_contexts_change.patch | |||
@@ -0,0 +1,46 @@ | |||
1 | From d284752e616dfc4c9288be3bb21c04ea78cdd967 Mon Sep 17 00:00:00 2001 | ||
2 | From: Francis Deslauriers <francis.deslauriers@efficios.com> | ||
3 | Date: Wed, 8 Sep 2021 10:16:23 -0400 | ||
4 | Subject: [PATCH 2/2] Fix: Tests: race condition in test_ns_contexts_change | ||
5 | MIME-Version: 1.0 | ||
6 | Content-Type: text/plain; charset=UTF-8 | ||
7 | Content-Transfer-Encoding: 8bit | ||
8 | |||
9 | Issue | ||
10 | ===== | ||
11 | The test script doesn't wait for the test application to complete before | ||
12 | stopping the tracing session. The race is that depending on the | ||
13 | scheduling the application is not always done generating events when the | ||
14 | session is stopped. | ||
15 | |||
16 | Fix | ||
17 | === | ||
18 | Make the test script wait for the termination of the test app before | ||
19 | stopping the session. | ||
20 | |||
21 | Signed-off-by: Francis Deslauriers <francis.deslauriers@efficios.com> | ||
22 | Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com> | ||
23 | Change-Id: I29d9b41d2a2ed60a6c42020509c2067442ae332c | ||
24 | Upstream-Status: Backport | ||
25 | Signed-off-by: Alexander Kanavin <alex.kanavin@gmail.com> | ||
26 | --- | ||
27 | tests/regression/ust/namespaces/test_ns_contexts_change | 3 +++ | ||
28 | 1 file changed, 3 insertions(+) | ||
29 | |||
30 | diff --git a/tests/regression/ust/namespaces/test_ns_contexts_change b/tests/regression/ust/namespaces/test_ns_contexts_change | ||
31 | index c0af15e..8a4b62c 100755 | ||
32 | --- a/tests/regression/ust/namespaces/test_ns_contexts_change | ||
33 | +++ b/tests/regression/ust/namespaces/test_ns_contexts_change | ||
34 | @@ -79,6 +79,9 @@ function test_ns() | ||
35 | |||
36 | touch "$file_sync_before_last" | ||
37 | |||
38 | + # Wait for the test app to generate all expected events and exit. | ||
39 | + wait $app_pid | ||
40 | + | ||
41 | # stop and destroy | ||
42 | stop_lttng_tracing_ok "$session_name" | ||
43 | destroy_lttng_session_ok "$session_name" | ||
44 | -- | ||
45 | 2.20.1 | ||
46 | |||
diff --git a/meta/recipes-kernel/lttng/lttng-tools_2.13.0.bb b/meta/recipes-kernel/lttng/lttng-tools_2.13.0.bb index 47cab42fcf..1491aff618 100644 --- a/meta/recipes-kernel/lttng/lttng-tools_2.13.0.bb +++ b/meta/recipes-kernel/lttng/lttng-tools_2.13.0.bb | |||
@@ -37,7 +37,8 @@ SRC_URI = "https://lttng.org/files/lttng-tools/lttng-tools-${PV}.tar.bz2 \ | |||
37 | file://lttng-sessiond.service \ | 37 | file://lttng-sessiond.service \ |
38 | file://determinism.patch \ | 38 | file://determinism.patch \ |
39 | file://0001-src-common-correct-header-location.patch \ | 39 | file://0001-src-common-correct-header-location.patch \ |
40 | file://0001-tests-wait-some-more-before-analysing-traces-or-star.patch \ | 40 | file://0001-Fix-Tests-race-condition-in-test_event_tracker.patch \ |
41 | file://0002-Fix-Tests-race-condition-in-test_ns_contexts_change.patch \ | ||
41 | " | 42 | " |
42 | 43 | ||
43 | SRC_URI[sha256sum] = "8dc894f9a7a840e943c1c344345c75f001a9529daa9157f1a0e6175c081c29e6" | 44 | SRC_URI[sha256sum] = "8dc894f9a7a840e943c1c344345c75f001a9529daa9157f1a0e6175c081c29e6" |