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