3 # Copyright (C) - 2012 David Goulet <dgoulet@efficios.com>
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.
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
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
17 TEST_DESC
="UST tracer - Tracing with per UID buffers"
20 TESTDIR
=$CURDIR/..
/..
/..
22 SESSION_NAME
="buffers-uid"
23 EVENT_NAME
="ust_gen_nevents:tptest"
24 BIN_NAME
="gen-nevents"
27 source $TESTDIR/utils
/utils.sh
29 print_test_banner
"$TEST_DESC"
31 if [ ! -x "$CURDIR/gen-nevents" ]; then
32 BAIL_OUT
"No UST nevents binary detected."
35 # MUST set TESTDIR before calling those functions
37 function enable_channel_per_uid
()
42 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN enable-channel
--buffers-uid -u $channel_name -s $sess_name >/dev
/null
2>&1
43 ok $?
"Enable channel $channel_name per UID for session $sess_name"
48 diag
"Waiting for applications to end..."
49 while [ -n "$(pidof $BIN_NAME)" ]; do
54 test_after_multiple_apps
() {
58 diag
"Start multiple applications AFTER tracing is started"
60 # BEFORE application is spawned
61 create_lttng_session
$SESSION_NAME $TRACE_PATH
62 enable_channel_per_uid
$SESSION_NAME "channel0"
63 enable_ust_lttng_event
$SESSION_NAME $EVENT_NAME
64 start_lttng_tracing
$SESSION_NAME
66 for i
in `seq 1 5`; do
67 .
/$CURDIR/$BIN_NAME $NR_ITER & >/dev
/null
2>&1
68 ok $?
"Start application $i for tracing"
72 stop_lttng_tracing
$SESSION_NAME
73 destroy_lttng_session
$SESSION_NAME
75 trace_matches
$EVENT_NAME $
[NR_ITER
* 5] $TRACE_PATH
80 test_before_multiple_apps
() {
84 diag
"Start multiple applications BEFORE tracing is started"
86 for i
in `seq 1 5`; do
87 .
/$CURDIR/$BIN_NAME $NR_ITER & >/dev
/null
2>&1
88 ok $?
"Start application $i for tracing"
91 # BEFORE application is spawned
92 create_lttng_session
$SESSION_NAME $TRACE_PATH
93 enable_channel_per_uid
$SESSION_NAME "channel0"
94 enable_ust_lttng_event
$SESSION_NAME $EVENT_NAME
95 start_lttng_tracing
$SESSION_NAME
97 # At least hit one event
100 stop_lttng_tracing
$SESSION_NAME
101 destroy_lttng_session
$SESSION_NAME
103 out
=$
(babeltrace
$TRACE_PATH |
grep $EVENT_NAME |
wc -l)
104 if [ $out -eq 0 ]; then
105 fail
"Trace validation"
106 diag
"No event(s) found. We are supposed to have at least one."
109 pass
"Trace validation"
110 diag
"Found $out event(s). Coherent."
122 diag
"Start application AFTER tracing is started"
124 # BEFORE application is spawned
125 create_lttng_session
$SESSION_NAME $TRACE_PATH
126 enable_channel_per_uid
$SESSION_NAME "channel0"
127 enable_ust_lttng_event
$SESSION_NAME $EVENT_NAME
128 start_lttng_tracing
$SESSION_NAME
130 .
/$CURDIR/$BIN_NAME $NR_ITER
131 ok $?
"Start application to trace"
133 stop_lttng_tracing
$SESSION_NAME
134 destroy_lttng_session
$SESSION_NAME
136 trace_matches
$EVENT_NAME $NR_ITER $TRACE_PATH
144 diag
"Start application BEFORE tracing is started"
146 .
/$CURDIR/$BIN_NAME $NR_ITER &
147 ok $?
"Start application to trace"
149 # BEFORE application is spawned
150 create_lttng_session
$SESSION_NAME $TRACE_PATH
151 enable_channel_per_uid
$SESSION_NAME "channel0"
152 enable_ust_lttng_event
$SESSION_NAME $EVENT_NAME
153 start_lttng_tracing
$SESSION_NAME
155 # At least hit one event
158 stop_lttng_tracing
$SESSION_NAME
159 destroy_lttng_session
$SESSION_NAME
161 out
=$
(babeltrace
$TRACE_PATH |
grep $EVENT_NAME |
wc -l)
162 if [ $out -eq 0 ]; then
163 fail
"Trace validation"
164 diag
"No event(s) found. We are supposed to have at least one."
167 pass
"Trace validation"
168 diag
"Found $out event(s). Coherent."
177 test_multiple_channels
() {
180 diag
"Start with multiple channels"
182 # BEFORE application is spawned
183 create_lttng_session
$SESSION_NAME $TRACE_PATH
184 enable_channel_per_uid
$SESSION_NAME "channel0"
185 enable_channel_per_uid
$SESSION_NAME "channel1"
186 enable_channel_per_uid
$SESSION_NAME "channel2"
187 enable_channel_per_uid
$SESSION_NAME "channel3"
188 enable_channel_per_uid
$SESSION_NAME "channel4"
189 # Enable event in all channels.
190 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN enable-event
$EVENT_NAME -c channel0
-s $SESSION_NAME -u >/dev
/null
2>&1
191 ok $?
"Enable event $EVENT_NAME for session $SESSION_NAME in channel0"
192 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN enable-event
$EVENT_NAME -c channel1
-s $SESSION_NAME -u >/dev
/null
2>&1
193 ok $?
"Enable event $EVENT_NAME for session $SESSION_NAME in channel1"
194 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN enable-event
$EVENT_NAME -c channel2
-s $SESSION_NAME -u >/dev
/null
2>&1
195 ok $?
"Enable event $EVENT_NAME for session $SESSION_NAME in channel2"
196 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN enable-event
$EVENT_NAME -c channel3
-s $SESSION_NAME -u >/dev
/null
2>&1
197 ok $?
"Enable event $EVENT_NAME for session $SESSION_NAME in channel3"
198 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN enable-event
$EVENT_NAME -c channel4
-s $SESSION_NAME -u >/dev
/null
2>&1
199 ok $?
"Enable event $EVENT_NAME for session $SESSION_NAME in channel4"
200 start_lttng_tracing
$SESSION_NAME
202 .
/$CURDIR/$BIN_NAME $NR_ITER
203 ok $?
"Start application to trace"
205 stop_lttng_tracing
$SESSION_NAME
206 trace_matches
$EVENT_NAME $
[NR_ITER
* 5] $TRACE_PATH
209 destroy_lttng_session
$SESSION_NAME
214 # MUST set TESTDIR before calling those functions
215 plan_tests
$NUM_TESTS
220 "test_after_multiple_apps"
221 "test_before_multiple_apps"
222 "test_multiple_channels"
225 TEST_COUNT
=${#TESTS[@]}
230 while [ $i -lt $TEST_COUNT ]; do
231 TRACE_PATH
=$
(mktemp
-d)
233 if [ $?
-ne 0 ]; then