Test: add file based synchronization point for python test app
[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
74f2abd5 49 local opt=""
0e115563 50
74f2abd5
JR
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
0e115563
DG
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
9586c198 91 $TESTDIR/../src/bin/lttng/$LTTNG_BIN enable-event "$event_name" -s $sess_name -p --filter "$filter" >$OUTPUT_DEST
0e115563
DG
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"
bf6ae429 111 create_lttng_session_ok $SESSION_NAME $TRACE_PATH
0e115563
DG
112 enable_python_lttng_event $SESSION_NAME $EVENT_NAME
113
114 # Run 5 times with a 1 second delay
dd238d2a 115 run_app_background $1
0e115563 116
e563bbdb 117 start_lttng_tracing_ok $SESSION_NAME
0e115563
DG
118
119 # Wait for the applications started in background
0fc2834c 120 wait
0e115563 121
96340a01 122 stop_lttng_tracing_ok $SESSION_NAME
67b4c664 123 destroy_lttng_session_ok $SESSION_NAME
0e115563
DG
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
bf6ae429 136 create_lttng_session_ok $SESSION_NAME $TRACE_PATH
0e115563 137 enable_python_lttng_event $SESSION_NAME $EVENT_NAME
e563bbdb 138 start_lttng_tracing_ok $SESSION_NAME
0e115563
DG
139
140 # Run 5 times with a 1 second delay
dd238d2a 141 run_app $1
0e115563 142
96340a01 143 stop_lttng_tracing_ok $SESSION_NAME
67b4c664 144 destroy_lttng_session_ok $SESSION_NAME
0e115563
DG
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
bf6ae429 157 create_lttng_session_ok $SESSION_NAME $TRACE_PATH
0e115563 158 enable_python_lttng_event_loglevel $SESSION_NAME $EVENT_NAME "INFO"
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 diag "Test Python applications with lower loglevel"
174
bf6ae429 175 create_lttng_session_ok $SESSION_NAME $TRACE_PATH
0e115563 176 enable_python_lttng_event_loglevel $SESSION_NAME $EVENT_NAME "CRITICAL"
e563bbdb 177 start_lttng_tracing_ok $SESSION_NAME
0e115563
DG
178
179 # Run 5 times with a 1 second delay
dd238d2a 180 run_app $1
0e115563 181
96340a01 182 stop_lttng_tracing_ok $SESSION_NAME
67b4c664 183 destroy_lttng_session_ok $SESSION_NAME
0e115563
DG
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
bf6ae429 193 create_lttng_session_ok $SESSION_NAME $TRACE_PATH
0e115563 194 enable_python_lttng_event_loglevel $SESSION_NAME $EVENT_NAME "DEBUG"
e563bbdb 195 start_lttng_tracing_ok $SESSION_NAME
0e115563
DG
196
197 # Run 5 times with a 1 second delay
dd238d2a 198 run_app $1
0e115563 199
96340a01 200 stop_lttng_tracing_ok $SESSION_NAME
67b4c664 201 destroy_lttng_session_ok $SESSION_NAME
0e115563
DG
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
bf6ae429 212 create_lttng_session_ok $SESSION_NAME $TRACE_PATH
0e115563
DG
213 enable_python_lttng_event_loglevel $SESSION_NAME $EVENT_NAME "INFO"
214 enable_python_lttng_event_loglevel $SESSION_NAME $EVENT_NAME "DEBUG"
e563bbdb 215 start_lttng_tracing_ok $SESSION_NAME
0e115563
DG
216
217 # Run 5 times with a 1 second delay and fire two TP.
dd238d2a 218 run_app $1 1
0e115563 219
96340a01 220 stop_lttng_tracing_ok $SESSION_NAME
67b4c664 221 destroy_lttng_session_ok $SESSION_NAME
0e115563
DG
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
bf6ae429 229 create_lttng_session_ok $SESSION_NAME $TRACE_PATH
0e115563
DG
230 enable_python_lttng_event_loglevel $SESSION_NAME '*' "INFO"
231 enable_python_lttng_event_loglevel $SESSION_NAME '*' "DEBUG"
e563bbdb 232 start_lttng_tracing_ok $SESSION_NAME
0e115563
DG
233
234 # Run 5 times with a 1 second delay and fire two TP.
dd238d2a 235 run_app $1 1
0e115563 236
96340a01 237 stop_lttng_tracing_ok $SESSION_NAME
67b4c664 238 destroy_lttng_session_ok $SESSION_NAME
0e115563
DG
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
bf6ae429 251 create_lttng_session_ok $SESSION_NAME-1 $TRACE_PATH/$SESSION_NAME-1
0e115563 252 enable_python_loglevel_only $SESSION_NAME-1 '*' "INFO"
e563bbdb 253 start_lttng_tracing_ok $SESSION_NAME-1
0e115563 254
bf6ae429 255 create_lttng_session_ok $SESSION_NAME-2 $TRACE_PATH/$SESSION_NAME-2
0e115563 256 enable_python_loglevel_only $SESSION_NAME-2 '*' "DEBUG"
e563bbdb 257 start_lttng_tracing_ok $SESSION_NAME-2
0e115563
DG
258
259 # Run 5 times with a 1 second delay and fire second TP.
dd238d2a 260 run_app $1 1 1
0e115563 261
96340a01
JR
262 stop_lttng_tracing_ok $SESSION_NAME-1
263 stop_lttng_tracing_ok $SESSION_NAME-2
67b4c664
JR
264 destroy_lttng_session_ok $SESSION_NAME-1
265 destroy_lttng_session_ok $SESSION_NAME-2
0e115563
DG
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
bf6ae429 288 create_lttng_session_ok $SESSION_NAME-1 $TRACE_PATH/$SESSION_NAME-1
0e115563
DG
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
e563bbdb 292 start_lttng_tracing_ok $SESSION_NAME-1
0e115563 293
bf6ae429 294 create_lttng_session_ok $SESSION_NAME-2 $TRACE_PATH/$SESSION_NAME-2
0e115563 295 enable_python_lttng_event $SESSION_NAME-2 $EVENT_NAME2
e563bbdb 296 start_lttng_tracing_ok $SESSION_NAME-2
0e115563
DG
297
298 # Run 5 times with a 1 second delay and fire second TP.
dd238d2a 299 run_app $1 0 1
0e115563 300
96340a01
JR
301 stop_lttng_tracing_ok $SESSION_NAME-1
302 stop_lttng_tracing_ok $SESSION_NAME-2
67b4c664
JR
303 destroy_lttng_session_ok $SESSION_NAME-1
304 destroy_lttng_session_ok $SESSION_NAME-2
0e115563
DG
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
bf6ae429 323 create_lttng_session_ok $SESSION_NAME-1 $TRACE_PATH/$SESSION_NAME-1
0e115563
DG
324 enable_python_lttng_event $SESSION_NAME-1 '*'
325
bf6ae429 326 create_lttng_session_ok $SESSION_NAME-2 $TRACE_PATH/$SESSION_NAME-2
0e115563
DG
327 enable_python_lttng_event $SESSION_NAME-2 '*'
328
329 disable_python_lttng_event $SESSION_NAME-1 '*'
330
e563bbdb
JR
331 start_lttng_tracing_ok $SESSION_NAME-1
332 start_lttng_tracing_ok $SESSION_NAME-2
0e115563 333
dd238d2a 334 run_app $1
0e115563 335
96340a01
JR
336 stop_lttng_tracing_ok $SESSION_NAME-1
337 stop_lttng_tracing_ok $SESSION_NAME-2
67b4c664
JR
338 destroy_lttng_session_ok $SESSION_NAME-1
339 destroy_lttng_session_ok $SESSION_NAME-2
0e115563
DG
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
aed7bbd2
PP
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
0e115563
DG
467function test_python_disable_all()
468{
469 diag "Test Python with multiple session with disabled all event"
470
bf6ae429 471 create_lttng_session_ok $SESSION_NAME $TRACE_PATH/$SESSION_NAME
0e115563
DG
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
b3639870 476 disable_python_lttng_event $SESSION_NAME -a
0e115563 477
e563bbdb 478 start_lttng_tracing_ok $SESSION_NAME
0e115563 479
dd238d2a 480 run_app $1 0 1
0e115563 481
96340a01 482 stop_lttng_tracing_ok $SESSION_NAME
67b4c664 483 destroy_lttng_session_ok $SESSION_NAME
0e115563
DG
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
bf6ae429 497 create_lttng_session_ok $SESSION_NAME-1 $TRACE_PATH/$SESSION_NAME-1
0e115563 498 enable_python_lttng_event $SESSION_NAME-1 $EVENT_NAME
e563bbdb 499 start_lttng_tracing_ok $SESSION_NAME-1
0e115563 500
bf6ae429 501 create_lttng_session_ok $SESSION_NAME-2 $TRACE_PATH/$SESSION_NAME-2
0e115563 502 enable_python_lttng_event $SESSION_NAME-2 $EVENT_NAME2
e563bbdb 503 start_lttng_tracing_ok $SESSION_NAME-2
0e115563
DG
504
505 # Run 5 times with a 1 second delay and fire second TP.
dd238d2a 506 run_app $1 0 1
0e115563 507
96340a01
JR
508 stop_lttng_tracing_ok $SESSION_NAME-1
509 stop_lttng_tracing_ok $SESSION_NAME-2
67b4c664
JR
510 destroy_lttng_session_ok $SESSION_NAME-1
511 destroy_lttng_session_ok $SESSION_NAME-2
0e115563
DG
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
bf6ae429 530 create_lttng_session_ok $SESSION_NAME $TRACE_PATH/first-sess
0e115563 531 enable_python_lttng_event $SESSION_NAME $EVENT_NAME
e563bbdb 532 start_lttng_tracing_ok $SESSION_NAME
0e115563
DG
533
534 # Run 5 times with a 1 second delay
dd238d2a 535 run_app_background $1 0 1
0e115563 536
0fc2834c
MD
537 # Wait for the applications started in background
538 wait
0e115563 539
96340a01 540 stop_lttng_tracing_ok $SESSION_NAME
67b4c664 541 destroy_lttng_session_ok $SESSION_NAME
0e115563
DG
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
bf6ae429 549 create_lttng_session_ok $SESSION_NAME $TRACE_PATH/second-sess
0e115563 550 enable_python_lttng_event $SESSION_NAME $EVENT_NAME2
e563bbdb 551 start_lttng_tracing_ok $SESSION_NAME
0e115563 552
0fc2834c 553 # Run 5 times with a 1 second delay
dd238d2a 554 run_app_background $1 0 1
0fc2834c 555
0e115563 556 # Wait for the applications started in background
0fc2834c 557 wait
0e115563 558
96340a01 559 stop_lttng_tracing_ok $SESSION_NAME
67b4c664 560 destroy_lttng_session_ok $SESSION_NAME
0e115563
DG
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
bf6ae429 573 create_lttng_session_ok $SESSION_NAME $TRACE_PATH/$SESSION_NAME
0e115563 574 # Enable all event with a filter.
dd238d2a 575 enable_python_filter $SESSION_NAME '*' 'msg == "python-ev-test2 fired [INFO]"'
e563bbdb 576 start_lttng_tracing_ok $SESSION_NAME
0e115563
DG
577
578 # Run 5 times with a 1 second delay and fire second TP.
dd238d2a 579 run_app $1 0 1
0e115563 580
96340a01 581 stop_lttng_tracing_ok $SESSION_NAME
67b4c664 582 destroy_lttng_session_ok $SESSION_NAME
0e115563
DG
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
bf6ae429 590 create_lttng_session_ok $SESSION_NAME $TRACE_PATH/$SESSION_NAME
0e115563
DG
591 # Enable first Logger but filter msg payload for the INFO one while
592 # triggering the debug and second TP.
9586c198 593 enable_python_filter $SESSION_NAME $EVENT_NAME 'msg == "python-ev-test1 fired [INFO]"'
e563bbdb 594 start_lttng_tracing_ok $SESSION_NAME
0e115563
DG
595
596 # Run 5 times with a 1 second delay, fire debug and second TP.
dd238d2a 597 run_app $1 1 1
0e115563 598
96340a01 599 stop_lttng_tracing_ok $SESSION_NAME
67b4c664 600 destroy_lttng_session_ok $SESSION_NAME
0e115563
DG
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
bf6ae429 613 create_lttng_session_ok $SESSION_NAME $TRACE_PATH/$SESSION_NAME
0e115563
DG
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
e563bbdb 618 start_lttng_tracing_ok $SESSION_NAME
0e115563
DG
619
620 # Run 5 times with a 1 second delay and fire second TP.
dd238d2a 621 run_app $1 0 1
0e115563 622
96340a01 623 stop_lttng_tracing_ok $SESSION_NAME
67b4c664 624 destroy_lttng_session_ok $SESSION_NAME
0e115563
DG
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
bf6ae429 637 create_lttng_session_ok $SESSION_NAME $TRACE_PATH/$SESSION_NAME
0e115563
DG
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
e563bbdb 642 start_lttng_tracing_ok $SESSION_NAME
0e115563
DG
643
644 # Run 5 times with a 1 second delay and fire second TP.
dd238d2a 645 run_app $1 0 1
0e115563 646
96340a01 647 stop_lttng_tracing_ok $SESSION_NAME
67b4c664 648 destroy_lttng_session_ok $SESSION_NAME
0e115563
DG
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
bf6ae429 665 create_lttng_session_ok $SESSION_NAME $TRACE_PATH/$SESSION_NAME
0e115563
DG
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"
e563bbdb 670 start_lttng_tracing_ok $SESSION_NAME
0e115563
DG
671
672 # Run 5 times with a 1 second delay and fire second TP.
dd238d2a 673 run_app $1 0 1
0e115563 674
96340a01 675 stop_lttng_tracing_ok $SESSION_NAME
67b4c664 676 destroy_lttng_session_ok $SESSION_NAME
0e115563
DG
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
9586c198
JR
689if [[ ${#python_versions[@]} -eq 0 || "x$run_test" != "xyes" ]]; then
690 skip_agent=0
0e115563 691else
9586c198 692 skip_agent=1
0e115563
DG
693fi
694
9586c198 695skip $skip_agent "Python agent test skipped." $NUM_TESTS ||
0e115563
DG
696{
697 start_lttng_sessiond
698
699 tests=(
700 test_python_multi_session_disable_wildcard
aed7bbd2
PP
701 test_python_multi_session_disable_wildcard_begin
702 test_python_multi_session_disable_wildcard_middle
703 test_python_multi_session_disable_wildcard_end
0e115563
DG
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
9586c198
JR
719
720 for python_version in ${python_versions[*]};
0e115563 721 do
dd238d2a
PP
722 for fct_test in ${tests[@]};
723 do
724 TRACE_PATH=$(mktemp -d)
725
726 diag "(Python $python_version)"
9586c198 727 ${fct_test} $python_version
dd238d2a
PP
728 if [ $? -ne 0 ]; then
729 break;
730 fi
731 rm -rf $TRACE_PATH
732 done
0e115563 733 done
0e115563
DG
734 stop_lttng_sessiond
735}
This page took 0.097912 seconds and 4 git commands to generate.