File: test_event_wildcard

package info (click to toggle)
ltt-control 2.14.0-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 21,860 kB
  • sloc: cpp: 192,012; sh: 28,777; ansic: 10,960; python: 7,108; makefile: 3,520; java: 109; xml: 46
file content (169 lines) | stat: -rwxr-xr-x 4,473 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
#!/bin/bash
#
# SPDX-FileCopyrightText: 2013 Christian Babeux <christian.babeux@efficios.com>
# SPDX-FileCopyrightText: 2015 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
#
# SPDX-License-Identifier: GPL-2.0-only

TEST_DESC="LTTng - Event wildcard test"

CURDIR=$(dirname $0)/
TESTDIR=$CURDIR/../../..
TESTAPP_PATH="$TESTDIR/utils/testapp"
TESTAPP_NAME="gen-ust-events"
TESTAPP_BIN="$TESTAPP_PATH/$TESTAPP_NAME/$TESTAPP_NAME"
SESSION_NAME="wildcard"
NR_ITER=100
NR_USEC_WAIT=1
NUM_GLOBAL_TESTS=2
NUM_UST_TESTS=$(( 7 * 25 ))
NUM_KERNEL_TESTS=$(( 7 * 25 ))
NUM_TESTS=$(($NUM_UST_TESTS+$NUM_KERNEL_TESTS+$NUM_GLOBAL_TESTS))

source $TESTDIR/utils/utils.sh

function run_ust
{
	$TESTAPP_BIN -i $NR_ITER -w $NR_USEC_WAIT
}

function run_kernel
{
	# Trigger the event for 100 iterations
	echo -n "100" > /proc/lttng-test-filter-event
}

function test_event_wildcard()
{
	TRACE_PATH=$(mktemp -d -t "tmp.${FUNCNAME[0]}_trace_path.XXXXXX")
	DOMAIN="$1"
	FIND="$2"
	WILDCARD="$3"
	CHANNEL=''

	create_lttng_session_ok $SESSION_NAME $TRACE_PATH

	if [ $DOMAIN = kernel ]; then
		CHANNEL=chan
		$TESTDIR/../src/bin/lttng/$LTTNG_BIN enable-channel -k chan -s $SESSION_NAME --subbuf-size=8M --num-subbuf=4
	fi

	enable_${DOMAIN}_lttng_event_ok $SESSION_NAME "$WILDCARD" "$CHANNEL"

	start_lttng_tracing_ok

	run_${DOMAIN}
	ok $? "Traced application stopped."

	stop_lttng_tracing_ok
	destroy_lttng_session_ok $SESSION_NAME

	if [ ${FIND} -eq 1 ]; then
		trace_matches $EVENT_NAME $NR_ITER $TRACE_PATH
	else
		trace_matches $EVENT_NAME 0 $TRACE_PATH
	fi

	rm -rf $TRACE_PATH
}

function test_event_wildcard_fail()
{
	TRACE_PATH=$(mktemp -d -t "tmp.${FUNCNAME[0]}_trace_path.XXXXXX")
	DOMAIN="$1"
	WILDCARD="$2"

	create_lttng_session_ok $SESSION_NAME $TRACE_PATH
	enable_${DOMAIN}_lttng_event_fail $SESSION_NAME "$WILDCARD"
	destroy_lttng_session_ok $SESSION_NAME

	rm -rf $TRACE_PATH
}

# MUST set TESTDIR before calling those functions
plan_tests $NUM_TESTS

print_test_banner "$TEST_DESC"

bail_out_if_no_babeltrace

start_lttng_sessiond

diag "Test UST wildcard"

if [ ! -x "$TESTAPP_BIN" ]; then
	BAIL_OUT "No UST nevents binary detected."
fi

EVENT_NAME="tp:tptest"

# non-matching
test_event_wildcard ust 0 'tp:abc*'
test_event_wildcard ust 0 '*abc'
test_event_wildcard ust 0 '*z*'
test_event_wildcard ust 0 '*\**'
test_event_wildcard ust 0 '*\*'
test_event_wildcard ust 0 '\**'
test_event_wildcard ust 0 '*:*tpte*s'
test_event_wildcard ust 0 'tp**tpTest'

# matching
test_event_wildcard ust 1 'tp:tp*'
test_event_wildcard ust 1 '*'
test_event_wildcard ust 1 'tp:tptest*'
test_event_wildcard ust 1 '**'
test_event_wildcard ust 1 '***'
test_event_wildcard ust 1 '*tptest'
test_event_wildcard ust 1 '**tptest'
test_event_wildcard ust 1 '*tpte*'
test_event_wildcard ust 1 '*tp*'
test_event_wildcard ust 1 '*tp**'
test_event_wildcard ust 1 '*:*tptest'
test_event_wildcard ust 1 '*:*tpte*t'
test_event_wildcard ust 1 't*p*:*t*e*s*t'
test_event_wildcard ust 1 '*t*p*:*t*e*s*t*'
test_event_wildcard ust 1 'tp*tptest'
test_event_wildcard ust 1 'tp**tptest'
test_event_wildcard ust 1 'tp*test'

check_skip_kernel_test "$NUM_KERNEL_TESTS" "Skipping kernel wildcard tests." ||
{
	diag "Test kernel wildcards"

	modprobe lttng-test

	EVENT_NAME="lttng_test_filter_event"

	# non-matching
	test_event_wildcard kernel 0 'lttng_test_abc*'
	test_event_wildcard kernel 0 '*abc'
	test_event_wildcard kernel 0 '*z*'
	test_event_wildcard kernel 0 '*\**'
	test_event_wildcard kernel 0 '*\*'
	test_event_wildcard kernel 0 '\**'
	test_event_wildcard kernel 0 '*:*eve*n'

	# matching
	test_event_wildcard kernel 1 'lttng_test_fil*'
	test_event_wildcard kernel 1 '*'
	test_event_wildcard kernel 1 'lttng_test_filter_event*'
	test_event_wildcard kernel 1 '**'
	test_event_wildcard kernel 1 '***'
	test_event_wildcard kernel 1 '*filter_event'
	test_event_wildcard kernel 1 '*ter_ev*'
	test_event_wildcard kernel 1 '*test*'
	test_event_wildcard kernel 1 '*test**'
	test_event_wildcard kernel 1 '*e*'
	test_event_wildcard kernel 1 '*_*event'
	test_event_wildcard kernel 1 '*_*filter_*nt'
	test_event_wildcard kernel 1 '*_**filter_*nt'
	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'
	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*'
	test_event_wildcard kernel 1 'lttng*event'
	test_event_wildcard kernel 1 'lttng*test*filter*event'
	test_event_wildcard kernel 1 '*lttng*test*filter*event*'

	modprobe --remove lttng-test
}

stop_lttng_sessiond