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