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