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 if [ ! -x "$CURDIR/demo/demo" ]; then
38 BAIL_OUT
"No UST nevents binary detected."
41 # MUST set TESTDIR before calling those functions
48 diag
"Running application"
49 .
/demo-trace
>/dev
/null
2>&1
50 ok $?
"Application done"
55 # Ease our life a bit ;)
56 trace_match_demo1_events
()
58 trace_matches
"$DEMO_EVENT1" $NUM_DEMO1_EVENT $TRACE_PATH
59 trace_matches
"$DEMO_EVENT1_2" $NUM_DEMO1_EVENT $TRACE_PATH
62 # Ease our life a bit ;)
63 trace_match_all_demo_events
()
65 trace_match_demo1_events
66 trace_matches
"$DEMO_EVENT2" $NUM_DEMO2_EVENT $TRACE_PATH
67 trace_matches
"$DEMO_EVENT3" $NUM_DEMO3_EVENT $TRACE_PATH
70 # Ease our life a bit ;)
71 trace_match_no_demo_events
()
73 trace_matches
"$DEMO_EVENT1" 0 $TRACE_PATH
74 trace_matches
"$DEMO_EVENT1_2" 0 $TRACE_PATH
75 trace_matches
"$DEMO_EVENT2" 0 $TRACE_PATH
76 trace_matches
"$DEMO_EVENT3" 0 $TRACE_PATH
79 # Expect all "demo" events, no duplicate.
80 test_enable_simple_wildcard
()
82 local event_wild1
="us*"
83 local event_wild2
="ust*"
85 diag
"Simple wildcard overlap"
87 enable_ust_lttng_event_ok
$SESSION_NAME "$event_wild1"
88 enable_ust_lttng_event_ok
$SESSION_NAME "$event_wild2"
90 start_lttng_tracing_ok
$SESSION_NAME
94 stop_lttng_tracing
$SESSION_NAME
96 trace_match_all_demo_events
101 # Expect all "demo" events, no duplicate.
102 test_enable_wildcard_filter
()
104 local event_wild1
="us*"
105 local event_wild2
="ust*"
107 diag
"Wildcard overlap with filter"
109 enable_ust_lttng_event_filter
$SESSION_NAME "$event_wild1" "1==1"
110 enable_ust_lttng_event_filter
$SESSION_NAME "$event_wild2" "1==0"
112 start_lttng_tracing_ok
$SESSION_NAME
116 stop_lttng_tracing
$SESSION_NAME
118 trace_match_all_demo_events
122 # Expect all "demo" events, no duplicate.
123 test_enable_wildcard_filter_2
()
125 local event_wild1
="us*"
126 local event_wild2
="ust*"
128 diag
"Wildcard overlap with filter 2"
130 enable_ust_lttng_event_filter
$SESSION_NAME "$event_wild1" "1==0"
131 enable_ust_lttng_event_filter
$SESSION_NAME "$event_wild2" "1==1"
133 start_lttng_tracing_ok
$SESSION_NAME
137 stop_lttng_tracing
$SESSION_NAME
139 trace_match_all_demo_events
143 # Expect all "demo" events, no duplicate.
144 test_enable_wildcard_filter_3
()
146 local event_wild1
="us*"
147 local event_wild2
="ust*"
149 diag
"Wildcard overlap with filter 3"
151 enable_ust_lttng_event_filter
$SESSION_NAME "$event_wild1" "1==1"
152 enable_ust_lttng_event_filter
$SESSION_NAME "$event_wild2" "1==1"
154 start_lttng_tracing_ok
$SESSION_NAME
158 stop_lttng_tracing
$SESSION_NAME
160 trace_match_all_demo_events
164 # Expected: No events.
165 test_enable_wildcard_filter_4
()
167 local event_wild1
="us*"
168 local event_wild2
="ust*"
170 diag
"Wildcard overlap with filter 4"
172 enable_ust_lttng_event_filter
$SESSION_NAME "$event_wild1" "1==0"
173 enable_ust_lttng_event_filter
$SESSION_NAME "$event_wild2" "1==0"
175 start_lttng_tracing_ok
$SESSION_NAME
179 stop_lttng_tracing
$SESSION_NAME
181 trace_match_no_demo_events
185 # Expect all "demo" events, no duplicate.
186 test_enable_wildcard_filter_5
()
188 local event_wild1
="us*"
189 local event_wild2
="$DEMO_EVENT1"
191 diag
"Wildcard overlap with filter 5"
193 enable_ust_lttng_event_filter
$SESSION_NAME "$event_wild1" "1==1"
194 enable_ust_lttng_event_filter
$SESSION_NAME "$event_wild2" "1==0"
196 start_lttng_tracing_ok
$SESSION_NAME
200 stop_lttng_tracing
$SESSION_NAME
202 trace_match_all_demo_events
206 # Expect all $DEMO_EVENT1 events, no duplicate.
207 test_enable_wildcard_filter_6
()
209 local event_wild1
="us*"
210 local event_wild2
="$DEMO_EVENT1"
212 diag
"Wildcard overlap with filter 6"
214 enable_ust_lttng_event_filter
$SESSION_NAME "$event_wild1" "1==0"
215 enable_ust_lttng_event_filter
$SESSION_NAME "$event_wild2" "1==1"
217 start_lttng_tracing_ok
$SESSION_NAME
221 stop_lttng_tracing
$SESSION_NAME
223 trace_matches
$DEMO_EVENT1 $NUM_DEMO1_EVENT $TRACE_PATH
224 trace_matches
$DEMO_EVENT1_2 0 $TRACE_PATH
225 trace_matches
$DEMO_EVENT2 0 $TRACE_PATH
226 trace_matches
$DEMO_EVENT3 0 $TRACE_PATH
230 # Expect all events, no duplicate.
231 test_enable_wildcard_filter_7
()
233 local event_wild1
="us*"
234 local event_wild2
="$DEMO_EVENT1"
236 diag
"Wildcard overlap with filter 7"
238 enable_ust_lttng_event_filter
$SESSION_NAME "$event_wild1" "1==1"
239 enable_ust_lttng_event_filter
$SESSION_NAME "$event_wild2" "1==1"
241 start_lttng_tracing_ok
$SESSION_NAME
245 stop_lttng_tracing
$SESSION_NAME
247 trace_match_all_demo_events
251 # Expected: No events.
252 test_enable_wildcard_filter_8
()
254 local event_wild1
="us*"
255 local event_wild2
="$DEMO_EVENT1"
257 diag
"Wildcard overlap with filter 8"
259 enable_ust_lttng_event_filter
$SESSION_NAME "$event_wild1" "1==0"
260 enable_ust_lttng_event_filter
$SESSION_NAME "$event_wild2" "1==0"
262 start_lttng_tracing_ok
$SESSION_NAME
266 stop_lttng_tracing
$SESSION_NAME
268 trace_match_no_demo_events
273 test_enable_same_wildcard_filter
()
275 local event_wild1
="ust*"
276 local event_wild2
="ust*"
278 diag
"Same wildcard overlap with filter"
280 enable_ust_lttng_event_filter
$SESSION_NAME "$event_wild1" "1==1&&1==1"
281 enable_ust_lttng_event_filter
$SESSION_NAME "$event_wild2" "1==1"
283 start_lttng_tracing_ok
$SESSION_NAME
287 stop_lttng_tracing
$SESSION_NAME
289 trace_match_all_demo_events
294 test_enable_same_wildcard_filter_2
()
296 local event_wild1
="ust*"
297 local event_wild2
="ust*"
299 diag
"Same wildcard overlap with filter 2"
301 enable_ust_lttng_event_filter
$SESSION_NAME "$event_wild1" "1==1"
303 # Enabling the same events with same filters should fail. This one is expected to fail.
304 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN enable-event
"$event_wild2" -s $SESSION_NAME -u --filter "1==1" >/dev
/null
2>&1
305 if [ $?
-ne 0 ]; then
306 pass
"Enable event $event_name with filtering for session $sess_name twice failure detected"
308 fail
"Enable event $event_name with filtering for session $sess_name twice failure NOT detected"
311 start_lttng_tracing_ok
$SESSION_NAME
315 stop_lttng_tracing
$SESSION_NAME
317 trace_match_all_demo_events
322 test_enable_same_wildcard_filter_3
()
324 local event_wild1
="ust*"
325 local event_wild2
="ust*"
327 diag
"Same wildcard overlap with filter 3"
329 enable_ust_lttng_event_filter
$SESSION_NAME "$event_wild1" "1==1"
330 enable_ust_lttng_event_filter
$SESSION_NAME "$event_wild2" "1==0"
332 start_lttng_tracing_ok
$SESSION_NAME
336 stop_lttng_tracing
$SESSION_NAME
338 trace_match_all_demo_events
342 # Expected: No events.
343 test_enable_same_wildcard_filter_4
()
345 local event_wild1
="ust*"
346 local event_wild2
="ust*"
348 diag
"Same wildcard overlap with filter 4"
350 enable_ust_lttng_event_filter
$SESSION_NAME "$event_wild1" "1==0&&1==0"
351 enable_ust_lttng_event_filter
$SESSION_NAME "$event_wild2" "1==0"
353 start_lttng_tracing_ok
$SESSION_NAME
357 stop_lttng_tracing
$SESSION_NAME
359 trace_match_no_demo_events
363 # Expected: Only $DEMO_EVENT1
364 test_enable_same_event_filter
()
366 local event_wild1
="$DEMO_EVENT1"
367 local event_wild2
="$DEMO_EVENT1"
369 diag
"Enable same event with filter."
371 enable_ust_lttng_event_filter
$SESSION_NAME "$event_wild1" "1==1&&1==1"
372 enable_ust_lttng_event_filter
$SESSION_NAME "$event_wild2" "1==1"
374 start_lttng_tracing_ok
$SESSION_NAME
378 stop_lttng_tracing
$SESSION_NAME
380 trace_matches
$DEMO_EVENT1 $NUM_DEMO1_EVENT $TRACE_PATH
381 trace_matches
$DEMO_EVENT1_2 0 $TRACE_PATH
382 trace_matches
$DEMO_EVENT2 0 $TRACE_PATH
383 trace_matches
$DEMO_EVENT3 0 $TRACE_PATH
387 # Expected: No events.
388 test_disable_same_wildcard_filter
()
390 local event_wild1
="ust*"
391 local event_wild2
="ust*"
393 diag
"Disable same wildcard with filter."
395 enable_ust_lttng_event_filter
$SESSION_NAME "$event_wild1" "1==1&&1==1"
396 enable_ust_lttng_event_filter
$SESSION_NAME "$event_wild2" "1==1"
398 disable_ust_lttng_event
$SESSION_NAME "ust*"
400 start_lttng_tracing_ok
$SESSION_NAME
404 stop_lttng_tracing
$SESSION_NAME
406 trace_match_no_demo_events
411 test_enable_bad_wildcard
()
414 local event_wild1
="ust_tests_demo"
415 local event_wild2
="ust_tests_demo2"
416 local event_wild3
="ust_tests_demo3"
418 diag
"Enable bad wildcard"
420 enable_ust_lttng_event_ok
$SESSION_NAME "$event_wild1"
421 enable_ust_lttng_event_ok
$SESSION_NAME "$event_wild2"
422 enable_ust_lttng_event_ok
$SESSION_NAME "$event_wild3"
424 start_lttng_tracing_ok
$SESSION_NAME
428 stop_lttng_tracing
$SESSION_NAME
430 trace_match_no_demo_events
434 # Expect all "demo" events, no duplicate.
435 test_enable_simple_wildcard_2
()
437 local event_wild1
="us*"
438 local event_wild2
="$DEMO_EVENT1"
440 diag
"Simple wildcard 2"
442 enable_ust_lttng_event_ok
$SESSION_NAME "$event_wild1"
443 enable_ust_lttng_event_ok
$SESSION_NAME "$event_wild2"
445 start_lttng_tracing_ok
$SESSION_NAME
449 stop_lttng_tracing
$SESSION_NAME
451 trace_match_all_demo_events
455 # Expected: all CRIT events, + all warning events.
456 test_enable_loglevel_overlap
()
458 local event_wild1
="us*"
459 local event_wild2
="ust*"
461 diag
"Enable loglevel overlap"
463 enable_ust_lttng_event_loglevel
$SESSION_NAME "$event_wild1" "TRACE_WARNING"
464 enable_ust_lttng_event_loglevel
$SESSION_NAME "$event_wild2" "TRACE_CRIT"
466 start_lttng_tracing_ok
$SESSION_NAME
470 stop_lttng_tracing
$SESSION_NAME
472 trace_match_all_demo_events
476 # Expected: all CRIT events, + all warning events.
477 test_enable_loglevel_only_overlap
()
479 local event_wild1
="us*"
480 local event_wild2
="ust*"
482 diag
"Enable loglevel only overlap"
484 enable_ust_lttng_event_loglevel
$SESSION_NAME "$event_wild1" "TRACE_WARNING"
485 enable_ust_lttng_event_loglevel_only
$SESSION_NAME "$event_wild2" "TRACE_CRIT"
487 start_lttng_tracing_ok
$SESSION_NAME
491 stop_lttng_tracing
$SESSION_NAME
493 trace_match_all_demo_events
497 # Expected: all events
498 test_enable_loglevel_overlap_2
()
500 local event_wild1
="us*"
501 local event_wild2
="$DEMO_EVENT2"
503 diag
"Enable loglevel overlap 2"
505 enable_ust_lttng_event_loglevel
$SESSION_NAME "$event_wild1" "TRACE_WARNING"
506 enable_ust_lttng_event_loglevel
$SESSION_NAME "$event_wild2" "TRACE_CRIT"
508 start_lttng_tracing_ok
$SESSION_NAME
512 stop_lttng_tracing
$SESSION_NAME
514 trace_match_all_demo_events
518 # Expected only ust_tests_demo* events.
519 test_enable_same_wildcard_loglevels
()
521 local event_wild1
="ust*"
522 local event_wild2
="ust*"
524 diag
"Enable same wildcard with different loglevels"
526 enable_ust_lttng_event_loglevel
$SESSION_NAME "$event_wild1" "TRACE_CRIT"
527 enable_ust_lttng_event_loglevel
$SESSION_NAME "$event_wild2" "TRACE_WARNING"
529 start_lttng_tracing_ok
$SESSION_NAME
533 stop_lttng_tracing
$SESSION_NAME
535 trace_match_all_demo_events
539 # Expected only ust_tests_demo:starting events.
540 test_enable_same_event_loglevels
()
542 local event_wild1
="$DEMO_EVENT1"
543 local event_wild2
="$DEMO_EVENT1"
545 diag
"Enable same event with different loglevels"
547 enable_ust_lttng_event_loglevel
$SESSION_NAME "$event_wild1" "TRACE_CRIT"
548 enable_ust_lttng_event_loglevel
$SESSION_NAME "$event_wild2" "TRACE_WARNING"
550 start_lttng_tracing_ok
$SESSION_NAME
554 stop_lttng_tracing
$SESSION_NAME
556 trace_matches
$DEMO_EVENT1 $NUM_DEMO1_EVENT $TRACE_PATH
557 trace_matches
$DEMO_EVENT1_2 0 $TRACE_PATH
558 trace_matches
$DEMO_EVENT2 0 $TRACE_PATH
559 trace_matches
$DEMO_EVENT3 0 $TRACE_PATH
564 test_disable_simple_wildcard
()
566 local event_wild1
="us*"
567 local event_wild2
="$DEMO_EVENT1"
569 diag
"Disable simple wildcard"
571 enable_ust_lttng_event_ok
$SESSION_NAME "$event_wild1"
572 enable_ust_lttng_event_ok
$SESSION_NAME "$event_wild2"
574 disable_ust_lttng_event
$SESSION_NAME "$event_wild1"
575 disable_ust_lttng_event
$SESSION_NAME "$event_wild2"
577 start_lttng_tracing_ok
$SESSION_NAME
581 stop_lttng_tracing
$SESSION_NAME
583 # No events are expected.
584 trace_match_no_demo_events
588 # Expect only "ust_tests_demo" events.
589 test_disable_wildcard_overlap
()
591 local event_wild1
="us*"
592 local event_wild2
="$DEMO_EVENT1"
594 diag
"Disable wildcard overlap"
596 enable_ust_lttng_event_ok
$SESSION_NAME "$event_wild1"
597 enable_ust_lttng_event_ok
$SESSION_NAME "$event_wild2"
599 disable_ust_lttng_event
$SESSION_NAME "$event_wild1"
601 start_lttng_tracing_ok
$SESSION_NAME
605 stop_lttng_tracing
$SESSION_NAME
607 # Expect only "ust_tests_demo" events.
608 trace_matches
"$DEMO_EVENT1" $NUM_DEMO1_EVENT $TRACE_PATH
609 trace_matches
"$DEMO_EVENT1_2" 0 $TRACE_PATH
610 trace_matches
"$DEMO_EVENT2" 0 $TRACE_PATH
611 trace_matches
"$DEMO_EVENT3" 0 $TRACE_PATH
615 plan_tests
$NUM_TESTS
617 print_test_banner
"$TEST_DESC"
620 "test_enable_wildcard_filter"
621 "test_enable_wildcard_filter_2"
622 "test_enable_wildcard_filter_3"
623 "test_enable_wildcard_filter_4"
624 "test_enable_wildcard_filter_5"
625 "test_enable_wildcard_filter_6"
626 "test_enable_wildcard_filter_7"
627 "test_enable_wildcard_filter_8"
628 "test_enable_same_wildcard_filter"
629 "test_enable_same_wildcard_filter_2"
630 "test_enable_same_wildcard_filter_3"
631 "test_enable_same_wildcard_filter_4"
632 "test_enable_same_event_filter"
633 "test_enable_loglevel_only_overlap"
634 "test_enable_same_event_loglevels"
635 "test_enable_same_wildcard_loglevels"
636 "test_enable_bad_wildcard"
637 "test_enable_loglevel_overlap_2"
638 "test_enable_simple_wildcard"
639 "test_enable_simple_wildcard_2"
640 "test_enable_loglevel_overlap"
641 "test_disable_simple_wildcard"
642 "test_disable_wildcard_overlap"
645 TEST_COUNT
=${#TESTS[@]}
650 while [ "$i" -lt "$TEST_COUNT" ]; do
652 TRACE_PATH
=$
(mktemp
-d)
654 create_lttng_session_ok
$SESSION_NAME $TRACE_PATH
659 destroy_lttng_session
$SESSION_NAME