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