2b5852c2f77b1d91b6623e649a752431d26c55af
[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 set -x
70 $python $TESTAPP_PATH/$TESTAPP_BIN -n $NR_ITER -s $NR_SEC_WAIT $opt
71 set +x
72 }
73
74 function run_app_background
75 {
76 run_app "$@" &
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
103 $TESTDIR/../src/bin/lttng/$LTTNG_BIN enable-event "$event_name" -s $sess_name -p --filter "$filter" >$OUTPUT_DEST
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 {
122 local ready_file=$(mktemp -u)
123 local go_file=$(mktemp -u)
124
125 diag "Test Python application BEFORE tracing starts"
126 create_lttng_session_ok $SESSION_NAME $TRACE_PATH
127 enable_python_lttng_event $SESSION_NAME $EVENT_NAME
128
129 # Run 5 times with a 1 second delay
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
136
137 start_lttng_tracing_ok $SESSION_NAME
138
139 # Wait for the applications started in background
140 echo "1" > ${go_file}
141 wait
142
143 stop_lttng_tracing_ok $SESSION_NAME
144 destroy_lttng_session_ok $SESSION_NAME
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
151
152 rm $go_file
153 }
154
155 function test_python_after_start ()
156 {
157 diag "Test Python application AFTER tracing starts"
158
159 create_lttng_session_ok $SESSION_NAME $TRACE_PATH
160 enable_python_lttng_event $SESSION_NAME $EVENT_NAME
161 start_lttng_tracing_ok $SESSION_NAME
162
163 # Run 5 times with a 1 second delay
164 run_app $1
165
166 stop_lttng_tracing_ok $SESSION_NAME
167 destroy_lttng_session_ok $SESSION_NAME
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
180 create_lttng_session_ok $SESSION_NAME $TRACE_PATH
181 enable_python_lttng_event_loglevel $SESSION_NAME $EVENT_NAME "INFO"
182 start_lttng_tracing_ok $SESSION_NAME
183
184 # Run 5 times with a 1 second delay
185 run_app $1
186
187 stop_lttng_tracing_ok $SESSION_NAME
188 destroy_lttng_session_ok $SESSION_NAME
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
198 create_lttng_session_ok $SESSION_NAME $TRACE_PATH
199 enable_python_lttng_event_loglevel $SESSION_NAME $EVENT_NAME "CRITICAL"
200 start_lttng_tracing_ok $SESSION_NAME
201
202 # Run 5 times with a 1 second delay
203 run_app $1
204
205 stop_lttng_tracing_ok $SESSION_NAME
206 destroy_lttng_session_ok $SESSION_NAME
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
216 create_lttng_session_ok $SESSION_NAME $TRACE_PATH
217 enable_python_lttng_event_loglevel $SESSION_NAME $EVENT_NAME "DEBUG"
218 start_lttng_tracing_ok $SESSION_NAME
219
220 # Run 5 times with a 1 second delay
221 run_app $1
222
223 stop_lttng_tracing_ok $SESSION_NAME
224 destroy_lttng_session_ok $SESSION_NAME
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
235 create_lttng_session_ok $SESSION_NAME $TRACE_PATH
236 enable_python_lttng_event_loglevel $SESSION_NAME $EVENT_NAME "INFO"
237 enable_python_lttng_event_loglevel $SESSION_NAME $EVENT_NAME "DEBUG"
238 start_lttng_tracing_ok $SESSION_NAME
239
240 # Run 5 times with a 1 second delay and fire two TP.
241 run_app $1 1
242
243 stop_lttng_tracing_ok $SESSION_NAME
244 destroy_lttng_session_ok $SESSION_NAME
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
252 create_lttng_session_ok $SESSION_NAME $TRACE_PATH
253 enable_python_lttng_event_loglevel $SESSION_NAME '*' "INFO"
254 enable_python_lttng_event_loglevel $SESSION_NAME '*' "DEBUG"
255 start_lttng_tracing_ok $SESSION_NAME
256
257 # Run 5 times with a 1 second delay and fire two TP.
258 run_app $1 1
259
260 stop_lttng_tracing_ok $SESSION_NAME
261 destroy_lttng_session_ok $SESSION_NAME
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
274 create_lttng_session_ok $SESSION_NAME-1 $TRACE_PATH/$SESSION_NAME-1
275 enable_python_loglevel_only $SESSION_NAME-1 '*' "INFO"
276 start_lttng_tracing_ok $SESSION_NAME-1
277
278 create_lttng_session_ok $SESSION_NAME-2 $TRACE_PATH/$SESSION_NAME-2
279 enable_python_loglevel_only $SESSION_NAME-2 '*' "DEBUG"
280 start_lttng_tracing_ok $SESSION_NAME-2
281
282 # Run 5 times with a 1 second delay and fire second TP.
283 run_app $1 1 1
284
285 stop_lttng_tracing_ok $SESSION_NAME-1
286 stop_lttng_tracing_ok $SESSION_NAME-2
287 destroy_lttng_session_ok $SESSION_NAME-1
288 destroy_lttng_session_ok $SESSION_NAME-2
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
311 create_lttng_session_ok $SESSION_NAME-1 $TRACE_PATH/$SESSION_NAME-1
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
315 start_lttng_tracing_ok $SESSION_NAME-1
316
317 create_lttng_session_ok $SESSION_NAME-2 $TRACE_PATH/$SESSION_NAME-2
318 enable_python_lttng_event $SESSION_NAME-2 $EVENT_NAME2
319 start_lttng_tracing_ok $SESSION_NAME-2
320
321 # Run 5 times with a 1 second delay and fire second TP.
322 run_app $1 0 1
323
324 stop_lttng_tracing_ok $SESSION_NAME-1
325 stop_lttng_tracing_ok $SESSION_NAME-2
326 destroy_lttng_session_ok $SESSION_NAME-1
327 destroy_lttng_session_ok $SESSION_NAME-2
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
346 create_lttng_session_ok $SESSION_NAME-1 $TRACE_PATH/$SESSION_NAME-1
347 enable_python_lttng_event $SESSION_NAME-1 '*'
348
349 create_lttng_session_ok $SESSION_NAME-2 $TRACE_PATH/$SESSION_NAME-2
350 enable_python_lttng_event $SESSION_NAME-2 '*'
351
352 disable_python_lttng_event $SESSION_NAME-1 '*'
353
354 start_lttng_tracing_ok $SESSION_NAME-1
355 start_lttng_tracing_ok $SESSION_NAME-2
356
357 run_app $1
358
359 stop_lttng_tracing_ok $SESSION_NAME-1
360 stop_lttng_tracing_ok $SESSION_NAME-2
361 destroy_lttng_session_ok $SESSION_NAME-1
362 destroy_lttng_session_ok $SESSION_NAME-2
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
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
490 function test_python_disable_all()
491 {
492 diag "Test Python with multiple session with disabled all event"
493
494 create_lttng_session_ok $SESSION_NAME $TRACE_PATH/$SESSION_NAME
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
499 disable_python_lttng_event $SESSION_NAME -a
500
501 start_lttng_tracing_ok $SESSION_NAME
502
503 run_app $1 0 1
504
505 stop_lttng_tracing_ok $SESSION_NAME
506 destroy_lttng_session_ok $SESSION_NAME
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
520 create_lttng_session_ok $SESSION_NAME-1 $TRACE_PATH/$SESSION_NAME-1
521 enable_python_lttng_event $SESSION_NAME-1 $EVENT_NAME
522 start_lttng_tracing_ok $SESSION_NAME-1
523
524 create_lttng_session_ok $SESSION_NAME-2 $TRACE_PATH/$SESSION_NAME-2
525 enable_python_lttng_event $SESSION_NAME-2 $EVENT_NAME2
526 start_lttng_tracing_ok $SESSION_NAME-2
527
528 # Run 5 times with a 1 second delay and fire second TP.
529 run_app $1 0 1
530
531 stop_lttng_tracing_ok $SESSION_NAME-1
532 stop_lttng_tracing_ok $SESSION_NAME-2
533 destroy_lttng_session_ok $SESSION_NAME-1
534 destroy_lttng_session_ok $SESSION_NAME-2
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
553 create_lttng_session_ok $SESSION_NAME $TRACE_PATH/first-sess
554 enable_python_lttng_event $SESSION_NAME $EVENT_NAME
555 start_lttng_tracing_ok $SESSION_NAME
556
557 # Run 5 times with a 1 second delay
558 run_app $1 0 1
559
560 stop_lttng_tracing_ok $SESSION_NAME
561 destroy_lttng_session_ok $SESSION_NAME
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
569 create_lttng_session_ok $SESSION_NAME $TRACE_PATH/second-sess
570 enable_python_lttng_event $SESSION_NAME $EVENT_NAME2
571 start_lttng_tracing_ok $SESSION_NAME
572
573 run_app $1 0 1
574
575 stop_lttng_tracing_ok $SESSION_NAME
576 destroy_lttng_session_ok $SESSION_NAME
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
589 create_lttng_session_ok $SESSION_NAME $TRACE_PATH/$SESSION_NAME
590 # Enable all event with a filter.
591 enable_python_filter $SESSION_NAME '*' 'msg == "python-ev-test2 fired [INFO]"'
592 start_lttng_tracing_ok $SESSION_NAME
593
594 # Run 5 times with a 1 second delay and fire second TP.
595 run_app $1 0 1
596
597 stop_lttng_tracing_ok $SESSION_NAME
598 destroy_lttng_session_ok $SESSION_NAME
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
606 create_lttng_session_ok $SESSION_NAME $TRACE_PATH/$SESSION_NAME
607 # Enable first Logger but filter msg payload for the INFO one while
608 # triggering the debug and second TP.
609 enable_python_filter $SESSION_NAME $EVENT_NAME 'msg == "python-ev-test1 fired [INFO]"'
610 start_lttng_tracing_ok $SESSION_NAME
611
612 # Run 5 times with a 1 second delay, fire debug and second TP.
613 run_app $1 1 1
614
615 stop_lttng_tracing_ok $SESSION_NAME
616 destroy_lttng_session_ok $SESSION_NAME
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
629 create_lttng_session_ok $SESSION_NAME $TRACE_PATH/$SESSION_NAME
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
634 start_lttng_tracing_ok $SESSION_NAME
635
636 # Run 5 times with a 1 second delay and fire second TP.
637 run_app $1 0 1
638
639 stop_lttng_tracing_ok $SESSION_NAME
640 destroy_lttng_session_ok $SESSION_NAME
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
653 create_lttng_session_ok $SESSION_NAME $TRACE_PATH/$SESSION_NAME
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
658 start_lttng_tracing_ok $SESSION_NAME
659
660 # Run 5 times with a 1 second delay and fire second TP.
661 run_app $1 0 1
662
663 stop_lttng_tracing_ok $SESSION_NAME
664 destroy_lttng_session_ok $SESSION_NAME
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
681 create_lttng_session_ok $SESSION_NAME $TRACE_PATH/$SESSION_NAME
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"
686 start_lttng_tracing_ok $SESSION_NAME
687
688 # Run 5 times with a 1 second delay and fire second TP.
689 run_app $1 0 1
690
691 stop_lttng_tracing_ok $SESSION_NAME
692 destroy_lttng_session_ok $SESSION_NAME
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
705 if [[ ${#python_versions[@]} -eq 0 || "x$run_test" != "xyes" ]]; then
706 skip_agent=0
707 else
708 skip_agent=1
709 fi
710
711 skip $skip_agent "Python agent test skipped." $NUM_TESTS ||
712 {
713 start_lttng_sessiond
714
715 tests=(
716 test_python_multi_session_disable_wildcard
717 test_python_multi_session_disable_wildcard_begin
718 test_python_multi_session_disable_wildcard_middle
719 test_python_multi_session_disable_wildcard_end
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
735
736 for python_version in ${python_versions[*]};
737 do
738 for fct_test in ${tests[@]};
739 do
740 TRACE_PATH=$(mktemp -d)
741
742 diag "(Python $python_version)"
743 ${fct_test} $python_version
744 if [ $? -ne 0 ]; then
745 break;
746 fi
747 rm -rf $TRACE_PATH
748 done
749 done
750 stop_lttng_sessiond
751 }
This page took 0.046783 seconds and 4 git commands to generate.