3 # Copyright (C) 2012 David Goulet <dgoulet@efficios.com>
5 # SPDX-License-Identifier: LGPL-2.1-only
7 TEST_DESC
="UST - Wildcard overlap"
10 TESTDIR
=$CURDIR/..
/..
/..
11 SESSION_NAME
="wildcard-overlap"
13 DEMO_EVENT1
="ust_tests_demo:starting"
14 DEMO_EVENT1_2
="ust_tests_demo:done"
15 DEMO_EVENT2
="ust_tests_demo2:loop"
16 DEMO_EVENT3
="ust_tests_demo3:done"
25 source $TESTDIR/utils
/utils.sh
27 # MUST set TESTDIR before calling those functions
34 diag
"Running application"
35 .
/demo-trace
>/dev
/null
2>&1
36 ok $?
"Application done"
41 # Ease our life a bit ;)
42 trace_match_demo1_events
()
44 trace_matches
"$DEMO_EVENT1" $NUM_DEMO1_EVENT $TRACE_PATH
45 trace_matches
"$DEMO_EVENT1_2" $NUM_DEMO1_EVENT $TRACE_PATH
48 # Ease our life a bit ;)
49 trace_match_all_demo_events
()
51 trace_match_demo1_events
52 trace_matches
"$DEMO_EVENT2" $NUM_DEMO2_EVENT $TRACE_PATH
53 trace_matches
"$DEMO_EVENT3" $NUM_DEMO3_EVENT $TRACE_PATH
56 # Ease our life a bit ;)
57 trace_match_no_demo_events
()
59 trace_matches
"$DEMO_EVENT1" 0 $TRACE_PATH
60 trace_matches
"$DEMO_EVENT1_2" 0 $TRACE_PATH
61 trace_matches
"$DEMO_EVENT2" 0 $TRACE_PATH
62 trace_matches
"$DEMO_EVENT3" 0 $TRACE_PATH
65 # Expect all "demo" events, no duplicate.
66 test_enable_simple_wildcard
()
68 local event_wild1
="us*"
69 local event_wild2
="ust*"
71 diag
"Simple wildcard overlap"
73 enable_ust_lttng_event_ok
$SESSION_NAME "$event_wild1"
74 enable_ust_lttng_event_ok
$SESSION_NAME "$event_wild2"
76 start_lttng_tracing_ok
$SESSION_NAME
80 stop_lttng_tracing_ok
$SESSION_NAME
82 trace_match_all_demo_events
87 # Expect all "demo" events, no duplicate.
88 test_enable_wildcard_filter
()
90 local event_wild1
="us*"
91 local event_wild2
="ust*"
93 diag
"Wildcard overlap with filter"
95 enable_ust_lttng_event_filter
$SESSION_NAME "$event_wild1" "1==1"
96 enable_ust_lttng_event_filter
$SESSION_NAME "$event_wild2" "1==0"
98 start_lttng_tracing_ok
$SESSION_NAME
102 stop_lttng_tracing_ok
$SESSION_NAME
104 trace_match_all_demo_events
108 # Expect all "demo" events, no duplicate.
109 test_enable_wildcard_filter_2
()
111 local event_wild1
="us*"
112 local event_wild2
="ust*"
114 diag
"Wildcard overlap with filter 2"
116 enable_ust_lttng_event_filter
$SESSION_NAME "$event_wild1" "1==0"
117 enable_ust_lttng_event_filter
$SESSION_NAME "$event_wild2" "1==1"
119 start_lttng_tracing_ok
$SESSION_NAME
123 stop_lttng_tracing_ok
$SESSION_NAME
125 trace_match_all_demo_events
129 # Expect all "demo" events, no duplicate.
130 test_enable_wildcard_filter_3
()
132 local event_wild1
="us*"
133 local event_wild2
="ust*"
135 diag
"Wildcard overlap with filter 3"
137 enable_ust_lttng_event_filter
$SESSION_NAME "$event_wild1" "1==1"
138 enable_ust_lttng_event_filter
$SESSION_NAME "$event_wild2" "1==1"
140 start_lttng_tracing_ok
$SESSION_NAME
144 stop_lttng_tracing_ok
$SESSION_NAME
146 trace_match_all_demo_events
150 # Expected: No events.
151 test_enable_wildcard_filter_4
()
153 local event_wild1
="us*"
154 local event_wild2
="ust*"
156 diag
"Wildcard overlap with filter 4"
158 enable_ust_lttng_event_filter
$SESSION_NAME "$event_wild1" "1==0"
159 enable_ust_lttng_event_filter
$SESSION_NAME "$event_wild2" "1==0"
161 start_lttng_tracing_ok
$SESSION_NAME
165 stop_lttng_tracing_ok
$SESSION_NAME
167 trace_match_no_demo_events
171 # Expect all "demo" events, no duplicate.
172 test_enable_wildcard_filter_5
()
174 local event_wild1
="us*"
175 local event_wild2
="$DEMO_EVENT1"
177 diag
"Wildcard overlap with filter 5"
179 enable_ust_lttng_event_filter
$SESSION_NAME "$event_wild1" "1==1"
180 enable_ust_lttng_event_filter
$SESSION_NAME "$event_wild2" "1==0"
182 start_lttng_tracing_ok
$SESSION_NAME
186 stop_lttng_tracing_ok
$SESSION_NAME
188 trace_match_all_demo_events
192 # Expect all $DEMO_EVENT1 events, no duplicate.
193 test_enable_wildcard_filter_6
()
195 local event_wild1
="us*"
196 local event_wild2
="$DEMO_EVENT1"
198 diag
"Wildcard overlap with filter 6"
200 enable_ust_lttng_event_filter
$SESSION_NAME "$event_wild1" "1==0"
201 enable_ust_lttng_event_filter
$SESSION_NAME "$event_wild2" "1==1"
203 start_lttng_tracing_ok
$SESSION_NAME
207 stop_lttng_tracing_ok
$SESSION_NAME
209 trace_matches
$DEMO_EVENT1 $NUM_DEMO1_EVENT $TRACE_PATH
210 trace_matches
$DEMO_EVENT1_2 0 $TRACE_PATH
211 trace_matches
$DEMO_EVENT2 0 $TRACE_PATH
212 trace_matches
$DEMO_EVENT3 0 $TRACE_PATH
216 # Expect all events, no duplicate.
217 test_enable_wildcard_filter_7
()
219 local event_wild1
="us*"
220 local event_wild2
="$DEMO_EVENT1"
222 diag
"Wildcard overlap with filter 7"
224 enable_ust_lttng_event_filter
$SESSION_NAME "$event_wild1" "1==1"
225 enable_ust_lttng_event_filter
$SESSION_NAME "$event_wild2" "1==1"
227 start_lttng_tracing_ok
$SESSION_NAME
231 stop_lttng_tracing_ok
$SESSION_NAME
233 trace_match_all_demo_events
237 # Expected: No events.
238 test_enable_wildcard_filter_8
()
240 local event_wild1
="us*"
241 local event_wild2
="$DEMO_EVENT1"
243 diag
"Wildcard overlap with filter 8"
245 enable_ust_lttng_event_filter
$SESSION_NAME "$event_wild1" "1==0"
246 enable_ust_lttng_event_filter
$SESSION_NAME "$event_wild2" "1==0"
248 start_lttng_tracing_ok
$SESSION_NAME
252 stop_lttng_tracing_ok
$SESSION_NAME
254 trace_match_no_demo_events
259 test_enable_same_wildcard_filter
()
261 local event_wild1
="ust*"
262 local event_wild2
="ust*"
264 diag
"Same wildcard overlap with filter"
266 enable_ust_lttng_event_filter
$SESSION_NAME "$event_wild1" "1==1&&1==1"
267 enable_ust_lttng_event_filter
$SESSION_NAME "$event_wild2" "1==1"
269 start_lttng_tracing_ok
$SESSION_NAME
273 stop_lttng_tracing_ok
$SESSION_NAME
275 trace_match_all_demo_events
280 test_enable_same_wildcard_filter_2
()
282 local event_wild1
="ust*"
283 local event_wild2
="ust*"
285 diag
"Same wildcard overlap with filter 2"
287 enable_ust_lttng_event_filter
$SESSION_NAME "$event_wild1" "1==1"
289 # Enabling the same events with same filters should fail. This one is expected to fail.
290 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN enable-event
"$event_wild2" -s $SESSION_NAME -u --filter "1==1" >/dev
/null
2>&1
291 if [ $?
-ne 0 ]; then
292 pass
"Enable event $event_name with filtering for session $sess_name twice failure detected"
294 fail
"Enable event $event_name with filtering for session $sess_name twice failure NOT detected"
297 start_lttng_tracing_ok
$SESSION_NAME
301 stop_lttng_tracing_ok
$SESSION_NAME
303 trace_match_all_demo_events
308 test_enable_same_wildcard_filter_3
()
310 local event_wild1
="ust*"
311 local event_wild2
="ust*"
313 diag
"Same wildcard overlap with filter 3"
315 enable_ust_lttng_event_filter
$SESSION_NAME "$event_wild1" "1==1"
316 enable_ust_lttng_event_filter
$SESSION_NAME "$event_wild2" "1==0"
318 start_lttng_tracing_ok
$SESSION_NAME
322 stop_lttng_tracing_ok
$SESSION_NAME
324 trace_match_all_demo_events
328 # Expected: No events.
329 test_enable_same_wildcard_filter_4
()
331 local event_wild1
="ust*"
332 local event_wild2
="ust*"
334 diag
"Same wildcard overlap with filter 4"
336 enable_ust_lttng_event_filter
$SESSION_NAME "$event_wild1" "1==0&&1==0"
337 enable_ust_lttng_event_filter
$SESSION_NAME "$event_wild2" "1==0"
339 start_lttng_tracing_ok
$SESSION_NAME
343 stop_lttng_tracing_ok
$SESSION_NAME
345 trace_match_no_demo_events
349 # Expected: Only $DEMO_EVENT1
350 test_enable_same_event_filter
()
352 local event_wild1
="$DEMO_EVENT1"
353 local event_wild2
="$DEMO_EVENT1"
355 diag
"Enable same event with filter."
357 enable_ust_lttng_event_filter
$SESSION_NAME "$event_wild1" "1==1&&1==1"
358 enable_ust_lttng_event_filter
$SESSION_NAME "$event_wild2" "1==1"
360 start_lttng_tracing_ok
$SESSION_NAME
364 stop_lttng_tracing_ok
$SESSION_NAME
366 trace_matches
$DEMO_EVENT1 $NUM_DEMO1_EVENT $TRACE_PATH
367 trace_matches
$DEMO_EVENT1_2 0 $TRACE_PATH
368 trace_matches
$DEMO_EVENT2 0 $TRACE_PATH
369 trace_matches
$DEMO_EVENT3 0 $TRACE_PATH
373 # Expected: No events.
374 test_disable_same_wildcard_filter
()
376 local event_wild1
="ust*"
377 local event_wild2
="ust*"
379 diag
"Disable same wildcard with filter."
381 enable_ust_lttng_event_filter
$SESSION_NAME "$event_wild1" "1==1&&1==1"
382 enable_ust_lttng_event_filter
$SESSION_NAME "$event_wild2" "1==1"
384 disable_ust_lttng_event
$SESSION_NAME "ust*"
386 start_lttng_tracing_ok
$SESSION_NAME
390 stop_lttng_tracing_ok
$SESSION_NAME
392 trace_match_no_demo_events
397 test_enable_bad_wildcard
()
400 local event_wild1
="ust_tests_demo"
401 local event_wild2
="ust_tests_demo2"
402 local event_wild3
="ust_tests_demo3"
404 diag
"Enable bad wildcard"
406 enable_ust_lttng_event_ok
$SESSION_NAME "$event_wild1"
407 enable_ust_lttng_event_ok
$SESSION_NAME "$event_wild2"
408 enable_ust_lttng_event_ok
$SESSION_NAME "$event_wild3"
410 start_lttng_tracing_ok
$SESSION_NAME
414 stop_lttng_tracing_ok
$SESSION_NAME
416 trace_match_no_demo_events
420 # Expect all "demo" events, no duplicate.
421 test_enable_simple_wildcard_2
()
423 local event_wild1
="us*"
424 local event_wild2
="$DEMO_EVENT1"
426 diag
"Simple wildcard 2"
428 enable_ust_lttng_event_ok
$SESSION_NAME "$event_wild1"
429 enable_ust_lttng_event_ok
$SESSION_NAME "$event_wild2"
431 start_lttng_tracing_ok
$SESSION_NAME
435 stop_lttng_tracing_ok
$SESSION_NAME
437 trace_match_all_demo_events
441 # Expected: all CRIT events, + all warning events.
442 test_enable_loglevel_overlap
()
444 local event_wild1
="us*"
445 local event_wild2
="ust*"
447 diag
"Enable loglevel overlap"
449 enable_ust_lttng_event_loglevel
$SESSION_NAME "$event_wild1" "TRACE_WARNING"
450 enable_ust_lttng_event_loglevel
$SESSION_NAME "$event_wild2" "TRACE_CRIT"
452 start_lttng_tracing_ok
$SESSION_NAME
456 stop_lttng_tracing_ok
$SESSION_NAME
458 trace_match_all_demo_events
462 # Expected: all CRIT events, + all warning events.
463 test_enable_loglevel_only_overlap
()
465 local event_wild1
="us*"
466 local event_wild2
="ust*"
468 diag
"Enable loglevel only overlap"
470 enable_ust_lttng_event_loglevel
$SESSION_NAME "$event_wild1" "TRACE_WARNING"
471 enable_ust_lttng_event_loglevel_only
$SESSION_NAME "$event_wild2" "TRACE_CRIT"
473 start_lttng_tracing_ok
$SESSION_NAME
477 stop_lttng_tracing_ok
$SESSION_NAME
479 trace_match_all_demo_events
483 # Expected: all events
484 test_enable_loglevel_overlap_2
()
486 local event_wild1
="us*"
487 local event_wild2
="$DEMO_EVENT2"
489 diag
"Enable loglevel overlap 2"
491 enable_ust_lttng_event_loglevel
$SESSION_NAME "$event_wild1" "TRACE_WARNING"
492 enable_ust_lttng_event_loglevel
$SESSION_NAME "$event_wild2" "TRACE_CRIT"
494 start_lttng_tracing_ok
$SESSION_NAME
498 stop_lttng_tracing_ok
$SESSION_NAME
500 trace_match_all_demo_events
504 # Expected only ust_tests_demo* events.
505 test_enable_same_wildcard_loglevels
()
507 local event_wild1
="ust*"
508 local event_wild2
="ust*"
510 diag
"Enable same wildcard with different loglevels"
512 enable_ust_lttng_event_loglevel
$SESSION_NAME "$event_wild1" "TRACE_CRIT"
513 enable_ust_lttng_event_loglevel
$SESSION_NAME "$event_wild2" "TRACE_WARNING"
515 start_lttng_tracing_ok
$SESSION_NAME
519 stop_lttng_tracing_ok
$SESSION_NAME
521 trace_match_all_demo_events
525 # Expected only ust_tests_demo:starting events.
526 test_enable_same_event_loglevels
()
528 local event_wild1
="$DEMO_EVENT1"
529 local event_wild2
="$DEMO_EVENT1"
531 diag
"Enable same event with different loglevels"
533 enable_ust_lttng_event_loglevel
$SESSION_NAME "$event_wild1" "TRACE_CRIT"
534 enable_ust_lttng_event_loglevel
$SESSION_NAME "$event_wild2" "TRACE_WARNING"
536 start_lttng_tracing_ok
$SESSION_NAME
540 stop_lttng_tracing_ok
$SESSION_NAME
542 trace_matches
$DEMO_EVENT1 $NUM_DEMO1_EVENT $TRACE_PATH
543 trace_matches
$DEMO_EVENT1_2 0 $TRACE_PATH
544 trace_matches
$DEMO_EVENT2 0 $TRACE_PATH
545 trace_matches
$DEMO_EVENT3 0 $TRACE_PATH
550 test_disable_simple_wildcard
()
552 local event_wild1
="us*"
553 local event_wild2
="$DEMO_EVENT1"
555 diag
"Disable simple wildcard"
557 enable_ust_lttng_event_ok
$SESSION_NAME "$event_wild1"
558 enable_ust_lttng_event_ok
$SESSION_NAME "$event_wild2"
560 disable_ust_lttng_event
$SESSION_NAME "$event_wild1"
561 disable_ust_lttng_event
$SESSION_NAME "$event_wild2"
563 start_lttng_tracing_ok
$SESSION_NAME
567 stop_lttng_tracing_ok
$SESSION_NAME
569 # No events are expected.
570 trace_match_no_demo_events
574 # Expect only "ust_tests_demo" events.
575 test_disable_wildcard_overlap
()
577 local event_wild1
="us*"
578 local event_wild2
="$DEMO_EVENT1"
580 diag
"Disable wildcard overlap"
582 enable_ust_lttng_event_ok
$SESSION_NAME "$event_wild1"
583 enable_ust_lttng_event_ok
$SESSION_NAME "$event_wild2"
585 disable_ust_lttng_event
$SESSION_NAME "$event_wild1"
587 start_lttng_tracing_ok
$SESSION_NAME
591 stop_lttng_tracing_ok
$SESSION_NAME
593 # Expect only "ust_tests_demo" events.
594 trace_matches
"$DEMO_EVENT1" $NUM_DEMO1_EVENT $TRACE_PATH
595 trace_matches
"$DEMO_EVENT1_2" 0 $TRACE_PATH
596 trace_matches
"$DEMO_EVENT2" 0 $TRACE_PATH
597 trace_matches
"$DEMO_EVENT3" 0 $TRACE_PATH
601 plan_tests
$NUM_TESTS
603 print_test_banner
"$TEST_DESC"
605 bail_out_if_no_babeltrace
607 if [ -x "$CURDIR/demo/demo" ]; then
613 skip
$foundbin "No UST nevents binary detected. Skipping all tests." $NUM_TESTS && exit 0
616 "test_enable_wildcard_filter"
617 "test_enable_wildcard_filter_2"
618 "test_enable_wildcard_filter_3"
619 "test_enable_wildcard_filter_4"
620 "test_enable_wildcard_filter_5"
621 "test_enable_wildcard_filter_6"
622 "test_enable_wildcard_filter_7"
623 "test_enable_wildcard_filter_8"
624 "test_enable_same_wildcard_filter"
625 "test_enable_same_wildcard_filter_2"
626 "test_enable_same_wildcard_filter_3"
627 "test_enable_same_wildcard_filter_4"
628 "test_enable_same_event_filter"
629 "test_enable_loglevel_only_overlap"
630 "test_enable_same_event_loglevels"
631 "test_enable_same_wildcard_loglevels"
632 "test_enable_bad_wildcard"
633 "test_enable_loglevel_overlap_2"
634 "test_enable_simple_wildcard"
635 "test_enable_simple_wildcard_2"
636 "test_enable_loglevel_overlap"
637 "test_disable_simple_wildcard"
638 "test_disable_wildcard_overlap"
641 TEST_COUNT
=${#TESTS[@]}
646 while [ "$i" -lt "$TEST_COUNT" ]; do
648 TRACE_PATH
=$
(mktemp
-d -t tmp.test_overlap.XXXXXX
)
650 create_lttng_session_ok
$SESSION_NAME $TRACE_PATH
655 destroy_lttng_session_ok
$SESSION_NAME