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