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/..
/..
/..
23 SESSION_NAME
="buffers-uid"
25 TESTAPP_PATH
="$TESTDIR/utils/testapp"
26 TESTAPP_NAME
="gen-ust-events"
27 TESTAPP_BIN
="$TESTAPP_PATH/$TESTAPP_NAME/$TESTAPP_NAME"
28 EVENT_NAME
="tp:tptest"
31 source $TESTDIR/utils
/utils.sh
33 if [ ! -x "$TESTAPP_BIN" ]; then
34 BAIL_OUT
"No UST events binary detected."
37 # MUST set TESTDIR before calling those functions
39 function enable_channel_per_uid
()
44 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN enable-channel
--buffers-uid -u $channel_name -s $sess_name >/dev
/null
2>&1
45 ok $?
"Enable channel $channel_name per UID for session $sess_name"
50 diag
"Waiting for applications to end..."
51 while [ -n "$(pidof $TESTAPP_NAME)" ]; do
56 test_after_multiple_apps
() {
60 diag
"Start multiple applications AFTER tracing is started"
62 # BEFORE application is spawned
63 create_lttng_session
$SESSION_NAME $TRACE_PATH
64 enable_channel_per_uid
$SESSION_NAME "channel0"
65 enable_ust_lttng_event
$SESSION_NAME $EVENT_NAME
66 start_lttng_tracing
$SESSION_NAME
68 for i
in `seq 1 5`; do
69 $TESTAPP_BIN $NR_ITER $NR_USEC_WAIT & >/dev
/null
2>&1
70 ok $?
"Start application $i for tracing"
74 stop_lttng_tracing
$SESSION_NAME
75 destroy_lttng_session
$SESSION_NAME
77 trace_matches
$EVENT_NAME $
[NR_ITER
* 5] $TRACE_PATH
82 test_before_multiple_apps
() {
86 diag
"Start multiple applications BEFORE tracing is started"
88 for i
in `seq 1 5`; do
89 $TESTAPP_BIN $NR_ITER $NR_USEC_WAIT & >/dev
/null
2>&1
90 ok $?
"Start application $i for tracing"
93 # BEFORE application is spawned
94 create_lttng_session
$SESSION_NAME $TRACE_PATH
95 enable_channel_per_uid
$SESSION_NAME "channel0"
96 enable_ust_lttng_event
$SESSION_NAME $EVENT_NAME
97 start_lttng_tracing
$SESSION_NAME
99 # At least hit one event
102 stop_lttng_tracing
$SESSION_NAME
103 destroy_lttng_session
$SESSION_NAME
105 out
=$
(babeltrace
$TRACE_PATH |
grep $EVENT_NAME |
wc -l)
106 if [ $out -eq 0 ]; then
107 fail
"Trace validation"
108 diag
"No event(s) found. We are supposed to have at least one."
111 pass
"Trace validation"
112 diag
"Found $out event(s). Coherent."
124 diag
"Start application AFTER tracing is started"
126 # BEFORE application is spawned
127 create_lttng_session
$SESSION_NAME $TRACE_PATH
128 enable_channel_per_uid
$SESSION_NAME "channel0"
129 enable_ust_lttng_event
$SESSION_NAME $EVENT_NAME
130 start_lttng_tracing
$SESSION_NAME
132 $TESTAPP_BIN $NR_ITER $NR_USEC_WAIT
133 ok $?
"Start application to trace"
135 stop_lttng_tracing
$SESSION_NAME
136 destroy_lttng_session
$SESSION_NAME
138 trace_matches
$EVENT_NAME $NR_ITER $TRACE_PATH
146 diag
"Start application BEFORE tracing is started"
148 $TESTAPP_BIN $NR_ITER $NR_USEC_WAIT &
149 ok $?
"Start application to trace"
151 # BEFORE application is spawned
152 create_lttng_session
$SESSION_NAME $TRACE_PATH
153 enable_channel_per_uid
$SESSION_NAME "channel0"
154 enable_ust_lttng_event
$SESSION_NAME $EVENT_NAME
155 start_lttng_tracing
$SESSION_NAME
157 # At least hit one event
160 stop_lttng_tracing
$SESSION_NAME
161 destroy_lttng_session
$SESSION_NAME
163 out
=$
(babeltrace
$TRACE_PATH |
grep $EVENT_NAME |
wc -l)
164 if [ $out -eq 0 ]; then
165 fail
"Trace validation"
166 diag
"No event(s) found. We are supposed to have at least one."
169 pass
"Trace validation"
170 diag
"Found $out event(s). Coherent."
179 test_multiple_channels
() {
182 diag
"Start with multiple channels"
184 # BEFORE application is spawned
185 create_lttng_session
$SESSION_NAME $TRACE_PATH
186 enable_channel_per_uid
$SESSION_NAME "channel0"
187 enable_channel_per_uid
$SESSION_NAME "channel1"
188 enable_channel_per_uid
$SESSION_NAME "channel2"
189 enable_channel_per_uid
$SESSION_NAME "channel3"
190 enable_channel_per_uid
$SESSION_NAME "channel4"
191 # Enable event in all channels.
192 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN enable-event
$EVENT_NAME -c channel0
-s $SESSION_NAME -u >/dev
/null
2>&1
193 ok $?
"Enable event $EVENT_NAME for session $SESSION_NAME in channel0"
194 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN enable-event
$EVENT_NAME -c channel1
-s $SESSION_NAME -u >/dev
/null
2>&1
195 ok $?
"Enable event $EVENT_NAME for session $SESSION_NAME in channel1"
196 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN enable-event
$EVENT_NAME -c channel2
-s $SESSION_NAME -u >/dev
/null
2>&1
197 ok $?
"Enable event $EVENT_NAME for session $SESSION_NAME in channel2"
198 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN enable-event
$EVENT_NAME -c channel3
-s $SESSION_NAME -u >/dev
/null
2>&1
199 ok $?
"Enable event $EVENT_NAME for session $SESSION_NAME in channel3"
200 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN enable-event
$EVENT_NAME -c channel4
-s $SESSION_NAME -u >/dev
/null
2>&1
201 ok $?
"Enable event $EVENT_NAME for session $SESSION_NAME in channel4"
202 start_lttng_tracing
$SESSION_NAME
204 $TESTAPP_BIN $NR_ITER $NR_USEC_WAIT
205 ok $?
"Start application to trace"
207 stop_lttng_tracing
$SESSION_NAME
208 trace_matches
$EVENT_NAME $
[NR_ITER
* 5] $TRACE_PATH
211 destroy_lttng_session
$SESSION_NAME
216 # MUST set TESTDIR before calling those functions
217 plan_tests
$NUM_TESTS
219 print_test_banner
"$TEST_DESC"
224 "test_after_multiple_apps"
225 "test_before_multiple_apps"
226 "test_multiple_channels"
229 TEST_COUNT
=${#TESTS[@]}
234 while [ $i -lt $TEST_COUNT ]; do
235 TRACE_PATH
=$
(mktemp
-d)