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/..
/..
/..
22 STATS_BIN
="$TESTDIR/utils/babelstats.pl"
23 SESSION_NAME
="test-exclusion"
24 TESTAPP_PATH
="$TESTDIR/utils/testapp"
25 TESTAPP_NAME
="gen-ust-nevents"
26 TESTAPP_BIN
="$TESTAPP_PATH/$TESTAPP_NAME/$TESTAPP_NAME"
31 source $TESTDIR/utils
/utils.sh
33 function enable_ust_lttng_all_event_exclusion
()
38 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN enable-event
-a -s $sess_name -u -x "$exclusion"
43 $TESTAPP_BIN -i $NR_ITER -w $NR_USEC_WAIT >/dev
/null
2>&1
46 function test_exclusion
49 event_name_expected_to_be_missing
="$2"
50 trace_path
=$
(mktemp
-d)
53 create_lttng_session_ok
$SESSION_NAME $trace_path
55 enable_ust_lttng_all_event_exclusion
$SESSION_NAME "$exclusions"
56 ok $?
"Enable lttng event with event \"$exclusions\" excluded"
59 start_lttng_tracing_ok
$SESSION_NAME
61 stop_lttng_tracing_ok
$SESSION_NAME
64 destroy_lttng_session_ok
$SESSION_NAME
66 stats
=`babeltrace $trace_path | $STATS_BIN --tracepoint "$event_name_expected_to_be_missing" | grep -v index`
67 if [ ! -z "$stats" ]; then
68 fail
"Excluded event \"$event_name_expected_to_be_missing\" was found in trace!"
70 ok
0 "Validate trace exclusion output"
75 function test_exclusion_fail
80 create_lttng_session_ok
$SESSION_NAME $trace_path
81 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN enable-event
-u "$event_name" -s $sess_name -x "$exclusions" >/dev
/null
2>&1
83 destroy_lttng_session_ok
$SESSION_NAME
85 if [ $res -eq 0 ]; then
86 fail
"Enable LTTng event \"$event_name\" with exclusion \"$exclusions\" passes"
89 pass
"Enable LTTng event \"$event_name\" with exclusion \"$exclusions\" fails"
96 print_test_banner
$TEST_DESC
100 test_exclusion
'tp:tptest2' 'tp:tptest2'
101 test_exclusion
'tp:tptest3' 'tp:tptest3'
102 test_exclusion
'tp:tptest*' 'tp:tptest1'
103 test_exclusion
'tp:tptest*' 'tp:tptest2'
104 test_exclusion
'tp:tptest*' 'tp:tptest3'
105 test_exclusion
'tp:tptest*' 'tp:tptest4'
106 test_exclusion
'tp:tptest*' 'tp:tptest5'
107 test_exclusion
'tp*tptest*' 'tp:tptest1'
108 test_exclusion
'tp*tptest*' 'tp:tptest2'
109 test_exclusion
'tp*tptest*' 'tp:tptest3'
110 test_exclusion
'tp*tptest*' 'tp:tptest4'
111 test_exclusion
'tp*tptest*' 'tp:tptest5'
112 test_exclusion
'*test2' 'tp:tptest2'
113 test_exclusion
'*test5' 'tp:tptest5'
114 test_exclusion
'*p*test*' 'tp:tptest1'
115 test_exclusion
'*p*test*' 'tp:tptest2'
116 test_exclusion
'*p*test*' 'tp:tptest3'
117 test_exclusion
'*p***test*' 'tp:tptest4'
118 test_exclusion
'*p*test*' 'tp:tptest5'
119 test_exclusion
'*3' 'tp:tptest3'
120 test_exclusion
'tp*test3,*2' 'tp:tptest2'
121 test_exclusion
'**tp*test3,*2' 'tp:tptest3'
123 # Cannot use exclusions with non-globbing event name
124 test_exclusion_fail
"allo" "lol"
125 test_exclusion_fail
"allo" "meow,lol"
126 test_exclusion_fail
"allo" "z*em"
128 # Exclusion name excludes all possible event names
129 test_exclusion_fail
"allo*" "all*"
130 test_exclusion_fail
"allo*" "ze,all*,yes"