Test fix: python logging test spams its output
[lttng-tools.git] / tests / regression / ust / python-logging / test_python_logging.in
1 #!/bin/bash
2 #
3 # Copyright (C) - 2015 Philippe Proulx <pproulx@efficios.com>
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
19 TEST_DESC="Python support"
20
21 CURDIR=$(dirname $0)/
22 TESTDIR=$CURDIR/../../..
23 NR_ITER=5
24 NR_SEC_WAIT=0
25 TESTAPP_NAME="test"
26 TESTAPP_BIN="$TESTAPP_NAME.py"
27 TESTAPP_PATH="@abs_top_srcdir@/tests/regression/ust/python-logging"
28 SESSION_NAME="python-test"
29 EVENT_NAME="python-ev-test1"
30 EVENT_NAME2="python-ev-test2"
31 OUTPUT_DEST="/dev/null"
32
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
39 NUM_TESTS=$(((194 * ${#python_versions[@]})+2))
40 fi
41
42 source $TESTDIR/utils/utils.sh
43
44 function run_app
45 {
46 local python=$1
47 local debug_tp=$2
48 local fire_second_tp=$3
49 local ready_file=$4
50 local go_file=$5
51 local opt=""
52
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
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 $python $TESTAPP_PATH/$TESTAPP_BIN -n $NR_ITER -s $NR_SEC_WAIT $opt
70 }
71
72 function run_app_background
73 {
74 run_app "$@" &
75 }
76
77 function 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
95 function enable_python_filter()
96 {
97 local sess_name="$1"
98 local event_name="$2"
99 local filter="$3"
100
101 $TESTDIR/../src/bin/lttng/$LTTNG_BIN enable-event "$event_name" -s $sess_name -p --filter "$filter" >$OUTPUT_DEST
102 ok $? "Enable event $event_name with filter $filter for session $sess_name"
103 }
104
105 function 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
118 function test_python_before_start ()
119 {
120 local ready_file=$(mktemp -u)
121 local go_file=$(mktemp -u)
122
123 diag "Test Python application BEFORE tracing starts"
124 create_lttng_session_ok $SESSION_NAME $TRACE_PATH
125 enable_python_lttng_event $SESSION_NAME $EVENT_NAME
126
127 # Run 5 times with a 1 second delay
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
134
135 start_lttng_tracing_ok $SESSION_NAME
136
137 # Wait for the applications started in background
138 echo "1" > ${go_file}
139 wait
140
141 stop_lttng_tracing_ok $SESSION_NAME
142 destroy_lttng_session_ok $SESSION_NAME
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
149
150 rm $go_file
151 }
152
153 function test_python_after_start ()
154 {
155 diag "Test Python application AFTER tracing starts"
156
157 create_lttng_session_ok $SESSION_NAME $TRACE_PATH
158 enable_python_lttng_event $SESSION_NAME $EVENT_NAME
159 start_lttng_tracing_ok $SESSION_NAME
160
161 # Run 5 times with a 1 second delay
162 run_app $1
163
164 stop_lttng_tracing_ok $SESSION_NAME
165 destroy_lttng_session_ok $SESSION_NAME
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
174 function test_python_loglevel ()
175 {
176 diag "Test Python application with loglevel"
177
178 create_lttng_session_ok $SESSION_NAME $TRACE_PATH
179 enable_python_lttng_event_loglevel $SESSION_NAME $EVENT_NAME "INFO"
180 start_lttng_tracing_ok $SESSION_NAME
181
182 # Run 5 times with a 1 second delay
183 run_app $1
184
185 stop_lttng_tracing_ok $SESSION_NAME
186 destroy_lttng_session_ok $SESSION_NAME
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
196 create_lttng_session_ok $SESSION_NAME $TRACE_PATH
197 enable_python_lttng_event_loglevel $SESSION_NAME $EVENT_NAME "CRITICAL"
198 start_lttng_tracing_ok $SESSION_NAME
199
200 # Run 5 times with a 1 second delay
201 run_app $1
202
203 stop_lttng_tracing_ok $SESSION_NAME
204 destroy_lttng_session_ok $SESSION_NAME
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
214 create_lttng_session_ok $SESSION_NAME $TRACE_PATH
215 enable_python_lttng_event_loglevel $SESSION_NAME $EVENT_NAME "DEBUG"
216 start_lttng_tracing_ok $SESSION_NAME
217
218 # Run 5 times with a 1 second delay
219 run_app $1
220
221 stop_lttng_tracing_ok $SESSION_NAME
222 destroy_lttng_session_ok $SESSION_NAME
223
224 # Validate test. Expecting all events.
225 trace_match_only $EVENT_NAME $NR_ITER $TRACE_PATH
226 return $?
227 }
228
229 function test_python_loglevel_multiple ()
230 {
231 diag "Test Python application with multiple loglevel"
232
233 create_lttng_session_ok $SESSION_NAME $TRACE_PATH
234 enable_python_lttng_event_loglevel $SESSION_NAME $EVENT_NAME "INFO"
235 enable_python_lttng_event_loglevel $SESSION_NAME $EVENT_NAME "DEBUG"
236 start_lttng_tracing_ok $SESSION_NAME
237
238 # Run 5 times with a 1 second delay and fire two TP.
239 run_app $1 1
240
241 stop_lttng_tracing_ok $SESSION_NAME
242 destroy_lttng_session_ok $SESSION_NAME
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
250 create_lttng_session_ok $SESSION_NAME $TRACE_PATH
251 enable_python_lttng_event_loglevel $SESSION_NAME '*' "INFO"
252 enable_python_lttng_event_loglevel $SESSION_NAME '*' "DEBUG"
253 start_lttng_tracing_ok $SESSION_NAME
254
255 # Run 5 times with a 1 second delay and fire two TP.
256 run_app $1 1
257
258 stop_lttng_tracing_ok $SESSION_NAME
259 destroy_lttng_session_ok $SESSION_NAME
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
268 function test_python_multi_session_loglevel()
269 {
270 diag "Test Python with multiple session"
271
272 create_lttng_session_ok $SESSION_NAME-1 $TRACE_PATH/$SESSION_NAME-1
273 enable_python_loglevel_only $SESSION_NAME-1 '*' "INFO"
274 start_lttng_tracing_ok $SESSION_NAME-1
275
276 create_lttng_session_ok $SESSION_NAME-2 $TRACE_PATH/$SESSION_NAME-2
277 enable_python_loglevel_only $SESSION_NAME-2 '*' "DEBUG"
278 start_lttng_tracing_ok $SESSION_NAME-2
279
280 # Run 5 times with a 1 second delay and fire second TP.
281 run_app $1 1 1
282
283 stop_lttng_tracing_ok $SESSION_NAME-1
284 stop_lttng_tracing_ok $SESSION_NAME-2
285 destroy_lttng_session_ok $SESSION_NAME-1
286 destroy_lttng_session_ok $SESSION_NAME-2
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
305 function test_python_multi_session_disable()
306 {
307 diag "Test Python with multiple session with disabled event"
308
309 create_lttng_session_ok $SESSION_NAME-1 $TRACE_PATH/$SESSION_NAME-1
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
313 start_lttng_tracing_ok $SESSION_NAME-1
314
315 create_lttng_session_ok $SESSION_NAME-2 $TRACE_PATH/$SESSION_NAME-2
316 enable_python_lttng_event $SESSION_NAME-2 $EVENT_NAME2
317 start_lttng_tracing_ok $SESSION_NAME-2
318
319 # Run 5 times with a 1 second delay and fire second TP.
320 run_app $1 0 1
321
322 stop_lttng_tracing_ok $SESSION_NAME-1
323 stop_lttng_tracing_ok $SESSION_NAME-2
324 destroy_lttng_session_ok $SESSION_NAME-1
325 destroy_lttng_session_ok $SESSION_NAME-2
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
340 function test_python_multi_session_disable_wildcard()
341 {
342 diag "Test Python with multiple session with disabled wildcard event"
343
344 create_lttng_session_ok $SESSION_NAME-1 $TRACE_PATH/$SESSION_NAME-1
345 enable_python_lttng_event $SESSION_NAME-1 '*'
346
347 create_lttng_session_ok $SESSION_NAME-2 $TRACE_PATH/$SESSION_NAME-2
348 enable_python_lttng_event $SESSION_NAME-2 '*'
349
350 disable_python_lttng_event $SESSION_NAME-1 '*'
351
352 start_lttng_tracing_ok $SESSION_NAME-1
353 start_lttng_tracing_ok $SESSION_NAME-2
354
355 run_app $1
356
357 stop_lttng_tracing_ok $SESSION_NAME-1
358 stop_lttng_tracing_ok $SESSION_NAME-2
359 destroy_lttng_session_ok $SESSION_NAME-1
360 destroy_lttng_session_ok $SESSION_NAME-2
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
375 function 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
411 function 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
447 function 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
488 function test_python_disable_all()
489 {
490 diag "Test Python with multiple session with disabled all event"
491
492 create_lttng_session_ok $SESSION_NAME $TRACE_PATH/$SESSION_NAME
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
497 disable_python_lttng_event $SESSION_NAME -a
498
499 start_lttng_tracing_ok $SESSION_NAME
500
501 run_app $1 0 1
502
503 stop_lttng_tracing_ok $SESSION_NAME
504 destroy_lttng_session_ok $SESSION_NAME
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
514 function test_python_multi_session()
515 {
516 diag "Test Python with multiple session"
517
518 create_lttng_session_ok $SESSION_NAME-1 $TRACE_PATH/$SESSION_NAME-1
519 enable_python_lttng_event $SESSION_NAME-1 $EVENT_NAME
520 start_lttng_tracing_ok $SESSION_NAME-1
521
522 create_lttng_session_ok $SESSION_NAME-2 $TRACE_PATH/$SESSION_NAME-2
523 enable_python_lttng_event $SESSION_NAME-2 $EVENT_NAME2
524 start_lttng_tracing_ok $SESSION_NAME-2
525
526 # Run 5 times with a 1 second delay and fire second TP.
527 run_app $1 0 1
528
529 stop_lttng_tracing_ok $SESSION_NAME-1
530 stop_lttng_tracing_ok $SESSION_NAME-2
531 destroy_lttng_session_ok $SESSION_NAME-1
532 destroy_lttng_session_ok $SESSION_NAME-2
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
547 function test_python_destroy_session()
548 {
549 diag "Test Python two session with destroy"
550
551 create_lttng_session_ok $SESSION_NAME $TRACE_PATH/first-sess
552 enable_python_lttng_event $SESSION_NAME $EVENT_NAME
553 start_lttng_tracing_ok $SESSION_NAME
554
555 # Run 5 times with a 1 second delay
556 run_app $1 0 1
557
558 stop_lttng_tracing_ok $SESSION_NAME
559 destroy_lttng_session_ok $SESSION_NAME
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
567 create_lttng_session_ok $SESSION_NAME $TRACE_PATH/second-sess
568 enable_python_lttng_event $SESSION_NAME $EVENT_NAME2
569 start_lttng_tracing_ok $SESSION_NAME
570
571 run_app $1 0 1
572
573 stop_lttng_tracing_ok $SESSION_NAME
574 destroy_lttng_session_ok $SESSION_NAME
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
583 function test_python_filtering()
584 {
585 diag "Test Python filtering"
586
587 create_lttng_session_ok $SESSION_NAME $TRACE_PATH/$SESSION_NAME
588 # Enable all event with a filter.
589 enable_python_filter $SESSION_NAME '*' 'msg == "python-ev-test2 fired [INFO]"'
590 start_lttng_tracing_ok $SESSION_NAME
591
592 # Run 5 times with a 1 second delay and fire second TP.
593 run_app $1 0 1
594
595 stop_lttng_tracing_ok $SESSION_NAME
596 destroy_lttng_session_ok $SESSION_NAME
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
604 create_lttng_session_ok $SESSION_NAME $TRACE_PATH/$SESSION_NAME
605 # Enable first Logger but filter msg payload for the INFO one while
606 # triggering the debug and second TP.
607 enable_python_filter $SESSION_NAME $EVENT_NAME 'msg == "python-ev-test1 fired [INFO]"'
608 start_lttng_tracing_ok $SESSION_NAME
609
610 # Run 5 times with a 1 second delay, fire debug and second TP.
611 run_app $1 1 1
612
613 stop_lttng_tracing_ok $SESSION_NAME
614 destroy_lttng_session_ok $SESSION_NAME
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
623 function test_python_disable()
624 {
625 diag "Test Python disable event"
626
627 create_lttng_session_ok $SESSION_NAME $TRACE_PATH/$SESSION_NAME
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
632 start_lttng_tracing_ok $SESSION_NAME
633
634 # Run 5 times with a 1 second delay and fire second TP.
635 run_app $1 0 1
636
637 stop_lttng_tracing_ok $SESSION_NAME
638 destroy_lttng_session_ok $SESSION_NAME
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
647 function test_python_disable_enable()
648 {
649 diag "Test Python disable event followed by an enable"
650
651 create_lttng_session_ok $SESSION_NAME $TRACE_PATH/$SESSION_NAME
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
656 start_lttng_tracing_ok $SESSION_NAME
657
658 # Run 5 times with a 1 second delay and fire second TP.
659 run_app $1 0 1
660
661 stop_lttng_tracing_ok $SESSION_NAME
662 destroy_lttng_session_ok $SESSION_NAME
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
671 function 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
679 create_lttng_session_ok $SESSION_NAME $TRACE_PATH/$SESSION_NAME
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"
684 start_lttng_tracing_ok $SESSION_NAME
685
686 # Run 5 times with a 1 second delay and fire second TP.
687 run_app $1 0 1
688
689 stop_lttng_tracing_ok $SESSION_NAME
690 destroy_lttng_session_ok $SESSION_NAME
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
699 plan_tests $NUM_TESTS
700
701 print_test_banner "$TEST_DESC"
702
703 if [[ ${#python_versions[@]} -eq 0 || "x$run_test" != "xyes" ]]; then
704 skip_agent=0
705 else
706 skip_agent=1
707 fi
708
709 skip $skip_agent "Python agent test skipped." $NUM_TESTS ||
710 {
711 start_lttng_sessiond
712
713 tests=(
714 test_python_multi_session_disable_wildcard
715 test_python_multi_session_disable_wildcard_begin
716 test_python_multi_session_disable_wildcard_middle
717 test_python_multi_session_disable_wildcard_end
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
733
734 for python_version in ${python_versions[*]};
735 do
736 for fct_test in ${tests[@]};
737 do
738 TRACE_PATH=$(mktemp -d)
739
740 diag "(Python $python_version)"
741 ${fct_test} $python_version
742 if [ $? -ne 0 ]; then
743 break;
744 fi
745 rm -rf $TRACE_PATH
746 done
747 done
748 stop_lttng_sessiond
749 }
This page took 0.046925 seconds and 5 git commands to generate.