Tests: add globbing pattern tests to test_event_wildcard
[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/../../..
3de31d0b 23LTTNG_BIN="lttng"
075ffe1f
MD
24TESTAPP_PATH="$TESTDIR/utils/testapp"
25TESTAPP_NAME="gen-ust-events"
26TESTAPP_BIN="$TESTAPP_PATH/$TESTAPP_NAME/$TESTAPP_NAME"
27SESSION_NAME="wildcard"
075ffe1f 28NR_ITER=100
4a180d9f 29NUM_GLOBAL_TESTS=2
862832e9
PP
30NUM_UST_TESTS=$(( 7 * 25 ))
31NUM_KERNEL_TESTS=$(( 7 * 25 ))
4a180d9f 32NUM_TESTS=$(($NUM_UST_TESTS+$NUM_KERNEL_TESTS+$NUM_GLOBAL_TESTS))
3de31d0b
CB
33
34source $TESTDIR/utils/utils.sh
35
4a180d9f
MD
36function run_ust
37{
38 $TESTAPP_BIN $NR_ITER $NR_USEC_WAIT
39}
40
41function run_kernel
42{
43 # Trigger the event for 100 iterations
44 echo -n "100" > /proc/lttng-test-filter-event
45}
075ffe1f 46
3de31d0b
CB
47function test_event_wildcard()
48{
49 TRACE_PATH=$(mktemp -d)
4a180d9f
MD
50 DOMAIN="$1"
51 FIND="$2"
52 WILDCARD="$3"
862832e9 53 CHANNEL=''
3de31d0b 54
bf6ae429 55 create_lttng_session_ok $SESSION_NAME $TRACE_PATH
862832e9
PP
56
57 if [ $DOMAIN = kernel ]; then
58 CHANNEL=chan
59 $TESTDIR/../src/bin/lttng/$LTTNG_BIN enable-channel -k chan -s $SESSION_NAME --subbuf-size=8M --num-subbuf=4
60 fi
61
62 enable_${DOMAIN}_lttng_event_ok $SESSION_NAME "$WILDCARD" "$CHANNEL"
3de31d0b 63
e563bbdb 64 start_lttng_tracing_ok
075ffe1f 65
4a180d9f 66 run_${DOMAIN}
075ffe1f
MD
67 ok $? "Traced application stopped."
68
96340a01 69 stop_lttng_tracing_ok
075ffe1f
MD
70 destroy_lttng_session_ok $SESSION_NAME
71
72 if [ ${FIND} -eq 1 ]; then
73 trace_matches $EVENT_NAME $NR_ITER $TRACE_PATH
74 else
862832e9 75 trace_matches $EVENT_NAME 0 $TRACE_PATH
075ffe1f
MD
76 fi
77
78 rm -rf $TRACE_PATH
79}
3de31d0b 80
075ffe1f
MD
81function test_event_wildcard_fail()
82{
83 TRACE_PATH=$(mktemp -d)
4a180d9f
MD
84 DOMAIN="$1"
85 WILDCARD="$2"
3de31d0b 86
075ffe1f 87 create_lttng_session_ok $SESSION_NAME $TRACE_PATH
4a180d9f 88 enable_${DOMAIN}_lttng_event_fail $SESSION_NAME "$WILDCARD"
67b4c664 89 destroy_lttng_session_ok $SESSION_NAME
3de31d0b
CB
90
91 rm -rf $TRACE_PATH
92}
93
94# MUST set TESTDIR before calling those functions
95plan_tests $NUM_TESTS
96
e3bef725
CB
97print_test_banner "$TEST_DESC"
98
3de31d0b
CB
99start_lttng_sessiond
100
4a180d9f
MD
101diag "Test UST wildcard"
102
103if [ ! -x "$TESTAPP_BIN" ]; then
104 BAIL_OUT "No UST nevents binary detected."
105fi
106
107EVENT_NAME="tp:tptest"
108
862832e9
PP
109# non-matching
110test_event_wildcard ust 0 'tp:abc*'
111test_event_wildcard ust 0 '*abc'
112test_event_wildcard ust 0 '*z*'
113test_event_wildcard ust 0 '*\**'
114test_event_wildcard ust 0 '*\*'
115test_event_wildcard ust 0 '\**'
116test_event_wildcard ust 0 '*:*tpte*s'
117test_event_wildcard ust 0 'tp**tpTest'
118
119# matching
4a180d9f
MD
120test_event_wildcard ust 1 'tp:tp*'
121test_event_wildcard ust 1 '*'
122test_event_wildcard ust 1 'tp:tptest*'
862832e9
PP
123test_event_wildcard ust 1 '**'
124test_event_wildcard ust 1 '***'
125test_event_wildcard ust 1 '*tptest'
126test_event_wildcard ust 1 '**tptest'
127test_event_wildcard ust 1 '*tpte*'
128test_event_wildcard ust 1 '*tp*'
129test_event_wildcard ust 1 '*tp**'
130test_event_wildcard ust 1 '*:*tptest'
131test_event_wildcard ust 1 '*:*tpte*t'
132test_event_wildcard ust 1 't*p*:*t*e*s*t'
133test_event_wildcard ust 1 '*t*p*:*t*e*s*t*'
134test_event_wildcard ust 1 'tp*tptest'
135test_event_wildcard ust 1 'tp**tptest'
136test_event_wildcard ust 1 'tp*test'
4a180d9f
MD
137
138if [ "$(id -u)" == "0" ]; then
139 isroot=1
140else
141 isroot=0
142fi
075ffe1f 143
4a180d9f
MD
144skip $isroot "Root access is needed. Skipping all kernel wildcard tests." $NUM_KERNEL_TESTS ||
145{
146 diag "Test kernel wildcards"
147
148 modprobe lttng-test
149
150 EVENT_NAME="lttng_test_filter_event"
151
862832e9
PP
152 # non-matching
153 test_event_wildcard kernel 0 'lttng_test_abc*'
154 test_event_wildcard kernel 0 '*abc'
155 test_event_wildcard kernel 0 '*z*'
156 test_event_wildcard kernel 0 '*\**'
157 test_event_wildcard kernel 0 '*\*'
158 test_event_wildcard kernel 0 '\**'
159 test_event_wildcard kernel 0 '*:*eve*n'
160
161 # matching
162 test_event_wildcard kernel 1 'lttng_test_fil*'
163 test_event_wildcard kernel 1 '*'
4a180d9f 164 test_event_wildcard kernel 1 'lttng_test_filter_event*'
862832e9
PP
165 test_event_wildcard kernel 1 '**'
166 test_event_wildcard kernel 1 '***'
167 test_event_wildcard kernel 1 '*filter_event'
168 test_event_wildcard kernel 1 '*ter_ev*'
169 test_event_wildcard kernel 1 '*test*'
170 test_event_wildcard kernel 1 '*test**'
171 test_event_wildcard kernel 1 '*e*'
172 test_event_wildcard kernel 1 '*_*event'
173 test_event_wildcard kernel 1 '*_*filter_*nt'
174 test_event_wildcard kernel 1 '*_**filter_*nt'
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 '*l*t*t*n*g*_*t*e*s*t*_*f*i*l*t*e*r*_*e*v*e*n*t*'
177 test_event_wildcard kernel 1 'lttng*event'
178 test_event_wildcard kernel 1 'lttng*test*filter*event'
179 test_event_wildcard kernel 1 '*lttng*test*filter*event*'
4a180d9f
MD
180
181 rmmod lttng-test
182}
3de31d0b
CB
183
184stop_lttng_sessiond
This page took 0.039538 seconds and 4 git commands to generate.