Gen-ust-events: use options instead of arguments
[lttng-tools.git] / tests / regression / tools / wildcard / test_event_wildcard
CommitLineData
3de31d0b
CB
1#!/bin/bash
2#
3# Copyright (C) - 2013 Christian Babeux <christian.babeux@efficios.com>
075ffe1f 4# Copyright (C) - 2015 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
3de31d0b
CB
5#
6# This program is free software; you can redistribute it and/or modify it
7# under the terms of the GNU General Public License, version 2 only, as
8# published by the Free Software Foundation.
9#
10# This program is distributed in the hope that it will be useful, but WITHOUT
11# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
13# more details.
14#
15# You should have received a copy of the GNU General Public License along with
16# this program; if not, write to the Free Software Foundation, Inc., 51
17# Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
18
4a180d9f 19TEST_DESC="LTTng - Event wildcard test"
3de31d0b
CB
20
21CURDIR=$(dirname $0)/
f34b33a2 22TESTDIR=$CURDIR/../../..
075ffe1f
MD
23TESTAPP_PATH="$TESTDIR/utils/testapp"
24TESTAPP_NAME="gen-ust-events"
25TESTAPP_BIN="$TESTAPP_PATH/$TESTAPP_NAME/$TESTAPP_NAME"
26SESSION_NAME="wildcard"
075ffe1f 27NR_ITER=100
4a180d9f 28NUM_GLOBAL_TESTS=2
862832e9
PP
29NUM_UST_TESTS=$(( 7 * 25 ))
30NUM_KERNEL_TESTS=$(( 7 * 25 ))
4a180d9f 31NUM_TESTS=$(($NUM_UST_TESTS+$NUM_KERNEL_TESTS+$NUM_GLOBAL_TESTS))
3de31d0b
CB
32
33source $TESTDIR/utils/utils.sh
34
4a180d9f
MD
35function run_ust
36{
a4c30524 37 $TESTAPP_BIN -i $NR_ITER -w $NR_USEC_WAIT
4a180d9f
MD
38}
39
40function run_kernel
41{
42 # Trigger the event for 100 iterations
43 echo -n "100" > /proc/lttng-test-filter-event
44}
075ffe1f 45
3de31d0b
CB
46function test_event_wildcard()
47{
48 TRACE_PATH=$(mktemp -d)
4a180d9f
MD
49 DOMAIN="$1"
50 FIND="$2"
51 WILDCARD="$3"
862832e9 52 CHANNEL=''
3de31d0b 53
bf6ae429 54 create_lttng_session_ok $SESSION_NAME $TRACE_PATH
862832e9
PP
55
56 if [ $DOMAIN = kernel ]; then
57 CHANNEL=chan
58 $TESTDIR/../src/bin/lttng/$LTTNG_BIN enable-channel -k chan -s $SESSION_NAME --subbuf-size=8M --num-subbuf=4
59 fi
60
61 enable_${DOMAIN}_lttng_event_ok $SESSION_NAME "$WILDCARD" "$CHANNEL"
3de31d0b 62
e563bbdb 63 start_lttng_tracing_ok
075ffe1f 64
4a180d9f 65 run_${DOMAIN}
075ffe1f
MD
66 ok $? "Traced application stopped."
67
96340a01 68 stop_lttng_tracing_ok
075ffe1f
MD
69 destroy_lttng_session_ok $SESSION_NAME
70
71 if [ ${FIND} -eq 1 ]; then
72 trace_matches $EVENT_NAME $NR_ITER $TRACE_PATH
73 else
862832e9 74 trace_matches $EVENT_NAME 0 $TRACE_PATH
075ffe1f
MD
75 fi
76
77 rm -rf $TRACE_PATH
78}
3de31d0b 79
075ffe1f
MD
80function test_event_wildcard_fail()
81{
82 TRACE_PATH=$(mktemp -d)
4a180d9f
MD
83 DOMAIN="$1"
84 WILDCARD="$2"
3de31d0b 85
075ffe1f 86 create_lttng_session_ok $SESSION_NAME $TRACE_PATH
4a180d9f 87 enable_${DOMAIN}_lttng_event_fail $SESSION_NAME "$WILDCARD"
67b4c664 88 destroy_lttng_session_ok $SESSION_NAME
3de31d0b
CB
89
90 rm -rf $TRACE_PATH
91}
92
93# MUST set TESTDIR before calling those functions
94plan_tests $NUM_TESTS
95
e3bef725
CB
96print_test_banner "$TEST_DESC"
97
3de31d0b
CB
98start_lttng_sessiond
99
4a180d9f
MD
100diag "Test UST wildcard"
101
102if [ ! -x "$TESTAPP_BIN" ]; then
103 BAIL_OUT "No UST nevents binary detected."
104fi
105
106EVENT_NAME="tp:tptest"
107
862832e9
PP
108# non-matching
109test_event_wildcard ust 0 'tp:abc*'
110test_event_wildcard ust 0 '*abc'
111test_event_wildcard ust 0 '*z*'
112test_event_wildcard ust 0 '*\**'
113test_event_wildcard ust 0 '*\*'
114test_event_wildcard ust 0 '\**'
115test_event_wildcard ust 0 '*:*tpte*s'
116test_event_wildcard ust 0 'tp**tpTest'
117
118# matching
4a180d9f
MD
119test_event_wildcard ust 1 'tp:tp*'
120test_event_wildcard ust 1 '*'
121test_event_wildcard ust 1 'tp:tptest*'
862832e9
PP
122test_event_wildcard ust 1 '**'
123test_event_wildcard ust 1 '***'
124test_event_wildcard ust 1 '*tptest'
125test_event_wildcard ust 1 '**tptest'
126test_event_wildcard ust 1 '*tpte*'
127test_event_wildcard ust 1 '*tp*'
128test_event_wildcard ust 1 '*tp**'
129test_event_wildcard ust 1 '*:*tptest'
130test_event_wildcard ust 1 '*:*tpte*t'
131test_event_wildcard ust 1 't*p*:*t*e*s*t'
132test_event_wildcard ust 1 '*t*p*:*t*e*s*t*'
133test_event_wildcard ust 1 'tp*tptest'
134test_event_wildcard ust 1 'tp**tptest'
135test_event_wildcard ust 1 'tp*test'
4a180d9f
MD
136
137if [ "$(id -u)" == "0" ]; then
138 isroot=1
139else
140 isroot=0
141fi
075ffe1f 142
4a180d9f
MD
143skip $isroot "Root access is needed. Skipping all kernel wildcard tests." $NUM_KERNEL_TESTS ||
144{
145 diag "Test kernel wildcards"
146
147 modprobe lttng-test
148
149 EVENT_NAME="lttng_test_filter_event"
150
862832e9
PP
151 # non-matching
152 test_event_wildcard kernel 0 'lttng_test_abc*'
153 test_event_wildcard kernel 0 '*abc'
154 test_event_wildcard kernel 0 '*z*'
155 test_event_wildcard kernel 0 '*\**'
156 test_event_wildcard kernel 0 '*\*'
157 test_event_wildcard kernel 0 '\**'
158 test_event_wildcard kernel 0 '*:*eve*n'
159
160 # matching
161 test_event_wildcard kernel 1 'lttng_test_fil*'
162 test_event_wildcard kernel 1 '*'
4a180d9f 163 test_event_wildcard kernel 1 'lttng_test_filter_event*'
862832e9
PP
164 test_event_wildcard kernel 1 '**'
165 test_event_wildcard kernel 1 '***'
166 test_event_wildcard kernel 1 '*filter_event'
167 test_event_wildcard kernel 1 '*ter_ev*'
168 test_event_wildcard kernel 1 '*test*'
169 test_event_wildcard kernel 1 '*test**'
170 test_event_wildcard kernel 1 '*e*'
171 test_event_wildcard kernel 1 '*_*event'
172 test_event_wildcard kernel 1 '*_*filter_*nt'
173 test_event_wildcard kernel 1 '*_**filter_*nt'
174 test_event_wildcard kernel 1 'l*t*t*n*g*_*t*e*s*t*_*f*i*l*t*e*r*_*e*v*e*n*t'
175 test_event_wildcard kernel 1 '*l*t*t*n*g*_*t*e*s*t*_*f*i*l*t*e*r*_*e*v*e*n*t*'
176 test_event_wildcard kernel 1 'lttng*event'
177 test_event_wildcard kernel 1 'lttng*test*filter*event'
178 test_event_wildcard kernel 1 '*lttng*test*filter*event*'
4a180d9f
MD
179
180 rmmod lttng-test
181}
3de31d0b
CB
182
183stop_lttng_sessiond
This page took 0.083905 seconds and 5 git commands to generate.