Commit | Line | Data |
---|---|---|
0e115563 DG |
1 | #!/bin/bash |
2 | # | |
dd238d2a | 3 | # Copyright (C) - 2015 Philippe Proulx <pproulx@efficios.com> |
0e115563 DG |
4 | # Copyright (C) - 2014 David Goulet <dgoulet@efficios.com> |
5 | # | |
6 | # This program is free software; you can redistribute it and/or modify it under | |
7 | # the terms of the GNU General Public License, version 2 only, as published by | |
8 | # the Free Software Foundation. | |
9 | # | |
10 | # This program is distributed in the hope that it will be useful, but WITHOUT | |
11 | # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS | |
12 | # FOR A PARTICULAR PURPOSE. See the GNU General Public License for more | |
13 | # details. | |
14 | # | |
15 | # You should have received a copy of the GNU General Public License along with | |
16 | # this program; if not, write to the Free Software Foundation, Inc., 51 | |
17 | # Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. | |
18 | ||
dd238d2a | 19 | TEST_DESC="Python support" |
0e115563 DG |
20 | |
21 | CURDIR=$(dirname $0)/ | |
22 | TESTDIR=$CURDIR/../../.. | |
23 | NR_ITER=5 | |
9586c198 | 24 | NR_SEC_WAIT=0 |
dd238d2a | 25 | TESTAPP_NAME="test" |
0e115563 | 26 | TESTAPP_BIN="$TESTAPP_NAME.py" |
840f7858 | 27 | TESTAPP_PATH="@abs_top_srcdir@/tests/regression/ust/python-logging" |
0e115563 DG |
28 | SESSION_NAME="python-test" |
29 | EVENT_NAME="python-ev-test1" | |
30 | EVENT_NAME2="python-ev-test2" | |
31 | OUTPUT_DEST="/dev/null" | |
32 | ||
9586c198 JR |
33 | python_versions=(@PYTHON2_AGENT@ @PYTHON3_AGENT@) |
34 | run_test=@RUN_PYTHON_AGENT_TEST@ | |
35 | ||
36 | if [[ -z "$run_test" ]]; then | |
37 | NUM_TESTS=1 | |
38 | else | |
aed7bbd2 | 39 | NUM_TESTS=$(((194 * ${#python_versions[@]})+2)) |
9586c198 | 40 | fi |
0e115563 DG |
41 | |
42 | source $TESTDIR/utils/utils.sh | |
43 | ||
44 | function run_app | |
45 | { | |
dd238d2a PP |
46 | local python=$1 |
47 | local debug_tp=$2 | |
48 | local fire_second_tp=$3 | |
25e9873d JR |
49 | local ready_file=$4 |
50 | local go_file=$5 | |
74f2abd5 | 51 | local opt="" |
0e115563 | 52 | |
74f2abd5 JR |
53 | if [[ -n "$debug_tp" ]] && [ "$debug_tp" -eq "1" ]; then |
54 | opt="${opt} -d" | |
55 | fi | |
56 | ||
57 | if [[ -n "$fire_second_tp" ]] && [ "$fire_second_tp" -eq "1" ]; then | |
58 | opt="${opt} -e" | |
59 | fi | |
60 | ||
25e9873d JR |
61 | if [[ -n "$ready_file" ]]; then |
62 | opt="${opt} -r ${ready_file}" | |
63 | fi | |
64 | ||
65 | if [[ -n "$go_file" ]]; then | |
66 | opt="${opt} -g ${go_file}" | |
67 | fi | |
68 | ||
69 | set -x | |
74f2abd5 | 70 | $python $TESTAPP_PATH/$TESTAPP_BIN -n $NR_ITER -s $NR_SEC_WAIT $opt |
25e9873d | 71 | set +x |
0e115563 DG |
72 | } |
73 | ||
74 | function run_app_background | |
75 | { | |
25e9873d | 76 | run_app "$@" & |
0e115563 DG |
77 | } |
78 | ||
79 | function enable_python_loglevel_only() | |
80 | { | |
81 | sess_name=$1 | |
82 | event_name="$2" | |
83 | loglevel=$3 | |
84 | channel_name=$4 | |
85 | ||
86 | if [ -z $channel_name ]; then | |
87 | # default channel if none specified | |
88 | chan="" | |
89 | else | |
90 | chan="-c $channel_name" | |
91 | fi | |
92 | ||
93 | $TESTDIR/../src/bin/lttng/$LTTNG_BIN enable-event --loglevel-only $loglevel "$event_name" $chan -s $sess_name -p >$OUTPUT_DEST | |
94 | ok $? "Enable Python event $event_name for session $sess_name with loglevel-only $loglevel" | |
95 | } | |
96 | ||
97 | function enable_python_filter() | |
98 | { | |
99 | local sess_name="$1" | |
100 | local event_name="$2" | |
101 | local filter="$3" | |
102 | ||
9586c198 | 103 | $TESTDIR/../src/bin/lttng/$LTTNG_BIN enable-event "$event_name" -s $sess_name -p --filter "$filter" >$OUTPUT_DEST |
0e115563 DG |
104 | ok $? "Enable event $event_name with filter $filter for session $sess_name" |
105 | } | |
106 | ||
107 | function enable_python_filter_loglevel_only() | |
108 | { | |
109 | local sess_name="$1" | |
110 | local event_name="$2" | |
111 | local filter="$3" | |
112 | local loglevel="$4" | |
113 | ||
114 | $TESTDIR/../src/bin/lttng/$LTTNG_BIN enable-event --loglevel-only $loglevel "$event_name" -s $sess_name -p --filter "$filter" >$OUTPUT_DEST | |
115 | ok $? "Enable event $event_name with filter \"$filter\" and loglevel-only $loglevel for session $sess_name" | |
116 | } | |
117 | ||
118 | # MUST set TESTDIR before calling those functions | |
119 | ||
120 | function test_python_before_start () | |
121 | { | |
25e9873d JR |
122 | local ready_file=$(mktemp -u) |
123 | local go_file=$(mktemp -u) | |
124 | ||
0e115563 | 125 | diag "Test Python application BEFORE tracing starts" |
bf6ae429 | 126 | create_lttng_session_ok $SESSION_NAME $TRACE_PATH |
0e115563 DG |
127 | enable_python_lttng_event $SESSION_NAME $EVENT_NAME |
128 | ||
129 | # Run 5 times with a 1 second delay | |
25e9873d JR |
130 | run_app_background $1 "" "" $ready_file $go_file |
131 | ||
132 | # Wait for ready file | |
133 | while [ ! -e ${ready_file} ]; do | |
134 | sleep 0.5 | |
135 | done | |
0e115563 | 136 | |
e563bbdb | 137 | start_lttng_tracing_ok $SESSION_NAME |
0e115563 DG |
138 | |
139 | # Wait for the applications started in background | |
25e9873d | 140 | echo "1" > ${go_file} |
0fc2834c | 141 | wait |
0e115563 | 142 | |
96340a01 | 143 | stop_lttng_tracing_ok $SESSION_NAME |
67b4c664 | 144 | destroy_lttng_session_ok $SESSION_NAME |
0e115563 DG |
145 | |
146 | # Validate test. Expecting all events. | |
147 | trace_match_only $EVENT_NAME $NR_ITER $TRACE_PATH | |
148 | if [ $? -ne 0 ]; then | |
149 | return $? | |
150 | fi | |
25e9873d JR |
151 | |
152 | rm $go_file | |
0e115563 DG |
153 | } |
154 | ||
155 | function test_python_after_start () | |
156 | { | |
157 | diag "Test Python application AFTER tracing starts" | |
158 | ||
bf6ae429 | 159 | create_lttng_session_ok $SESSION_NAME $TRACE_PATH |
0e115563 | 160 | enable_python_lttng_event $SESSION_NAME $EVENT_NAME |
e563bbdb | 161 | start_lttng_tracing_ok $SESSION_NAME |
0e115563 DG |
162 | |
163 | # Run 5 times with a 1 second delay | |
dd238d2a | 164 | run_app $1 |
0e115563 | 165 | |
96340a01 | 166 | stop_lttng_tracing_ok $SESSION_NAME |
67b4c664 | 167 | destroy_lttng_session_ok $SESSION_NAME |
0e115563 DG |
168 | |
169 | # Validate test. Expecting all events. | |
170 | trace_match_only $EVENT_NAME $NR_ITER $TRACE_PATH | |
171 | if [ $? -ne 0 ]; then | |
172 | return $? | |
173 | fi | |
174 | } | |
175 | ||
176 | function test_python_loglevel () | |
177 | { | |
178 | diag "Test Python application with loglevel" | |
179 | ||
bf6ae429 | 180 | create_lttng_session_ok $SESSION_NAME $TRACE_PATH |
0e115563 | 181 | enable_python_lttng_event_loglevel $SESSION_NAME $EVENT_NAME "INFO" |
e563bbdb | 182 | start_lttng_tracing_ok $SESSION_NAME |
0e115563 DG |
183 | |
184 | # Run 5 times with a 1 second delay | |
dd238d2a | 185 | run_app $1 |
0e115563 | 186 | |
96340a01 | 187 | stop_lttng_tracing_ok $SESSION_NAME |
67b4c664 | 188 | destroy_lttng_session_ok $SESSION_NAME |
0e115563 DG |
189 | |
190 | # Validate test. Expecting all events. | |
191 | trace_match_only $EVENT_NAME $NR_ITER $TRACE_PATH | |
192 | if [ $? -ne 0 ]; then | |
193 | return $? | |
194 | fi | |
195 | ||
196 | diag "Test Python applications with lower loglevel" | |
197 | ||
bf6ae429 | 198 | create_lttng_session_ok $SESSION_NAME $TRACE_PATH |
0e115563 | 199 | enable_python_lttng_event_loglevel $SESSION_NAME $EVENT_NAME "CRITICAL" |
e563bbdb | 200 | start_lttng_tracing_ok $SESSION_NAME |
0e115563 DG |
201 | |
202 | # Run 5 times with a 1 second delay | |
dd238d2a | 203 | run_app $1 |
0e115563 | 204 | |
96340a01 | 205 | stop_lttng_tracing_ok $SESSION_NAME |
67b4c664 | 206 | destroy_lttng_session_ok $SESSION_NAME |
0e115563 DG |
207 | |
208 | # Validate test. Expecting 0 events. | |
209 | trace_match_only $EVENT_NAME 0 $TRACE_PATH | |
210 | if [ $? -ne 0 ]; then | |
211 | return $? | |
212 | fi | |
213 | ||
214 | diag "Test Python applications with higher loglevel" | |
215 | ||
bf6ae429 | 216 | create_lttng_session_ok $SESSION_NAME $TRACE_PATH |
0e115563 | 217 | enable_python_lttng_event_loglevel $SESSION_NAME $EVENT_NAME "DEBUG" |
e563bbdb | 218 | start_lttng_tracing_ok $SESSION_NAME |
0e115563 DG |
219 | |
220 | # Run 5 times with a 1 second delay | |
dd238d2a | 221 | run_app $1 |
0e115563 | 222 | |
96340a01 | 223 | stop_lttng_tracing_ok $SESSION_NAME |
67b4c664 | 224 | destroy_lttng_session_ok $SESSION_NAME |
0e115563 DG |
225 | |
226 | # Validate test. Expecting all events. | |
227 | trace_match_only $EVENT_NAME $NR_ITER $TRACE_PATH | |
228 | return $? | |
229 | } | |
230 | ||
231 | function test_python_loglevel_multiple () | |
232 | { | |
233 | diag "Test Python application with multiple loglevel" | |
234 | ||
bf6ae429 | 235 | create_lttng_session_ok $SESSION_NAME $TRACE_PATH |
0e115563 DG |
236 | enable_python_lttng_event_loglevel $SESSION_NAME $EVENT_NAME "INFO" |
237 | enable_python_lttng_event_loglevel $SESSION_NAME $EVENT_NAME "DEBUG" | |
e563bbdb | 238 | start_lttng_tracing_ok $SESSION_NAME |
0e115563 DG |
239 | |
240 | # Run 5 times with a 1 second delay and fire two TP. | |
dd238d2a | 241 | run_app $1 1 |
0e115563 | 242 | |
96340a01 | 243 | stop_lttng_tracing_ok $SESSION_NAME |
67b4c664 | 244 | destroy_lttng_session_ok $SESSION_NAME |
0e115563 DG |
245 | |
246 | # Validate test. Expecting all events times two. | |
247 | trace_match_only $EVENT_NAME $(($NR_ITER * 2)) $TRACE_PATH | |
248 | if [ $? -ne 0 ]; then | |
249 | return $? | |
250 | fi | |
251 | ||
bf6ae429 | 252 | create_lttng_session_ok $SESSION_NAME $TRACE_PATH |
0e115563 DG |
253 | enable_python_lttng_event_loglevel $SESSION_NAME '*' "INFO" |
254 | enable_python_lttng_event_loglevel $SESSION_NAME '*' "DEBUG" | |
e563bbdb | 255 | start_lttng_tracing_ok $SESSION_NAME |
0e115563 DG |
256 | |
257 | # Run 5 times with a 1 second delay and fire two TP. | |
dd238d2a | 258 | run_app $1 1 |
0e115563 | 259 | |
96340a01 | 260 | stop_lttng_tracing_ok $SESSION_NAME |
67b4c664 | 261 | destroy_lttng_session_ok $SESSION_NAME |
0e115563 DG |
262 | |
263 | # Validate test. Expecting all events times two. | |
264 | trace_match_only $EVENT_NAME $(($NR_ITER * 2)) $TRACE_PATH | |
265 | if [ $? -ne 0 ]; then | |
266 | return $? | |
267 | fi | |
268 | } | |
269 | ||
270 | function test_python_multi_session_loglevel() | |
271 | { | |
272 | diag "Test Python with multiple session" | |
273 | ||
bf6ae429 | 274 | create_lttng_session_ok $SESSION_NAME-1 $TRACE_PATH/$SESSION_NAME-1 |
0e115563 | 275 | enable_python_loglevel_only $SESSION_NAME-1 '*' "INFO" |
e563bbdb | 276 | start_lttng_tracing_ok $SESSION_NAME-1 |
0e115563 | 277 | |
bf6ae429 | 278 | create_lttng_session_ok $SESSION_NAME-2 $TRACE_PATH/$SESSION_NAME-2 |
0e115563 | 279 | enable_python_loglevel_only $SESSION_NAME-2 '*' "DEBUG" |
e563bbdb | 280 | start_lttng_tracing_ok $SESSION_NAME-2 |
0e115563 DG |
281 | |
282 | # Run 5 times with a 1 second delay and fire second TP. | |
dd238d2a | 283 | run_app $1 1 1 |
0e115563 | 284 | |
96340a01 JR |
285 | stop_lttng_tracing_ok $SESSION_NAME-1 |
286 | stop_lttng_tracing_ok $SESSION_NAME-2 | |
67b4c664 JR |
287 | destroy_lttng_session_ok $SESSION_NAME-1 |
288 | destroy_lttng_session_ok $SESSION_NAME-2 | |
0e115563 DG |
289 | |
290 | # Expecting NR_ITER events being the main event and the second tp one. | |
291 | trace_matches $EVENT_NAME $NR_ITER $TRACE_PATH/$SESSION_NAME-1 | |
292 | if [ $? -ne 0 ]; then | |
293 | return $? | |
294 | fi | |
295 | trace_matches $EVENT_NAME2 1 $TRACE_PATH/$SESSION_NAME-1 | |
296 | if [ $? -ne 0 ]; then | |
297 | return $? | |
298 | fi | |
299 | ||
300 | # Expectin NR_ITER events being the debug TP. | |
301 | trace_match_only $EVENT_NAME $NR_ITER $TRACE_PATH/$SESSION_NAME-2 | |
302 | if [ $? -ne 0 ]; then | |
303 | return $? | |
304 | fi | |
305 | } | |
306 | ||
307 | function test_python_multi_session_disable() | |
308 | { | |
309 | diag "Test Python with multiple session with disabled event" | |
310 | ||
bf6ae429 | 311 | create_lttng_session_ok $SESSION_NAME-1 $TRACE_PATH/$SESSION_NAME-1 |
0e115563 DG |
312 | enable_python_lttng_event $SESSION_NAME-1 $EVENT_NAME |
313 | enable_python_lttng_event $SESSION_NAME-1 $EVENT_NAME2 | |
314 | disable_python_lttng_event $SESSION_NAME-1 $EVENT_NAME | |
e563bbdb | 315 | start_lttng_tracing_ok $SESSION_NAME-1 |
0e115563 | 316 | |
bf6ae429 | 317 | create_lttng_session_ok $SESSION_NAME-2 $TRACE_PATH/$SESSION_NAME-2 |
0e115563 | 318 | enable_python_lttng_event $SESSION_NAME-2 $EVENT_NAME2 |
e563bbdb | 319 | start_lttng_tracing_ok $SESSION_NAME-2 |
0e115563 DG |
320 | |
321 | # Run 5 times with a 1 second delay and fire second TP. | |
dd238d2a | 322 | run_app $1 0 1 |
0e115563 | 323 | |
96340a01 JR |
324 | stop_lttng_tracing_ok $SESSION_NAME-1 |
325 | stop_lttng_tracing_ok $SESSION_NAME-2 | |
67b4c664 JR |
326 | destroy_lttng_session_ok $SESSION_NAME-1 |
327 | destroy_lttng_session_ok $SESSION_NAME-2 | |
0e115563 DG |
328 | |
329 | # Validate test. Expecting one event of the second TP. | |
330 | trace_match_only $EVENT_NAME2 1 $TRACE_PATH/$SESSION_NAME-1 | |
331 | if [ $? -ne 0 ]; then | |
332 | return $? | |
333 | fi | |
334 | ||
335 | # Validate test. Expecting one event of the second TP. | |
336 | trace_match_only $EVENT_NAME2 1 $TRACE_PATH/$SESSION_NAME-2 | |
337 | if [ $? -ne 0 ]; then | |
338 | return $? | |
339 | fi | |
340 | } | |
341 | ||
342 | function test_python_multi_session_disable_wildcard() | |
343 | { | |
344 | diag "Test Python with multiple session with disabled wildcard event" | |
345 | ||
bf6ae429 | 346 | create_lttng_session_ok $SESSION_NAME-1 $TRACE_PATH/$SESSION_NAME-1 |
0e115563 DG |
347 | enable_python_lttng_event $SESSION_NAME-1 '*' |
348 | ||
bf6ae429 | 349 | create_lttng_session_ok $SESSION_NAME-2 $TRACE_PATH/$SESSION_NAME-2 |
0e115563 DG |
350 | enable_python_lttng_event $SESSION_NAME-2 '*' |
351 | ||
352 | disable_python_lttng_event $SESSION_NAME-1 '*' | |
353 | ||
e563bbdb JR |
354 | start_lttng_tracing_ok $SESSION_NAME-1 |
355 | start_lttng_tracing_ok $SESSION_NAME-2 | |
0e115563 | 356 | |
dd238d2a | 357 | run_app $1 |
0e115563 | 358 | |
96340a01 JR |
359 | stop_lttng_tracing_ok $SESSION_NAME-1 |
360 | stop_lttng_tracing_ok $SESSION_NAME-2 | |
67b4c664 JR |
361 | destroy_lttng_session_ok $SESSION_NAME-1 |
362 | destroy_lttng_session_ok $SESSION_NAME-2 | |
0e115563 DG |
363 | |
364 | # Validate test. Expecting NO event of the first TP. | |
365 | trace_match_only $EVENT_NAME 0 $TRACE_PATH/$SESSION_NAME-1 | |
366 | if [ $? -ne 0 ]; then | |
367 | return $? | |
368 | fi | |
369 | ||
370 | # Validate test. Expecting all events of the first TP. | |
371 | trace_match_only $EVENT_NAME $NR_ITER $TRACE_PATH/$SESSION_NAME-2 | |
372 | if [ $? -ne 0 ]; then | |
373 | return $? | |
374 | fi | |
375 | } | |
376 | ||
aed7bbd2 PP |
377 | function test_python_multi_session_disable_wildcard_begin() |
378 | { | |
379 | ev_name='*ev-test1' | |
380 | diag "Test Python with multiple session with disabled wildcard (at the beginning) event" | |
381 | ||
382 | create_lttng_session_ok $SESSION_NAME-1 $TRACE_PATH/$SESSION_NAME-1 | |
383 | enable_python_lttng_event $SESSION_NAME-1 "$ev_name" | |
384 | ||
385 | create_lttng_session_ok $SESSION_NAME-2 $TRACE_PATH/$SESSION_NAME-2 | |
386 | enable_python_lttng_event $SESSION_NAME-2 "$ev_name" | |
387 | ||
388 | disable_python_lttng_event $SESSION_NAME-1 "$ev_name" | |
389 | ||
390 | start_lttng_tracing_ok $SESSION_NAME-1 | |
391 | start_lttng_tracing_ok $SESSION_NAME-2 | |
392 | ||
393 | run_app $1 0 1 | |
394 | ||
395 | stop_lttng_tracing_ok $SESSION_NAME-1 | |
396 | stop_lttng_tracing_ok $SESSION_NAME-2 | |
397 | destroy_lttng_session_ok $SESSION_NAME-1 | |
398 | destroy_lttng_session_ok $SESSION_NAME-2 | |
399 | ||
400 | # Validate test. Expecting NO event of the first TP. | |
401 | trace_match_only $EVENT_NAME 0 $TRACE_PATH/$SESSION_NAME-1 | |
402 | if [ $? -ne 0 ]; then | |
403 | return $? | |
404 | fi | |
405 | ||
406 | # Validate test. Expecting all events of the first TP. | |
407 | trace_match_only $EVENT_NAME $NR_ITER $TRACE_PATH/$SESSION_NAME-2 | |
408 | if [ $? -ne 0 ]; then | |
409 | return $? | |
410 | fi | |
411 | } | |
412 | ||
413 | function test_python_multi_session_disable_wildcard_middle() | |
414 | { | |
415 | ev_name='python-*-test1' | |
416 | diag "Test Python with multiple session with disabled wildcard (at the middle) event" | |
417 | ||
418 | create_lttng_session_ok $SESSION_NAME-1 $TRACE_PATH/$SESSION_NAME-1 | |
419 | enable_python_lttng_event $SESSION_NAME-1 "$ev_name" | |
420 | ||
421 | create_lttng_session_ok $SESSION_NAME-2 $TRACE_PATH/$SESSION_NAME-2 | |
422 | enable_python_lttng_event $SESSION_NAME-2 "$ev_name" | |
423 | ||
424 | disable_python_lttng_event $SESSION_NAME-1 "$ev_name" | |
425 | ||
426 | start_lttng_tracing_ok $SESSION_NAME-1 | |
427 | start_lttng_tracing_ok $SESSION_NAME-2 | |
428 | ||
429 | run_app $1 0 1 | |
430 | ||
431 | stop_lttng_tracing_ok $SESSION_NAME-1 | |
432 | stop_lttng_tracing_ok $SESSION_NAME-2 | |
433 | destroy_lttng_session_ok $SESSION_NAME-1 | |
434 | destroy_lttng_session_ok $SESSION_NAME-2 | |
435 | ||
436 | # Validate test. Expecting NO event of the first TP. | |
437 | trace_match_only $EVENT_NAME 0 $TRACE_PATH/$SESSION_NAME-1 | |
438 | if [ $? -ne 0 ]; then | |
439 | return $? | |
440 | fi | |
441 | ||
442 | # Validate test. Expecting all events of the first TP. | |
443 | trace_match_only $EVENT_NAME $NR_ITER $TRACE_PATH/$SESSION_NAME-2 | |
444 | if [ $? -ne 0 ]; then | |
445 | return $? | |
446 | fi | |
447 | } | |
448 | ||
449 | function test_python_multi_session_disable_wildcard_end() | |
450 | { | |
451 | ev_name='python-*' | |
452 | diag "Test Python with multiple session with disabled wildcard (at the end) event" | |
453 | ||
454 | create_lttng_session_ok $SESSION_NAME-1 $TRACE_PATH/$SESSION_NAME-1 | |
455 | enable_python_lttng_event $SESSION_NAME-1 "$ev_name" | |
456 | ||
457 | create_lttng_session_ok $SESSION_NAME-2 $TRACE_PATH/$SESSION_NAME-2 | |
458 | enable_python_lttng_event $SESSION_NAME-2 "$ev_name" | |
459 | ||
460 | disable_python_lttng_event $SESSION_NAME-1 "$ev_name" | |
461 | ||
462 | start_lttng_tracing_ok $SESSION_NAME-1 | |
463 | start_lttng_tracing_ok $SESSION_NAME-2 | |
464 | ||
465 | run_app $1 0 1 | |
466 | ||
467 | stop_lttng_tracing_ok $SESSION_NAME-1 | |
468 | stop_lttng_tracing_ok $SESSION_NAME-2 | |
469 | destroy_lttng_session_ok $SESSION_NAME-1 | |
470 | destroy_lttng_session_ok $SESSION_NAME-2 | |
471 | ||
472 | # Validate test. Expecting NO event of the first TP. | |
473 | trace_match_only $EVENT_NAME 0 $TRACE_PATH/$SESSION_NAME-1 | |
474 | if [ $? -ne 0 ]; then | |
475 | return $? | |
476 | fi | |
477 | ||
478 | # Validate test. Expecting all events of the first TP. | |
479 | trace_matches $EVENT_NAME $NR_ITER $TRACE_PATH/$SESSION_NAME-2 | |
480 | if [ $? -ne 0 ]; then | |
481 | return $? | |
482 | fi | |
483 | ||
484 | trace_matches $EVENT_NAME2 1 $TRACE_PATH/$SESSION_NAME-2 | |
485 | if [ $? -ne 0 ]; then | |
486 | return $? | |
487 | fi | |
488 | } | |
489 | ||
0e115563 DG |
490 | function test_python_disable_all() |
491 | { | |
492 | diag "Test Python with multiple session with disabled all event" | |
493 | ||
bf6ae429 | 494 | create_lttng_session_ok $SESSION_NAME $TRACE_PATH/$SESSION_NAME |
0e115563 DG |
495 | enable_python_lttng_event $SESSION_NAME '*' |
496 | enable_python_lttng_event $SESSION_NAME $EVENT_NAME | |
497 | enable_python_lttng_event $SESSION_NAME $EVENT_NAME2 | |
498 | ||
b3639870 | 499 | disable_python_lttng_event $SESSION_NAME -a |
0e115563 | 500 | |
e563bbdb | 501 | start_lttng_tracing_ok $SESSION_NAME |
0e115563 | 502 | |
dd238d2a | 503 | run_app $1 0 1 |
0e115563 | 504 | |
96340a01 | 505 | stop_lttng_tracing_ok $SESSION_NAME |
67b4c664 | 506 | destroy_lttng_session_ok $SESSION_NAME |
0e115563 DG |
507 | |
508 | # Validate test. Expecting NO event of the first TP and second TP. | |
509 | trace_match_only $EVENT_NAME 0 $TRACE_PATH/$SESSION_NAME | |
510 | trace_match_only $EVENT_NAME2 0 $TRACE_PATH/$SESSION_NAME | |
511 | if [ $? -ne 0 ]; then | |
512 | return $? | |
513 | fi | |
514 | } | |
515 | ||
516 | function test_python_multi_session() | |
517 | { | |
518 | diag "Test Python with multiple session" | |
519 | ||
bf6ae429 | 520 | create_lttng_session_ok $SESSION_NAME-1 $TRACE_PATH/$SESSION_NAME-1 |
0e115563 | 521 | enable_python_lttng_event $SESSION_NAME-1 $EVENT_NAME |
e563bbdb | 522 | start_lttng_tracing_ok $SESSION_NAME-1 |
0e115563 | 523 | |
bf6ae429 | 524 | create_lttng_session_ok $SESSION_NAME-2 $TRACE_PATH/$SESSION_NAME-2 |
0e115563 | 525 | enable_python_lttng_event $SESSION_NAME-2 $EVENT_NAME2 |
e563bbdb | 526 | start_lttng_tracing_ok $SESSION_NAME-2 |
0e115563 DG |
527 | |
528 | # Run 5 times with a 1 second delay and fire second TP. | |
dd238d2a | 529 | run_app $1 0 1 |
0e115563 | 530 | |
96340a01 JR |
531 | stop_lttng_tracing_ok $SESSION_NAME-1 |
532 | stop_lttng_tracing_ok $SESSION_NAME-2 | |
67b4c664 JR |
533 | destroy_lttng_session_ok $SESSION_NAME-1 |
534 | destroy_lttng_session_ok $SESSION_NAME-2 | |
0e115563 DG |
535 | |
536 | # Validate test. Expecting all events of first TP | |
537 | trace_match_only $EVENT_NAME $NR_ITER $TRACE_PATH/$SESSION_NAME-1 | |
538 | if [ $? -ne 0 ]; then | |
539 | return $? | |
540 | fi | |
541 | ||
542 | # Validate test. Expecting one event of the second TP. | |
543 | trace_match_only $EVENT_NAME2 1 $TRACE_PATH/$SESSION_NAME-2 | |
544 | if [ $? -ne 0 ]; then | |
545 | return $? | |
546 | fi | |
547 | } | |
548 | ||
549 | function test_python_destroy_session() | |
550 | { | |
551 | diag "Test Python two session with destroy" | |
552 | ||
bf6ae429 | 553 | create_lttng_session_ok $SESSION_NAME $TRACE_PATH/first-sess |
0e115563 | 554 | enable_python_lttng_event $SESSION_NAME $EVENT_NAME |
e563bbdb | 555 | start_lttng_tracing_ok $SESSION_NAME |
0e115563 DG |
556 | |
557 | # Run 5 times with a 1 second delay | |
25e9873d | 558 | run_app $1 0 1 |
0e115563 | 559 | |
96340a01 | 560 | stop_lttng_tracing_ok $SESSION_NAME |
67b4c664 | 561 | destroy_lttng_session_ok $SESSION_NAME |
0e115563 DG |
562 | |
563 | # Validate test. Expecting at least one event num 1 | |
564 | validate_trace $EVENT_NAME $TRACE_PATH/first-sess | |
565 | if [ $? -ne 0 ]; then | |
566 | return $? | |
567 | fi | |
568 | ||
bf6ae429 | 569 | create_lttng_session_ok $SESSION_NAME $TRACE_PATH/second-sess |
0e115563 | 570 | enable_python_lttng_event $SESSION_NAME $EVENT_NAME2 |
e563bbdb | 571 | start_lttng_tracing_ok $SESSION_NAME |
0e115563 | 572 | |
25e9873d | 573 | run_app $1 0 1 |
0e115563 | 574 | |
96340a01 | 575 | stop_lttng_tracing_ok $SESSION_NAME |
67b4c664 | 576 | destroy_lttng_session_ok $SESSION_NAME |
0e115563 DG |
577 | |
578 | # Validate test. Expecting only one event num 2 | |
579 | trace_match_only $EVENT_NAME2 1 $TRACE_PATH/second-sess | |
580 | if [ $? -ne 0 ]; then | |
581 | return $? | |
582 | fi | |
583 | } | |
584 | ||
585 | function test_python_filtering() | |
586 | { | |
587 | diag "Test Python filtering" | |
588 | ||
bf6ae429 | 589 | create_lttng_session_ok $SESSION_NAME $TRACE_PATH/$SESSION_NAME |
0e115563 | 590 | # Enable all event with a filter. |
dd238d2a | 591 | enable_python_filter $SESSION_NAME '*' 'msg == "python-ev-test2 fired [INFO]"' |
e563bbdb | 592 | start_lttng_tracing_ok $SESSION_NAME |
0e115563 DG |
593 | |
594 | # Run 5 times with a 1 second delay and fire second TP. | |
dd238d2a | 595 | run_app $1 0 1 |
0e115563 | 596 | |
96340a01 | 597 | stop_lttng_tracing_ok $SESSION_NAME |
67b4c664 | 598 | destroy_lttng_session_ok $SESSION_NAME |
0e115563 DG |
599 | |
600 | # Validate test. Expecting one event of the second TP only. | |
601 | trace_match_only $EVENT_NAME2 1 $TRACE_PATH/$SESSION_NAME | |
602 | if [ $? -ne 0 ]; then | |
603 | return $? | |
604 | fi | |
605 | ||
bf6ae429 | 606 | create_lttng_session_ok $SESSION_NAME $TRACE_PATH/$SESSION_NAME |
0e115563 DG |
607 | # Enable first Logger but filter msg payload for the INFO one while |
608 | # triggering the debug and second TP. | |
9586c198 | 609 | enable_python_filter $SESSION_NAME $EVENT_NAME 'msg == "python-ev-test1 fired [INFO]"' |
e563bbdb | 610 | start_lttng_tracing_ok $SESSION_NAME |
0e115563 DG |
611 | |
612 | # Run 5 times with a 1 second delay, fire debug and second TP. | |
dd238d2a | 613 | run_app $1 1 1 |
0e115563 | 614 | |
96340a01 | 615 | stop_lttng_tracing_ok $SESSION_NAME |
67b4c664 | 616 | destroy_lttng_session_ok $SESSION_NAME |
0e115563 DG |
617 | |
618 | # Validate test. Expecting NR_ITER event of the main INFO tp. | |
619 | trace_match_only $EVENT_NAME $NR_ITER $TRACE_PATH/$SESSION_NAME | |
620 | if [ $? -ne 0 ]; then | |
621 | return $? | |
622 | fi | |
623 | } | |
624 | ||
625 | function test_python_disable() | |
626 | { | |
627 | diag "Test Python disable event" | |
628 | ||
bf6ae429 | 629 | create_lttng_session_ok $SESSION_NAME $TRACE_PATH/$SESSION_NAME |
0e115563 DG |
630 | # Enable all event with a filter. |
631 | enable_python_lttng_event $SESSION_NAME $EVENT_NAME | |
632 | enable_python_lttng_event $SESSION_NAME $EVENT_NAME2 | |
633 | disable_python_lttng_event $SESSION_NAME $EVENT_NAME | |
e563bbdb | 634 | start_lttng_tracing_ok $SESSION_NAME |
0e115563 DG |
635 | |
636 | # Run 5 times with a 1 second delay and fire second TP. | |
dd238d2a | 637 | run_app $1 0 1 |
0e115563 | 638 | |
96340a01 | 639 | stop_lttng_tracing_ok $SESSION_NAME |
67b4c664 | 640 | destroy_lttng_session_ok $SESSION_NAME |
0e115563 DG |
641 | |
642 | # Validate test. Expecting one event of the second TP only. | |
643 | trace_match_only $EVENT_NAME2 1 $TRACE_PATH/$SESSION_NAME | |
644 | if [ $? -ne 0 ]; then | |
645 | return $? | |
646 | fi | |
647 | } | |
648 | ||
649 | function test_python_disable_enable() | |
650 | { | |
651 | diag "Test Python disable event followed by an enable" | |
652 | ||
bf6ae429 | 653 | create_lttng_session_ok $SESSION_NAME $TRACE_PATH/$SESSION_NAME |
0e115563 DG |
654 | # Enable all event with a filter. |
655 | enable_python_lttng_event $SESSION_NAME $EVENT_NAME | |
656 | disable_python_lttng_event $SESSION_NAME $EVENT_NAME | |
657 | enable_python_lttng_event $SESSION_NAME $EVENT_NAME | |
e563bbdb | 658 | start_lttng_tracing_ok $SESSION_NAME |
0e115563 DG |
659 | |
660 | # Run 5 times with a 1 second delay and fire second TP. | |
dd238d2a | 661 | run_app $1 0 1 |
0e115563 | 662 | |
96340a01 | 663 | stop_lttng_tracing_ok $SESSION_NAME |
67b4c664 | 664 | destroy_lttng_session_ok $SESSION_NAME |
0e115563 DG |
665 | |
666 | # Validate test. Expecting NR_ITER event of the main INFO tp. | |
667 | trace_match_only $EVENT_NAME $NR_ITER $TRACE_PATH/$SESSION_NAME | |
668 | if [ $? -ne 0 ]; then | |
669 | return $? | |
670 | fi | |
671 | } | |
672 | ||
673 | function test_python_filter_loglevel() | |
674 | { | |
675 | local BOGUS_EVENT_NAME="not_a_real_event" | |
676 | local FILTER="int_loglevel > 30 || int_loglevel < 30" | |
677 | local ALL_EVENTS="." | |
678 | ||
679 | diag "Test Python a filter with a loglevel" | |
680 | ||
bf6ae429 | 681 | create_lttng_session_ok $SESSION_NAME $TRACE_PATH/$SESSION_NAME |
0e115563 DG |
682 | # Enable an event with a filter and the loglevel-only option. |
683 | enable_python_filter_loglevel_only $SESSION_NAME $BOGUS_EVENT_NAME "$FILTER" "INFO" | |
684 | disable_python_lttng_event $SESSION_NAME $BOGUS_EVENT_NAME | |
685 | enable_python_filter_loglevel_only $SESSION_NAME $BOGUS_EVENT_NAME "$FILTER" "INFO" | |
e563bbdb | 686 | start_lttng_tracing_ok $SESSION_NAME |
0e115563 DG |
687 | |
688 | # Run 5 times with a 1 second delay and fire second TP. | |
dd238d2a | 689 | run_app $1 0 1 |
0e115563 | 690 | |
96340a01 | 691 | stop_lttng_tracing_ok $SESSION_NAME |
67b4c664 | 692 | destroy_lttng_session_ok $SESSION_NAME |
0e115563 DG |
693 | |
694 | # Validate test. Expecting no events. | |
695 | trace_match_only $ALL_EVENTS 0 $TRACE_PATH/$SESSION_NAME | |
696 | if [ $? -ne 0 ]; then | |
697 | return $? | |
698 | fi | |
699 | } | |
700 | ||
701 | plan_tests $NUM_TESTS | |
702 | ||
703 | print_test_banner "$TEST_DESC" | |
704 | ||
9586c198 JR |
705 | if [[ ${#python_versions[@]} -eq 0 || "x$run_test" != "xyes" ]]; then |
706 | skip_agent=0 | |
0e115563 | 707 | else |
9586c198 | 708 | skip_agent=1 |
0e115563 DG |
709 | fi |
710 | ||
9586c198 | 711 | skip $skip_agent "Python agent test skipped." $NUM_TESTS || |
0e115563 DG |
712 | { |
713 | start_lttng_sessiond | |
714 | ||
715 | tests=( | |
716 | test_python_multi_session_disable_wildcard | |
aed7bbd2 PP |
717 | test_python_multi_session_disable_wildcard_begin |
718 | test_python_multi_session_disable_wildcard_middle | |
719 | test_python_multi_session_disable_wildcard_end | |
0e115563 DG |
720 | test_python_multi_session_disable |
721 | test_python_disable | |
722 | test_python_disable_enable | |
723 | test_python_disable_all | |
724 | test_python_filtering | |
725 | test_python_multi_session_loglevel | |
726 | test_python_destroy_session | |
727 | test_python_loglevel | |
728 | test_python_loglevel_multiple | |
729 | test_python_before_start | |
730 | test_python_after_start | |
731 | test_python_multi_session | |
732 | test_python_filter_loglevel | |
733 | ) | |
734 | ||
9586c198 JR |
735 | |
736 | for python_version in ${python_versions[*]}; | |
0e115563 | 737 | do |
dd238d2a PP |
738 | for fct_test in ${tests[@]}; |
739 | do | |
740 | TRACE_PATH=$(mktemp -d) | |
741 | ||
742 | diag "(Python $python_version)" | |
9586c198 | 743 | ${fct_test} $python_version |
dd238d2a PP |
744 | if [ $? -ne 0 ]; then |
745 | break; | |
746 | fi | |
747 | rm -rf $TRACE_PATH | |
748 | done | |
0e115563 | 749 | done |
0e115563 DG |
750 | stop_lttng_sessiond |
751 | } |