Tests: add globbing pattern tests to test_exclusion
[lttng-tools.git] / tests / regression / tools / wildcard / test_event_wildcard
CommitLineData
3de31d0b
CB
1#!/bin/bash
2#
3# Copyright (C) - 2013 Christian Babeux <christian.babeux@efficios.com>
075ffe1f 4# Copyright (C) - 2015 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
3de31d0b
CB
5#
6# This program is free software; you can redistribute it and/or modify it
7# under the terms of the GNU General Public License, version 2 only, as
8# published by the Free Software Foundation.
9#
10# This program is distributed in the hope that it will be useful, but WITHOUT
11# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
13# more details.
14#
15# You should have received a copy of the GNU General Public License along with
16# this program; if not, write to the Free Software Foundation, Inc., 51
17# Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
18
4a180d9f 19TEST_DESC="LTTng - Event wildcard test"
3de31d0b
CB
20
21CURDIR=$(dirname $0)/
f34b33a2 22TESTDIR=$CURDIR/../../..
3de31d0b 23LTTNG_BIN="lttng"
075ffe1f
MD
24TESTAPP_PATH="$TESTDIR/utils/testapp"
25TESTAPP_NAME="gen-ust-events"
26TESTAPP_BIN="$TESTAPP_PATH/$TESTAPP_NAME/$TESTAPP_NAME"
27SESSION_NAME="wildcard"
075ffe1f 28NR_ITER=100
4a180d9f
MD
29NUM_GLOBAL_TESTS=2
30NUM_UST_TESTS=37
0f6fd363 31NUM_KERNEL_TESTS=30
4a180d9f 32NUM_TESTS=$(($NUM_UST_TESTS+$NUM_KERNEL_TESTS+$NUM_GLOBAL_TESTS))
3de31d0b
CB
33
34source $TESTDIR/utils/utils.sh
35
4a180d9f
MD
36function run_ust
37{
38 $TESTAPP_BIN $NR_ITER $NR_USEC_WAIT
39}
40
41function run_kernel
42{
43 # Trigger the event for 100 iterations
44 echo -n "100" > /proc/lttng-test-filter-event
45}
075ffe1f 46
3de31d0b
CB
47function test_event_wildcard()
48{
49 TRACE_PATH=$(mktemp -d)
4a180d9f
MD
50 DOMAIN="$1"
51 FIND="$2"
52 WILDCARD="$3"
3de31d0b 53
bf6ae429 54 create_lttng_session_ok $SESSION_NAME $TRACE_PATH
4a180d9f 55 enable_${DOMAIN}_lttng_event_ok $SESSION_NAME "$WILDCARD"
3de31d0b 56
e563bbdb 57 start_lttng_tracing_ok
075ffe1f 58
4a180d9f 59 run_${DOMAIN}
075ffe1f
MD
60 ok $? "Traced application stopped."
61
96340a01 62 stop_lttng_tracing_ok
075ffe1f
MD
63 destroy_lttng_session_ok $SESSION_NAME
64
65 if [ ${FIND} -eq 1 ]; then
66 trace_matches $EVENT_NAME $NR_ITER $TRACE_PATH
67 else
68 validate_trace_empty $TRACE_PATH
69 fi
70
71 rm -rf $TRACE_PATH
72}
3de31d0b 73
075ffe1f
MD
74function test_event_wildcard_fail()
75{
76 TRACE_PATH=$(mktemp -d)
4a180d9f
MD
77 DOMAIN="$1"
78 WILDCARD="$2"
3de31d0b 79
075ffe1f 80 create_lttng_session_ok $SESSION_NAME $TRACE_PATH
4a180d9f 81 enable_${DOMAIN}_lttng_event_fail $SESSION_NAME "$WILDCARD"
67b4c664 82 destroy_lttng_session_ok $SESSION_NAME
3de31d0b
CB
83
84 rm -rf $TRACE_PATH
85}
86
87# MUST set TESTDIR before calling those functions
88plan_tests $NUM_TESTS
89
e3bef725
CB
90print_test_banner "$TEST_DESC"
91
3de31d0b
CB
92start_lttng_sessiond
93
4a180d9f
MD
94diag "Test UST wildcard"
95
96if [ ! -x "$TESTAPP_BIN" ]; then
97 BAIL_OUT "No UST nevents binary detected."
98fi
99
100EVENT_NAME="tp:tptest"
101
102test_event_wildcard ust 1 'tp:tp*'
103test_event_wildcard ust 1 '*'
104test_event_wildcard ust 1 'tp:tptest*'
105test_event_wildcard ust 0 'tp:abc*'
106
107test_event_wildcard_fail ust 'tp:*tp'
108test_event_wildcard_fail ust 'tp:tp**'
109test_event_wildcard_fail ust '*tp:tp*'
110
111
112if [ "$(id -u)" == "0" ]; then
113 isroot=1
114else
115 isroot=0
116fi
075ffe1f 117
4a180d9f
MD
118skip $isroot "Root access is needed. Skipping all kernel wildcard tests." $NUM_KERNEL_TESTS ||
119{
120 diag "Test kernel wildcards"
121
122 modprobe lttng-test
123
124 EVENT_NAME="lttng_test_filter_event"
125
126 test_event_wildcard kernel 1 'lttng_test_*'
4a180d9f
MD
127 test_event_wildcard kernel 1 'lttng_test_filter_event*'
128 test_event_wildcard kernel 0 'lttng_test_asdfasdf*'
129
130 test_event_wildcard_fail kernel 'tp_*tp'
131 test_event_wildcard_fail kernel 'tp_tp**'
132 test_event_wildcard_fail kernel '*tp_tp*'
133
134 rmmod lttng-test
135}
3de31d0b
CB
136
137stop_lttng_sessiond
This page took 0.036847 seconds and 4 git commands to generate.