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 if [ ! -x "$CURDIR/gen-nevents" ]; then
30 BAIL_OUT
"No UST nevents binary detected."
33 # MUST set TESTDIR before calling those functions
35 function enable_channel_per_uid
()
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"
46 diag
"Waiting for applications to end..."
47 while [ -n "$(pidof $BIN_NAME)" ]; do
52 test_after_multiple_apps
() {
56 diag
"Start multiple applications AFTER tracing is started"
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
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"
70 stop_lttng_tracing
$SESSION_NAME
71 destroy_lttng_session
$SESSION_NAME
73 trace_matches
$EVENT_NAME $
[NR_ITER
* 5] $TRACE_PATH
78 test_before_multiple_apps
() {
82 diag
"Start multiple applications BEFORE tracing is started"
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"
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
95 # At least hit one event
98 stop_lttng_tracing
$SESSION_NAME
99 destroy_lttng_session
$SESSION_NAME
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."
107 pass
"Trace validation"
108 diag
"Found $out event(s). Coherent."
120 diag
"Start application AFTER tracing is started"
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
128 .
/$CURDIR/$BIN_NAME $NR_ITER
129 ok $?
"Start application to trace"
131 stop_lttng_tracing
$SESSION_NAME
132 destroy_lttng_session
$SESSION_NAME
134 trace_matches
$EVENT_NAME $NR_ITER $TRACE_PATH
142 diag
"Start application BEFORE tracing is started"
144 .
/$CURDIR/$BIN_NAME $NR_ITER &
145 ok $?
"Start application to trace"
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
153 # At least hit one event
156 stop_lttng_tracing
$SESSION_NAME
157 destroy_lttng_session
$SESSION_NAME
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."
165 pass
"Trace validation"
166 diag
"Found $out event(s). Coherent."
175 test_multiple_channels
() {
178 diag
"Start with multiple channels"
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
200 .
/$CURDIR/$BIN_NAME $NR_ITER
201 ok $?
"Start application to trace"
203 stop_lttng_tracing
$SESSION_NAME
204 trace_matches
$EVENT_NAME $
[NR_ITER
* 5] $TRACE_PATH
207 destroy_lttng_session
$SESSION_NAME
212 # MUST set TESTDIR before calling those functions
213 plan_tests
$NUM_TESTS
215 print_test_banner
"$TEST_DESC"
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)