Tests: add globbing pattern tests to test_exclusion
[lttng-tools.git] / tests / regression / tools / exclusion / test_exclusion
CommitLineData
345121ec
DG
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
18TEST_DESC="Event exclusion"
19
20CURDIR=$(dirname $0)/
21TESTDIR=$CURDIR/../../..
22LTTNG_BIN="lttng"
23STATS_BIN="$TESTDIR/utils/babelstats.pl"
24SESSION_NAME="test-exclusion"
345121ec
DG
25TESTAPP_PATH="$TESTDIR/utils/testapp"
26TESTAPP_NAME="gen-ust-nevents"
27TESTAPP_BIN="$TESTAPP_PATH/$TESTAPP_NAME/$TESTAPP_NAME"
28NR_ITER=100
29NR_USEC_WAIT=1
062f6132 30NUM_TESTS=149
345121ec
DG
31
32source $TESTDIR/utils/utils.sh
33
34function enable_ust_lttng_all_event_exclusion()
35{
36 sess_name="$1"
37 exclusion="$2"
38
062f6132 39 $TESTDIR/../src/bin/lttng/$LTTNG_BIN enable-event -a -s $sess_name -u -x "$exclusion"
345121ec
DG
40}
41
42function run_apps
43{
062f6132 44 $TESTAPP_BIN $NR_ITER $NR_USEC_WAIT
345121ec
DG
45}
46
47function test_exclusion
48{
062f6132
PP
49 exclusions="$1"
50 event_name_expected_to_be_missing="$2"
345121ec
DG
51 trace_path=$(mktemp -d)
52
53 # Create session
bf6ae429 54 create_lttng_session_ok $SESSION_NAME $trace_path
345121ec 55
062f6132
PP
56 enable_ust_lttng_all_event_exclusion $SESSION_NAME "$exclusions"
57 ok $? "Enable lttng event with event \"$exclusions\" excluded"
345121ec
DG
58
59 # Trace apps
e563bbdb 60 start_lttng_tracing_ok $SESSION_NAME
345121ec 61 run_apps
96340a01 62 stop_lttng_tracing_ok $SESSION_NAME
345121ec
DG
63
64 # Destroy session
67b4c664 65 destroy_lttng_session_ok $SESSION_NAME
345121ec 66
062f6132 67 stats=`babeltrace $trace_path | $STATS_BIN --tracepoint "$event_name_expected_to_be_missing" | grep -v index`
345121ec 68 if [ ! -z "$stats" ]; then
062f6132 69 fail "Excluded event \"$event_name_expected_to_be_missing\" was found in trace!"
345121ec
DG
70 else
71 ok 0 "Validate trace exclusion output"
72 rm -rf $trace_path
73 fi
74}
75
062f6132
PP
76function 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" 2&>1 >/dev/null
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
345121ec
DG
95plan_tests $NUM_TESTS
96
97print_test_banner $TEST_DESC
98
99start_lttng_sessiond
100
062f6132
PP
101test_exclusion 'tp:tptest2' 'tp:tptest2'
102test_exclusion 'tp:tptest3' 'tp:tptest3'
103test_exclusion 'tp:tptest*' 'tp:tptest1'
104test_exclusion 'tp:tptest*' 'tp:tptest2'
105test_exclusion 'tp:tptest*' 'tp:tptest3'
106test_exclusion 'tp:tptest*' 'tp:tptest4'
107test_exclusion 'tp:tptest*' 'tp:tptest5'
108test_exclusion 'tp*tptest*' 'tp:tptest1'
109test_exclusion 'tp*tptest*' 'tp:tptest2'
110test_exclusion 'tp*tptest*' 'tp:tptest3'
111test_exclusion 'tp*tptest*' 'tp:tptest4'
112test_exclusion 'tp*tptest*' 'tp:tptest5'
113test_exclusion '*test2' 'tp:tptest2'
114test_exclusion '*test5' 'tp:tptest5'
115test_exclusion '*p*test*' 'tp:tptest1'
116test_exclusion '*p*test*' 'tp:tptest2'
117test_exclusion '*p*test*' 'tp:tptest3'
118test_exclusion '*p***test*' 'tp:tptest4'
119test_exclusion '*p*test*' 'tp:tptest5'
120test_exclusion '*3' 'tp:tptest3'
121test_exclusion 'tp*test3,*2' 'tp:tptest2'
122test_exclusion '**tp*test3,*2' 'tp:tptest3'
123
124# Cannot use exclusions with non-globbing event name
125test_exclusion_fail "allo" "lol"
126test_exclusion_fail "allo" "meow,lol"
127test_exclusion_fail "allo" "z*em"
128
129# Exclusion name excludes all possible event names
130test_exclusion_fail "allo*" "all*"
131test_exclusion_fail "allo*" "ze,all*,yes"
345121ec
DG
132
133stop_lttng_sessiond
This page took 0.041896 seconds and 5 git commands to generate.