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