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