3 # Copyright (C) - 2012 Christian Babeux <christian.babeux@efficios.com>
5 # This program is free software; you can redistribute it and/or modify it
6 # under the terms of the GNU General Public License, version 2 only, as
7 # published by the Free Software Foundation.
9 # This program is distributed in the hope that it will be useful, but WITHOUT
10 # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 # FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
14 # You should have received a copy of the GNU General Public License along with
15 # this program; if not, write to the Free Software Foundation, Inc., 51
16 # Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
18 TEST_DESC
="Event exclusion"
21 TESTDIR
=$CURDIR/..
/..
/..
23 STATS_BIN
="$TESTDIR/utils/babelstats.pl"
24 SESSION_NAME
="test-exclusion"
25 TESTAPP_PATH
="$TESTDIR/utils/testapp"
26 TESTAPP_NAME
="gen-ust-nevents"
27 TESTAPP_BIN
="$TESTAPP_PATH/$TESTAPP_NAME/$TESTAPP_NAME"
32 source $TESTDIR/utils
/utils.sh
34 function enable_ust_lttng_all_event_exclusion
()
39 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN enable-event
-a -s $sess_name -u -x "$exclusion"
44 $TESTAPP_BIN $NR_ITER $NR_USEC_WAIT
47 function test_exclusion
50 event_name_expected_to_be_missing
="$2"
51 trace_path
=$
(mktemp
-d)
54 create_lttng_session_ok
$SESSION_NAME $trace_path
56 enable_ust_lttng_all_event_exclusion
$SESSION_NAME "$exclusions"
57 ok $?
"Enable lttng event with event \"$exclusions\" excluded"
60 start_lttng_tracing_ok
$SESSION_NAME
62 stop_lttng_tracing_ok
$SESSION_NAME
65 destroy_lttng_session_ok
$SESSION_NAME
67 stats
=`babeltrace $trace_path | $STATS_BIN --tracepoint "$event_name_expected_to_be_missing" | grep -v index`
68 if [ ! -z "$stats" ]; then
69 fail
"Excluded event \"$event_name_expected_to_be_missing\" was found in trace!"
71 ok
0 "Validate trace exclusion output"
76 function test_exclusion_fail
81 create_lttng_session_ok
$SESSION_NAME $trace_path
82 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN enable-event
-u "$event_name" -s $sess_name -x "$exclusions" >/dev
/null
2>&1
84 destroy_lttng_session_ok
$SESSION_NAME
86 if [ $res -eq 0 ]; then
87 fail
"Enable LTTng event \"$event_name\" with exclusion \"$exclusions\" passes"
90 pass
"Enable LTTng event \"$event_name\" with exclusion \"$exclusions\" fails"
97 print_test_banner
$TEST_DESC
101 test_exclusion
'tp:tptest2' 'tp:tptest2'
102 test_exclusion
'tp:tptest3' 'tp:tptest3'
103 test_exclusion
'tp:tptest*' 'tp:tptest1'
104 test_exclusion
'tp:tptest*' 'tp:tptest2'
105 test_exclusion
'tp:tptest*' 'tp:tptest3'
106 test_exclusion
'tp:tptest*' 'tp:tptest4'
107 test_exclusion
'tp:tptest*' 'tp:tptest5'
108 test_exclusion
'tp*tptest*' 'tp:tptest1'
109 test_exclusion
'tp*tptest*' 'tp:tptest2'
110 test_exclusion
'tp*tptest*' 'tp:tptest3'
111 test_exclusion
'tp*tptest*' 'tp:tptest4'
112 test_exclusion
'tp*tptest*' 'tp:tptest5'
113 test_exclusion
'*test2' 'tp:tptest2'
114 test_exclusion
'*test5' 'tp:tptest5'
115 test_exclusion
'*p*test*' 'tp:tptest1'
116 test_exclusion
'*p*test*' 'tp:tptest2'
117 test_exclusion
'*p*test*' 'tp:tptest3'
118 test_exclusion
'*p***test*' 'tp:tptest4'
119 test_exclusion
'*p*test*' 'tp:tptest5'
120 test_exclusion
'*3' 'tp:tptest3'
121 test_exclusion
'tp*test3,*2' 'tp:tptest2'
122 test_exclusion
'**tp*test3,*2' 'tp:tptest3'
124 # Cannot use exclusions with non-globbing event name
125 test_exclusion_fail
"allo" "lol"
126 test_exclusion_fail
"allo" "meow,lol"
127 test_exclusion_fail
"allo" "z*em"
129 # Exclusion name excludes all possible event names
130 test_exclusion_fail
"allo*" "all*"
131 test_exclusion_fail
"allo*" "ze,all*,yes"