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