Tests: Do not exit when a failure occurs in test_buffers_uid
[lttng-tools.git] / tests / regression / ust / buffers-uid / test_buffers_uid
CommitLineData
7972aab2
DG
1#!/bin/bash
2#
3# Copyright (C) - 2012 David Goulet <dgoulet@efficios.com>
4#
5# This library is free software; you can redistribute it and/or modify it under
6# the terms of the GNU Lesser General Public License as published by the Free
7# Software Foundation; version 2.1 of the License.
8#
9# This library is distributed in the hope that it will be useful, but WITHOUT
10# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
11# FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
12# details.
13#
14# You should have received a copy of the GNU Lesser General Public License
15# along with this library; if not, write to the Free Software Foundation, Inc.,
16# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
17TEST_DESC="UST tracer - Tracing with per UID buffers"
18
19CURDIR=$(dirname $0)/
20TESTDIR=$CURDIR/../../..
21NR_ITER=100
22SESSION_NAME="buffers-uid"
23EVENT_NAME="ust_gen_nevents:tptest"
24BIN_NAME="gen-nevents"
25NUM_TESTS=58
26
27source $TESTDIR/utils/utils.sh
28
7972aab2
DG
29if [ ! -x "$CURDIR/gen-nevents" ]; then
30 BAIL_OUT "No UST nevents binary detected."
31fi
32
33# MUST set TESTDIR before calling those functions
34
35function enable_channel_per_uid()
36{
37 sess_name=$1
38 channel_name=$2
39
40 $TESTDIR/../src/bin/lttng/$LTTNG_BIN enable-channel --buffers-uid -u $channel_name -s $sess_name >/dev/null 2>&1
41 ok $? "Enable channel $channel_name per UID for session $sess_name"
42}
43
44function wait_apps
45{
46 diag "Waiting for applications to end..."
47 while [ -n "$(pidof $BIN_NAME)" ]; do
48 sleep 1
49 done
50}
51
52test_after_multiple_apps() {
53 local out
54 local i
55
56 diag "Start multiple applications AFTER tracing is started"
57
58 # BEFORE application is spawned
59 create_lttng_session $SESSION_NAME $TRACE_PATH
60 enable_channel_per_uid $SESSION_NAME "channel0"
61 enable_ust_lttng_event $SESSION_NAME $EVENT_NAME
62 start_lttng_tracing $SESSION_NAME
63
64 for i in `seq 1 5`; do
65 ./$CURDIR/$BIN_NAME $NR_ITER & >/dev/null 2>&1
66 ok $? "Start application $i for tracing"
67 done
68 wait_apps
69
70 stop_lttng_tracing $SESSION_NAME
71 destroy_lttng_session $SESSION_NAME
72
73 trace_matches $EVENT_NAME $[NR_ITER * 5] $TRACE_PATH
74
75 return $?
76}
77
78test_before_multiple_apps() {
79 local out
80 local i
81
82 diag "Start multiple applications BEFORE tracing is started"
83
84 for i in `seq 1 5`; do
85 ./$CURDIR/$BIN_NAME $NR_ITER & >/dev/null 2>&1
86 ok $? "Start application $i for tracing"
87 done
88
89 # BEFORE application is spawned
90 create_lttng_session $SESSION_NAME $TRACE_PATH
91 enable_channel_per_uid $SESSION_NAME "channel0"
92 enable_ust_lttng_event $SESSION_NAME $EVENT_NAME
93 start_lttng_tracing $SESSION_NAME
94
95 # At least hit one event
96 sleep 2
97
98 stop_lttng_tracing $SESSION_NAME
99 destroy_lttng_session $SESSION_NAME
100
101 out=$(babeltrace $TRACE_PATH | grep $EVENT_NAME | wc -l)
102 if [ $out -eq 0 ]; then
103 fail "Trace validation"
104 diag "No event(s) found. We are supposed to have at least one."
105 out=1
106 else
107 pass "Trace validation"
108 diag "Found $out event(s). Coherent."
109 out=0
110 fi
111
112 wait_apps
113
114 return $out
115}
116
117test_after_app() {
118 local out
119
120 diag "Start application AFTER tracing is started"
121
122 # BEFORE application is spawned
123 create_lttng_session $SESSION_NAME $TRACE_PATH
124 enable_channel_per_uid $SESSION_NAME "channel0"
125 enable_ust_lttng_event $SESSION_NAME $EVENT_NAME
126 start_lttng_tracing $SESSION_NAME
127
128 ./$CURDIR/$BIN_NAME $NR_ITER
129 ok $? "Start application to trace"
130
131 stop_lttng_tracing $SESSION_NAME
132 destroy_lttng_session $SESSION_NAME
133
134 trace_matches $EVENT_NAME $NR_ITER $TRACE_PATH
135
136 return $?
137}
138
139test_before_app() {
140 local out
141
142 diag "Start application BEFORE tracing is started"
143
144 ./$CURDIR/$BIN_NAME $NR_ITER &
145 ok $? "Start application to trace"
146
147 # BEFORE application is spawned
148 create_lttng_session $SESSION_NAME $TRACE_PATH
149 enable_channel_per_uid $SESSION_NAME "channel0"
150 enable_ust_lttng_event $SESSION_NAME $EVENT_NAME
151 start_lttng_tracing $SESSION_NAME
152
153 # At least hit one event
154 sleep 2
155
156 stop_lttng_tracing $SESSION_NAME
157 destroy_lttng_session $SESSION_NAME
158
159 out=$(babeltrace $TRACE_PATH | grep $EVENT_NAME | wc -l)
160 if [ $out -eq 0 ]; then
161 fail "Trace validation"
162 diag "No event(s) found. We are supposed to have at least one."
163 out=1
164 else
165 pass "Trace validation"
166 diag "Found $out event(s). Coherent."
167 out=0
168 fi
169
170 wait_apps
171
172 return $out
173}
174
175test_multiple_channels() {
176 local out
177
178 diag "Start with multiple channels"
179
180 # BEFORE application is spawned
181 create_lttng_session $SESSION_NAME $TRACE_PATH
182 enable_channel_per_uid $SESSION_NAME "channel0"
183 enable_channel_per_uid $SESSION_NAME "channel1"
184 enable_channel_per_uid $SESSION_NAME "channel2"
185 enable_channel_per_uid $SESSION_NAME "channel3"
186 enable_channel_per_uid $SESSION_NAME "channel4"
187 # Enable event in all channels.
188 $TESTDIR/../src/bin/lttng/$LTTNG_BIN enable-event $EVENT_NAME -c channel0 -s $SESSION_NAME -u >/dev/null 2>&1
189 ok $? "Enable event $EVENT_NAME for session $SESSION_NAME in channel0"
190 $TESTDIR/../src/bin/lttng/$LTTNG_BIN enable-event $EVENT_NAME -c channel1 -s $SESSION_NAME -u >/dev/null 2>&1
191 ok $? "Enable event $EVENT_NAME for session $SESSION_NAME in channel1"
192 $TESTDIR/../src/bin/lttng/$LTTNG_BIN enable-event $EVENT_NAME -c channel2 -s $SESSION_NAME -u >/dev/null 2>&1
193 ok $? "Enable event $EVENT_NAME for session $SESSION_NAME in channel2"
194 $TESTDIR/../src/bin/lttng/$LTTNG_BIN enable-event $EVENT_NAME -c channel3 -s $SESSION_NAME -u >/dev/null 2>&1
195 ok $? "Enable event $EVENT_NAME for session $SESSION_NAME in channel3"
196 $TESTDIR/../src/bin/lttng/$LTTNG_BIN enable-event $EVENT_NAME -c channel4 -s $SESSION_NAME -u >/dev/null 2>&1
197 ok $? "Enable event $EVENT_NAME for session $SESSION_NAME in channel4"
198 start_lttng_tracing $SESSION_NAME
199
200 ./$CURDIR/$BIN_NAME $NR_ITER
201 ok $? "Start application to trace"
202
203 stop_lttng_tracing $SESSION_NAME
2edab283 204 trace_matches $EVENT_NAME $[NR_ITER * 5] $TRACE_PATH
7972aab2
DG
205 out=$?
206
207 destroy_lttng_session $SESSION_NAME
208
209 return $out
210}
211
212# MUST set TESTDIR before calling those functions
213plan_tests $NUM_TESTS
214
e3bef725
CB
215print_test_banner "$TEST_DESC"
216
7972aab2
DG
217TESTS=(
218 "test_before_app"
219 "test_after_app"
220 "test_after_multiple_apps"
221 "test_before_multiple_apps"
222 "test_multiple_channels"
223)
224
225TEST_COUNT=${#TESTS[@]}
226i=0
227
228start_lttng_sessiond
229
230while [ $i -lt $TEST_COUNT ]; do
231 TRACE_PATH=$(mktemp -d)
232 ${TESTS[$i]}
7972aab2
DG
233 rm -rf $TRACE_PATH
234 let "i++"
235done
236
237stop_lttng_sessiond
This page took 0.030899 seconds and 4 git commands to generate.