3 # Copyright (C) - 2012 David Goulet <dgoulet@efficios.com>
5 # This library is free software; you can redistribute it and/or modify it under
6 # the terms of the GNU Lesser General Public License as published by the Free
7 # Software Foundation; version 2.1 of the License.
9 # This library is distributed in the hope that it will be useful, but WITHOUT
10 # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
11 # FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
14 # You should have received a copy of the GNU Lesser General Public License
15 # along with this library; if not, write to the Free Software Foundation, Inc.,
16 # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
17 TEST_DESC
="UST - Wildcard overlap"
20 TESTDIR
=$CURDIR/..
/..
/..
21 SESSION_NAME
="wildcard-overlap"
23 DEMO_EVENT1
="ust_tests_demo:starting"
24 DEMO_EVENT1_2
="ust_tests_demo:done"
25 DEMO_EVENT2
="ust_tests_demo2:loop"
26 DEMO_EVENT3
="ust_tests_demo3:done"
35 source $TESTDIR/utils
/utils.sh
37 print_test_banner
"$TEST_DESC"
39 if [ ! -x "$CURDIR/demo/demo" ]; then
40 BAIL_OUT
"No UST nevents binary detected."
43 # MUST set TESTDIR before calling those functions
50 .
/demo-trace
>/dev
/null
2>&1
51 ok $?
"Start application"
56 # Ease our life a bit ;)
57 trace_match_demo1_events
()
59 trace_matches
"$DEMO_EVENT1" $NUM_DEMO1_EVENT $TRACE_PATH
60 trace_matches
"$DEMO_EVENT1_2" $NUM_DEMO1_EVENT $TRACE_PATH
63 # Ease our life a bit ;)
64 trace_match_all_demo_events
()
66 trace_match_demo1_events
67 trace_matches
"$DEMO_EVENT2" $NUM_DEMO2_EVENT $TRACE_PATH
68 trace_matches
"$DEMO_EVENT3" $NUM_DEMO3_EVENT $TRACE_PATH
71 # Ease our life a bit ;)
72 trace_match_no_demo_events
()
74 trace_matches
"$DEMO_EVENT1" 0 $TRACE_PATH
75 trace_matches
"$DEMO_EVENT1_2" 0 $TRACE_PATH
76 trace_matches
"$DEMO_EVENT2" 0 $TRACE_PATH
77 trace_matches
"$DEMO_EVENT3" 0 $TRACE_PATH
80 # Expect all "demo" events, no duplicate.
81 test_enable_simple_wildcard
()
83 local event_wild1
="us*"
84 local event_wild2
="ust*"
86 diag
"Simple wildcard overlap"
88 enable_ust_lttng_event
$SESSION_NAME "$event_wild1"
89 enable_ust_lttng_event
$SESSION_NAME "$event_wild2"
91 start_lttng_tracing
$SESSION_NAME >/dev
/null
2>&1
95 stop_lttng_tracing
$SESSION_NAME >/dev
/null
2>&1
97 trace_match_all_demo_events
102 # Expect all "demo" events, no duplicate.
103 test_enable_wildcard_filter
()
105 local event_wild1
="us*"
106 local event_wild2
="ust*"
108 diag
"Wildcard overlap with filter"
110 enable_ust_lttng_event_filter
$SESSION_NAME "$event_wild1" "1==1"
111 enable_ust_lttng_event_filter
$SESSION_NAME "$event_wild2" "1==0"
113 start_lttng_tracing
$SESSION_NAME >/dev
/null
2>&1
117 stop_lttng_tracing
$SESSION_NAME >/dev
/null
2>&1
119 trace_match_all_demo_events
123 # Expect all "demo" events, no duplicate.
124 test_enable_wildcard_filter_2
()
126 local event_wild1
="us*"
127 local event_wild2
="ust*"
129 diag
"Wildcard overlap with filter 2"
131 enable_ust_lttng_event_filter
$SESSION_NAME "$event_wild1" "1==0"
132 enable_ust_lttng_event_filter
$SESSION_NAME "$event_wild2" "1==1"
134 start_lttng_tracing
$SESSION_NAME >/dev
/null
2>&1
138 stop_lttng_tracing
$SESSION_NAME >/dev
/null
2>&1
140 trace_match_all_demo_events
144 # Expect all "demo" events, no duplicate.
145 test_enable_wildcard_filter_3
()
147 local event_wild1
="us*"
148 local event_wild2
="ust*"
150 diag
"Wildcard overlap with filter 3"
152 enable_ust_lttng_event_filter
$SESSION_NAME "$event_wild1" "1==1"
153 enable_ust_lttng_event_filter
$SESSION_NAME "$event_wild2" "1==1"
155 start_lttng_tracing
$SESSION_NAME >/dev
/null
2>&1
159 stop_lttng_tracing
$SESSION_NAME >/dev
/null
2>&1
161 trace_match_all_demo_events
165 # Expected: No events.
166 test_enable_wildcard_filter_4
()
168 local event_wild1
="us*"
169 local event_wild2
="ust*"
171 diag
"Wildcard overlap with filter 4"
173 enable_ust_lttng_event_filter
$SESSION_NAME "$event_wild1" "1==0"
174 enable_ust_lttng_event_filter
$SESSION_NAME "$event_wild2" "1==0"
176 start_lttng_tracing
$SESSION_NAME >/dev
/null
2>&1
180 stop_lttng_tracing
$SESSION_NAME >/dev
/null
2>&1
182 trace_match_no_demo_events
186 # Expect all "demo" events, no duplicate.
187 test_enable_wildcard_filter_5
()
189 local event_wild1
="us*"
190 local event_wild2
="$DEMO_EVENT1"
192 diag
"Wildcard overlap with filter 5"
194 enable_ust_lttng_event_filter
$SESSION_NAME "$event_wild1" "1==1"
195 enable_ust_lttng_event_filter
$SESSION_NAME "$event_wild2" "1==0"
197 start_lttng_tracing
$SESSION_NAME >/dev
/null
2>&1
201 stop_lttng_tracing
$SESSION_NAME >/dev
/null
2>&1
203 trace_match_all_demo_events
207 # Expect all $DEMO_EVENT1 events, no duplicate.
208 test_enable_wildcard_filter_6
()
210 local event_wild1
="us*"
211 local event_wild2
="$DEMO_EVENT1"
213 diag
"Wildcard overlap with filter 6"
215 enable_ust_lttng_event_filter
$SESSION_NAME "$event_wild1" "1==0"
216 enable_ust_lttng_event_filter
$SESSION_NAME "$event_wild2" "1==1"
218 start_lttng_tracing
$SESSION_NAME >/dev
/null
2>&1
222 stop_lttng_tracing
$SESSION_NAME >/dev
/null
2>&1
224 trace_matches
$DEMO_EVENT1 $NUM_DEMO1_EVENT $TRACE_PATH
225 trace_matches
$DEMO_EVENT1_2 0 $TRACE_PATH
226 trace_matches
$DEMO_EVENT2 0 $TRACE_PATH
227 trace_matches
$DEMO_EVENT3 0 $TRACE_PATH
231 # Expect all events, no duplicate.
232 test_enable_wildcard_filter_7
()
234 local event_wild1
="us*"
235 local event_wild2
="$DEMO_EVENT1"
237 diag
"Wildcard overlap with filter 7"
239 enable_ust_lttng_event_filter
$SESSION_NAME "$event_wild1" "1==1"
240 enable_ust_lttng_event_filter
$SESSION_NAME "$event_wild2" "1==1"
242 start_lttng_tracing
$SESSION_NAME >/dev
/null
2>&1
246 stop_lttng_tracing
$SESSION_NAME >/dev
/null
2>&1
248 trace_match_all_demo_events
252 # Expected: No events.
253 test_enable_wildcard_filter_8
()
255 local event_wild1
="us*"
256 local event_wild2
="$DEMO_EVENT1"
258 diag
"Wildcard overlap with filter 8"
260 enable_ust_lttng_event_filter
$SESSION_NAME "$event_wild1" "1==0"
261 enable_ust_lttng_event_filter
$SESSION_NAME "$event_wild2" "1==0"
263 start_lttng_tracing
$SESSION_NAME >/dev
/null
2>&1
267 stop_lttng_tracing
$SESSION_NAME >/dev
/null
2>&1
269 trace_match_no_demo_events
274 test_enable_same_wildcard_filter
()
276 local event_wild1
="ust*"
277 local event_wild2
="ust*"
279 diag
"Same wildcard overlap with filter"
281 enable_ust_lttng_event_filter
$SESSION_NAME "$event_wild1" "1==1&&1==1"
282 enable_ust_lttng_event_filter
$SESSION_NAME "$event_wild2" "1==1"
284 start_lttng_tracing
$SESSION_NAME >/dev
/null
2>&1
288 stop_lttng_tracing
$SESSION_NAME >/dev
/null
2>&1
290 trace_match_all_demo_events
295 test_enable_same_wildcard_filter_2
()
297 local event_wild1
="ust*"
298 local event_wild2
="ust*"
300 diag
"Same wildcard overlap with filter 2"
302 enable_ust_lttng_event_filter
$SESSION_NAME "$event_wild1" "1==1"
304 # Enabling the same events with same filters should fail
305 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN enable-event
"$event_wild2" -s $SESSION_NAME -u --filter "1==1" >/dev
/null
2>&1
307 if [ $?
-eq 1 ]; then
308 pass
"Enable event $event_name with filtering for session $sess_name twice failure detected"
310 fail
"Enable event $event_name with filtering for session $sess_name twice failure detected"
313 start_lttng_tracing
$SESSION_NAME >/dev
/null
2>&1
317 stop_lttng_tracing
$SESSION_NAME >/dev
/null
2>&1
319 trace_match_all_demo_events
324 test_enable_same_wildcard_filter_3
()
326 local event_wild1
="ust*"
327 local event_wild2
="ust*"
329 diag
"Same wildcard overlap with filter 3"
331 enable_ust_lttng_event_filter
$SESSION_NAME "$event_wild1" "1==1"
332 enable_ust_lttng_event_filter
$SESSION_NAME "$event_wild2" "1==0"
334 start_lttng_tracing
$SESSION_NAME >/dev
/null
2>&1
338 stop_lttng_tracing
$SESSION_NAME >/dev
/null
2>&1
340 trace_match_all_demo_events
344 # Expected: No events.
345 test_enable_same_wildcard_filter_4
()
347 local event_wild1
="ust*"
348 local event_wild2
="ust*"
350 diag
"Same wildcard overlap with filter 4"
352 enable_ust_lttng_event_filter
$SESSION_NAME "$event_wild1" "1==0&&1==0"
353 enable_ust_lttng_event_filter
$SESSION_NAME "$event_wild2" "1==0"
355 start_lttng_tracing
$SESSION_NAME >/dev
/null
2>&1
359 stop_lttng_tracing
$SESSION_NAME >/dev
/null
2>&1
361 trace_match_no_demo_events
365 # Expected: Only $DEMO_EVENT1
366 test_enable_same_event_filter
()
368 local event_wild1
="$DEMO_EVENT1"
369 local event_wild2
="$DEMO_EVENT1"
371 diag
"Enable same event with filter."
373 enable_ust_lttng_event_filter
$SESSION_NAME "$event_wild1" "1==1&&1==1"
374 enable_ust_lttng_event_filter
$SESSION_NAME "$event_wild2" "1==1"
376 disable_ust_lttng_event
$SESSION_NAME "ust*"
378 start_lttng_tracing
$SESSION_NAME >/dev
/null
2>&1
382 stop_lttng_tracing
$SESSION_NAME >/dev
/null
2>&1
384 trace_matches
$DEMO_EVENT1 $NUM_DEMO1_EVENT $TRACE_PATH
385 trace_matches
$DEMO_EVENT1_2 0 $TRACE_PATH
386 trace_matches
$DEMO_EVENT2 0 $TRACE_PATH
387 trace_matches
$DEMO_EVENT3 0 $TRACE_PATH
391 # Expected: No events.
392 test_disable_same_wildcard_filter
()
394 local event_wild1
="ust*"
395 local event_wild2
="ust*"
397 diag
"Disable same wildcard with filter."
399 enable_ust_lttng_event_filter
$SESSION_NAME "$event_wild1" "1==1&&1==1"
400 enable_ust_lttng_event_filter
$SESSION_NAME "$event_wild2" "1==1"
402 disable_ust_lttng_event
$SESSION_NAME "ust*"
404 start_lttng_tracing
$SESSION_NAME >/dev
/null
2>&1
408 stop_lttng_tracing
$SESSION_NAME >/dev
/null
2>&1
410 trace_match_no_demo_events
415 test_enable_bad_wildcard
()
418 local event_wild1
="ust_tests_demo"
419 local event_wild2
="ust_tests_demo2"
420 local event_wild3
="ust_tests_demo3"
422 diag
"Enable bad wildcard"
424 enable_ust_lttng_event
$SESSION_NAME "$event_wild1"
425 enable_ust_lttng_event
$SESSION_NAME "$event_wild2"
426 enable_ust_lttng_event
$SESSION_NAME "$event_wild3"
428 start_lttng_tracing
$SESSION_NAME >/dev
/null
2>&1
432 stop_lttng_tracing
$SESSION_NAME >/dev
/null
2>&1
434 trace_match_no_demo_events
438 # Expect all "demo" events, no duplicate.
439 test_enable_simple_wildcard_2
()
441 local event_wild1
="us*"
442 local event_wild2
="$DEMO_EVENT1"
444 diag
"Simple wildcard 2"
446 enable_ust_lttng_event
$SESSION_NAME "$event_wild1"
447 enable_ust_lttng_event
$SESSION_NAME "$event_wild2"
449 start_lttng_tracing
$SESSION_NAME >/dev
/null
2>&1
453 stop_lttng_tracing
$SESSION_NAME >/dev
/null
2>&1
455 trace_match_all_demo_events
459 # Expected: all CRIT events, + all warning events.
460 test_enable_loglevel_overlap
()
462 local event_wild1
="us*"
463 local event_wild2
="ust*"
465 diag
"Enable loglevel overlap"
467 enable_ust_lttng_event_loglevel
$SESSION_NAME "$event_wild1" "TRACE_WARNING"
468 enable_ust_lttng_event_loglevel
$SESSION_NAME "$event_wild2" "TRACE_CRIT"
470 start_lttng_tracing
$SESSION_NAME >/dev
/null
2>&1
474 stop_lttng_tracing
$SESSION_NAME >/dev
/null
2>&1
476 trace_match_all_demo_events
480 # Expected: all CRIT events, + all warning events.
481 test_enable_loglevel_only_overlap
()
483 local event_wild1
="us*"
484 local event_wild2
="ust*"
486 diag
"Enable loglevel only overlap"
488 enable_ust_lttng_event_loglevel
$SESSION_NAME "$event_wild1" "TRACE_WARNING"
489 enable_ust_lttng_event_loglevel_only
$SESSION_NAME "$event_wild2" "TRACE_CRIT"
491 start_lttng_tracing
$SESSION_NAME >/dev
/null
2>&1
495 stop_lttng_tracing
$SESSION_NAME >/dev
/null
2>&1
497 trace_match_all_demo_events
501 # Expected: all events
502 test_enable_loglevel_overlap_2
()
504 local event_wild1
="us*"
505 local event_wild2
="$DEMO_EVENT2"
507 diag
"Enable loglevel overlap 2"
509 enable_ust_lttng_event_loglevel
$SESSION_NAME "$event_wild1" "TRACE_WARNING"
510 enable_ust_lttng_event_loglevel
$SESSION_NAME "$event_wild2" "TRACE_CRIT"
512 start_lttng_tracing
$SESSION_NAME >/dev
/null
2>&1
516 stop_lttng_tracing
$SESSION_NAME >/dev
/null
2>&1
518 trace_match_all_demo_events
522 # Expected only ust_tests_demo* events.
523 test_enable_same_wildcard_loglevels
()
525 local event_wild1
="ust*"
526 local event_wild2
="ust*"
528 diag
"Enable same wildcard with different loglevels"
530 enable_ust_lttng_event_loglevel
$SESSION_NAME "$event_wild1" "TRACE_CRIT"
531 enable_ust_lttng_event_loglevel
$SESSION_NAME "$event_wild2" "TRACE_WARNING"
533 start_lttng_tracing
$SESSION_NAME >/dev
/null
2>&1
537 stop_lttng_tracing
$SESSION_NAME >/dev
/null
2>&1
539 trace_match_all_demo_events
543 # Expected only ust_tests_demo:starting events.
544 test_enable_same_event_loglevels
()
546 local event_wild1
="$DEMO_EVENT1"
547 local event_wild2
="$DEMO_EVENT1"
549 diag
"Enable same event with different loglevels"
551 enable_ust_lttng_event_loglevel
$SESSION_NAME "$event_wild1" "TRACE_CRIT"
552 enable_ust_lttng_event_loglevel
$SESSION_NAME "$event_wild2" "TRACE_WARNING"
554 start_lttng_tracing
$SESSION_NAME >/dev
/null
2>&1
558 stop_lttng_tracing
$SESSION_NAME >/dev
/null
2>&1
560 trace_matches
$DEMO_EVENT1 $NUM_DEMO1_EVENT $TRACE_PATH
561 trace_matches
$DEMO_EVENT1_2 0 $TRACE_PATH
562 trace_matches
$DEMO_EVENT2 0 $TRACE_PATH
563 trace_matches
$DEMO_EVENT3 0 $TRACE_PATH
568 test_disable_simple_wildcard
()
570 local event_wild1
="us*"
571 local event_wild2
="$DEMO_EVENT1"
573 diag
"Disable simple wildcard"
575 enable_ust_lttng_event
$SESSION_NAME "$event_wild1"
576 enable_ust_lttng_event
$SESSION_NAME "$event_wild2"
578 disable_ust_lttng_event
$SESSION_NAME "$event_wild1"
579 disable_ust_lttng_event
$SESSION_NAME "$event_wild2"
581 start_lttng_tracing
$SESSION_NAME >/dev
/null
2>&1
585 stop_lttng_tracing
$SESSION_NAME >/dev
/null
2>&1
587 # No events are expected.
588 trace_match_no_demo_events
592 # Expect only "ust_tests_demo" events.
593 test_disable_wildcard_overlap
()
595 local event_wild1
="us*"
596 local event_wild2
="$DEMO_EVENT1"
598 diag
"Disable wildcard overlap"
600 enable_ust_lttng_event
$SESSION_NAME "$event_wild1"
601 enable_ust_lttng_event
$SESSION_NAME "$event_wild2"
603 disable_ust_lttng_event
$SESSION_NAME "$event_wild1"
605 start_lttng_tracing
$SESSION_NAME >/dev
/null
2>&1
609 stop_lttng_tracing
$SESSION_NAME >/dev
/null
2>&1
611 # Expect only "ust_tests_demo" events.
612 trace_matches
"$DEMO_EVENT1" $NUM_DEMO1_EVENT $TRACE_PATH
613 trace_matches
"$DEMO_EVENT1_2" 0 $TRACE_PATH
614 trace_matches
"$DEMO_EVENT2" 0 $TRACE_PATH
615 trace_matches
"$DEMO_EVENT3" 0 $TRACE_PATH
619 plan_tests
$NUM_TESTS
622 "test_enable_wildcard_filter"
623 "test_enable_wildcard_filter_2"
624 "test_enable_wildcard_filter_3"
625 "test_enable_wildcard_filter_4"
626 "test_enable_wildcard_filter_5"
627 "test_enable_wildcard_filter_6"
628 "test_enable_wildcard_filter_7"
629 "test_enable_wildcard_filter_8"
630 "test_enable_same_wildcard_filter"
631 "test_enable_same_wildcard_filter_2"
632 "test_enable_same_wildcard_filter_3"
633 "test_enable_same_wildcard_filter_4"
634 "test_enable_same_event_filter"
635 "test_enable_loglevel_only_overlap"
636 "test_enable_same_event_loglevels"
637 "test_enable_same_wildcard_loglevels"
638 "test_enable_bad_wildcard"
639 "test_enable_loglevel_overlap_2"
640 "test_enable_simple_wildcard"
641 "test_enable_simple_wildcard_2"
642 "test_enable_loglevel_overlap"
643 "test_disable_simple_wildcard"
644 "test_disable_wildcard_overlap"
647 TEST_COUNT
=${#TESTS[@]}
652 while [ "$i" -lt "$TEST_COUNT" ]; do
654 TRACE_PATH
=$
(mktemp
-d)
656 create_lttng_session
$SESSION_NAME $TRACE_PATH >/dev
/null
2>&1
660 if [ $?
-ne 0 ]; then
665 destroy_lttng_session
$SESSION_NAME >/dev
/null
2>&1