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