Commit | Line | Data |
---|---|---|
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 | 8 | TEST_DESC="LTTng - Event wildcard test" |
3de31d0b CB |
9 | |
10 | CURDIR=$(dirname $0)/ | |
f34b33a2 | 11 | TESTDIR=$CURDIR/../../.. |
075ffe1f MD |
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" | |
075ffe1f | 16 | NR_ITER=100 |
5bbf6fde | 17 | NR_USEC_WAIT=1 |
4a180d9f | 18 | NUM_GLOBAL_TESTS=2 |
862832e9 PP |
19 | NUM_UST_TESTS=$(( 7 * 25 )) |
20 | NUM_KERNEL_TESTS=$(( 7 * 25 )) | |
4a180d9f | 21 | NUM_TESTS=$(($NUM_UST_TESTS+$NUM_KERNEL_TESTS+$NUM_GLOBAL_TESTS)) |
3de31d0b CB |
22 | |
23 | source $TESTDIR/utils/utils.sh | |
24 | ||
4a180d9f MD |
25 | function run_ust |
26 | { | |
6c4a91d6 | 27 | $TESTAPP_BIN -i $NR_ITER -w $NR_USEC_WAIT |
4a180d9f MD |
28 | } |
29 | ||
30 | function run_kernel | |
31 | { | |
32 | # Trigger the event for 100 iterations | |
33 | echo -n "100" > /proc/lttng-test-filter-event | |
34 | } | |
075ffe1f | 35 | |
3de31d0b CB |
36 | function test_event_wildcard() |
37 | { | |
38 | TRACE_PATH=$(mktemp -d) | |
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 |
70 | function test_event_wildcard_fail() |
71 | { | |
72 | TRACE_PATH=$(mktemp -d) | |
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 | |
84 | plan_tests $NUM_TESTS | |
85 | ||
e3bef725 CB |
86 | print_test_banner "$TEST_DESC" |
87 | ||
3de31d0b CB |
88 | start_lttng_sessiond |
89 | ||
4a180d9f MD |
90 | diag "Test UST wildcard" |
91 | ||
92 | if [ ! -x "$TESTAPP_BIN" ]; then | |
93 | BAIL_OUT "No UST nevents binary detected." | |
94 | fi | |
95 | ||
96 | EVENT_NAME="tp:tptest" | |
97 | ||
862832e9 PP |
98 | # non-matching |
99 | test_event_wildcard ust 0 'tp:abc*' | |
100 | test_event_wildcard ust 0 '*abc' | |
101 | test_event_wildcard ust 0 '*z*' | |
102 | test_event_wildcard ust 0 '*\**' | |
103 | test_event_wildcard ust 0 '*\*' | |
104 | test_event_wildcard ust 0 '\**' | |
105 | test_event_wildcard ust 0 '*:*tpte*s' | |
106 | test_event_wildcard ust 0 'tp**tpTest' | |
107 | ||
108 | # matching | |
4a180d9f MD |
109 | test_event_wildcard ust 1 'tp:tp*' |
110 | test_event_wildcard ust 1 '*' | |
111 | test_event_wildcard ust 1 'tp:tptest*' | |
862832e9 PP |
112 | test_event_wildcard ust 1 '**' |
113 | test_event_wildcard ust 1 '***' | |
114 | test_event_wildcard ust 1 '*tptest' | |
115 | test_event_wildcard ust 1 '**tptest' | |
116 | test_event_wildcard ust 1 '*tpte*' | |
117 | test_event_wildcard ust 1 '*tp*' | |
118 | test_event_wildcard ust 1 '*tp**' | |
119 | test_event_wildcard ust 1 '*:*tptest' | |
120 | test_event_wildcard ust 1 '*:*tpte*t' | |
121 | test_event_wildcard ust 1 't*p*:*t*e*s*t' | |
122 | test_event_wildcard ust 1 '*t*p*:*t*e*s*t*' | |
123 | test_event_wildcard ust 1 'tp*tptest' | |
124 | test_event_wildcard ust 1 'tp**tptest' | |
125 | test_event_wildcard ust 1 'tp*test' | |
4a180d9f MD |
126 | |
127 | if [ "$(id -u)" == "0" ]; then | |
128 | isroot=1 | |
129 | else | |
130 | isroot=0 | |
131 | fi | |
075ffe1f | 132 | |
4a180d9f MD |
133 | skip $isroot "Root access is needed. Skipping all kernel wildcard tests." $NUM_KERNEL_TESTS || |
134 | { | |
135 | diag "Test kernel wildcards" | |
136 | ||
137 | modprobe lttng-test | |
138 | ||
139 | EVENT_NAME="lttng_test_filter_event" | |
140 | ||
862832e9 PP |
141 | # non-matching |
142 | test_event_wildcard kernel 0 'lttng_test_abc*' | |
143 | test_event_wildcard kernel 0 '*abc' | |
144 | test_event_wildcard kernel 0 '*z*' | |
145 | test_event_wildcard kernel 0 '*\**' | |
146 | test_event_wildcard kernel 0 '*\*' | |
147 | test_event_wildcard kernel 0 '\**' | |
148 | test_event_wildcard kernel 0 '*:*eve*n' | |
149 | ||
150 | # matching | |
151 | test_event_wildcard kernel 1 'lttng_test_fil*' | |
152 | test_event_wildcard kernel 1 '*' | |
4a180d9f | 153 | test_event_wildcard kernel 1 'lttng_test_filter_event*' |
862832e9 PP |
154 | test_event_wildcard kernel 1 '**' |
155 | test_event_wildcard kernel 1 '***' | |
156 | test_event_wildcard kernel 1 '*filter_event' | |
157 | test_event_wildcard kernel 1 '*ter_ev*' | |
158 | test_event_wildcard kernel 1 '*test*' | |
159 | test_event_wildcard kernel 1 '*test**' | |
160 | test_event_wildcard kernel 1 '*e*' | |
161 | test_event_wildcard kernel 1 '*_*event' | |
162 | test_event_wildcard kernel 1 '*_*filter_*nt' | |
163 | test_event_wildcard kernel 1 '*_**filter_*nt' | |
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 '*l*t*t*n*g*_*t*e*s*t*_*f*i*l*t*e*r*_*e*v*e*n*t*' | |
166 | test_event_wildcard kernel 1 'lttng*event' | |
167 | test_event_wildcard kernel 1 'lttng*test*filter*event' | |
168 | test_event_wildcard kernel 1 '*lttng*test*filter*event*' | |
4a180d9f MD |
169 | |
170 | rmmod lttng-test | |
171 | } | |
3de31d0b CB |
172 | |
173 | stop_lttng_sessiond |