diff options
Diffstat (limited to 'meta/recipes-kernel/lttng/lttng-tools/0001-Fix-Tests-race-condition-in-test_event_tracker.patch')
-rw-r--r-- | meta/recipes-kernel/lttng/lttng-tools/0001-Fix-Tests-race-condition-in-test_event_tracker.patch | 221 |
1 files changed, 221 insertions, 0 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 | |||