Tests: remove declaration already present in utils.sh
[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/../../..
075ffe1f
MD
23TESTAPP_PATH="$TESTDIR/utils/testapp"
24TESTAPP_NAME="gen-ust-events"
25TESTAPP_BIN="$TESTAPP_PATH/$TESTAPP_NAME/$TESTAPP_NAME"
26SESSION_NAME="wildcard"
075ffe1f 27NR_ITER=100
4a180d9f
MD
28NUM_GLOBAL_TESTS=2
29NUM_UST_TESTS=37
0f6fd363 30NUM_KERNEL_TESTS=30
4a180d9f 31NUM_TESTS=$(($NUM_UST_TESTS+$NUM_KERNEL_TESTS+$NUM_GLOBAL_TESTS))
3de31d0b
CB
32
33source $TESTDIR/utils/utils.sh
34
4a180d9f
MD
35function run_ust
36{
37 $TESTAPP_BIN $NR_ITER $NR_USEC_WAIT
38}
39
40function run_kernel
41{
42 # Trigger the event for 100 iterations
43 echo -n "100" > /proc/lttng-test-filter-event
44}
075ffe1f 45
3de31d0b
CB
46function test_event_wildcard()
47{
48 TRACE_PATH=$(mktemp -d)
4a180d9f
MD
49 DOMAIN="$1"
50 FIND="$2"
51 WILDCARD="$3"
3de31d0b 52
bf6ae429 53 create_lttng_session_ok $SESSION_NAME $TRACE_PATH
4a180d9f 54 enable_${DOMAIN}_lttng_event_ok $SESSION_NAME "$WILDCARD"
3de31d0b 55
e563bbdb 56 start_lttng_tracing_ok
075ffe1f 57
4a180d9f 58 run_${DOMAIN}
075ffe1f
MD
59 ok $? "Traced application stopped."
60
96340a01 61 stop_lttng_tracing_ok
075ffe1f
MD
62 destroy_lttng_session_ok $SESSION_NAME
63
64 if [ ${FIND} -eq 1 ]; then
65 trace_matches $EVENT_NAME $NR_ITER $TRACE_PATH
66 else
67 validate_trace_empty $TRACE_PATH
68 fi
69
70 rm -rf $TRACE_PATH
71}
3de31d0b 72
075ffe1f
MD
73function test_event_wildcard_fail()
74{
75 TRACE_PATH=$(mktemp -d)
4a180d9f
MD
76 DOMAIN="$1"
77 WILDCARD="$2"
3de31d0b 78
075ffe1f 79 create_lttng_session_ok $SESSION_NAME $TRACE_PATH
4a180d9f 80 enable_${DOMAIN}_lttng_event_fail $SESSION_NAME "$WILDCARD"
67b4c664 81 destroy_lttng_session_ok $SESSION_NAME
3de31d0b
CB
82
83 rm -rf $TRACE_PATH
84}
85
86# MUST set TESTDIR before calling those functions
87plan_tests $NUM_TESTS
88
e3bef725
CB
89print_test_banner "$TEST_DESC"
90
3de31d0b
CB
91start_lttng_sessiond
92
4a180d9f
MD
93diag "Test UST wildcard"
94
95if [ ! -x "$TESTAPP_BIN" ]; then
96 BAIL_OUT "No UST nevents binary detected."
97fi
98
99EVENT_NAME="tp:tptest"
100
101test_event_wildcard ust 1 'tp:tp*'
102test_event_wildcard ust 1 '*'
103test_event_wildcard ust 1 'tp:tptest*'
104test_event_wildcard ust 0 'tp:abc*'
105
106test_event_wildcard_fail ust 'tp:*tp'
107test_event_wildcard_fail ust 'tp:tp**'
108test_event_wildcard_fail ust '*tp:tp*'
109
110
111if [ "$(id -u)" == "0" ]; then
112 isroot=1
113else
114 isroot=0
115fi
075ffe1f 116
4a180d9f
MD
117skip $isroot "Root access is needed. Skipping all kernel wildcard tests." $NUM_KERNEL_TESTS ||
118{
119 diag "Test kernel wildcards"
120
121 modprobe lttng-test
122
123 EVENT_NAME="lttng_test_filter_event"
124
125 test_event_wildcard kernel 1 'lttng_test_*'
4a180d9f
MD
126 test_event_wildcard kernel 1 'lttng_test_filter_event*'
127 test_event_wildcard kernel 0 'lttng_test_asdfasdf*'
128
129 test_event_wildcard_fail kernel 'tp_*tp'
130 test_event_wildcard_fail kernel 'tp_tp**'
131 test_event_wildcard_fail kernel '*tp_tp*'
132
133 rmmod lttng-test
134}
3de31d0b
CB
135
136stop_lttng_sessiond
This page took 0.039129 seconds and 4 git commands to generate.