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