949cd41df1459db3f3898ed1aeca49f6d2d2c178
[lttng-tools.git] / tests / regression / tools / exclusion / test_exclusion
1 #!/bin/bash
2 #
3 # Copyright (C) - 2012 Christian Babeux <christian.babeux@efficios.com>
4 #
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.
8 #
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
12 # more details.
13 #
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.
17
18 TEST_DESC="Event exclusion"
19
20 CURDIR=$(dirname $0)/
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"
27 NR_ITER=100
28 NR_USEC_WAIT=1
29 NUM_TESTS=149
30
31 source $TESTDIR/utils/utils.sh
32
33 function enable_ust_lttng_all_event_exclusion()
34 {
35 sess_name="$1"
36 exclusion="$2"
37
38 $TESTDIR/../src/bin/lttng/$LTTNG_BIN enable-event -a -s $sess_name -u -x "$exclusion"
39 }
40
41 function run_apps
42 {
43 $TESTAPP_BIN $NR_ITER $NR_USEC_WAIT
44 }
45
46 function test_exclusion
47 {
48 exclusions="$1"
49 event_name_expected_to_be_missing="$2"
50 trace_path=$(mktemp -d)
51
52 # Create session
53 create_lttng_session_ok $SESSION_NAME $trace_path
54
55 enable_ust_lttng_all_event_exclusion $SESSION_NAME "$exclusions"
56 ok $? "Enable lttng event with event \"$exclusions\" excluded"
57
58 # Trace apps
59 start_lttng_tracing_ok $SESSION_NAME
60 run_apps
61 stop_lttng_tracing_ok $SESSION_NAME
62
63 # Destroy session
64 destroy_lttng_session_ok $SESSION_NAME
65
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!"
69 else
70 ok 0 "Validate trace exclusion output"
71 rm -rf $trace_path
72 fi
73 }
74
75 function test_exclusion_fail
76 {
77 event_name="$1"
78 exclusions="$2"
79
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
82 res=$?
83 destroy_lttng_session_ok $SESSION_NAME
84
85 if [ $res -eq 0 ]; then
86 fail "Enable LTTng event \"$event_name\" with exclusion \"$exclusions\" passes"
87 return 1
88 else
89 pass "Enable LTTng event \"$event_name\" with exclusion \"$exclusions\" fails"
90 return 0
91 fi
92 }
93
94 plan_tests $NUM_TESTS
95
96 print_test_banner $TEST_DESC
97
98 start_lttng_sessiond
99
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'
122
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"
127
128 # Exclusion name excludes all possible event names
129 test_exclusion_fail "allo*" "all*"
130 test_exclusion_fail "allo*" "ze,all*,yes"
131
132 stop_lttng_sessiond
This page took 0.050304 seconds and 4 git commands to generate.