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 PID buffers"
20 TESTDIR
=$CURDIR/..
/..
/..
23 SESSION_NAME
="buffers-pid"
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_pid
()
44 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN enable-channel
--buffers-pid -u $channel_name -s $sess_name >/dev
/null
2>&1
45 ok $?
"Enable channel $channel_name per PID for session $sess_name"
48 test_after_multiple_apps
() {
52 diag
"Start multiple applications AFTER tracing is started"
54 # BEFORE application is spawned
55 create_lttng_session
$SESSION_NAME $TRACE_PATH
56 enable_channel_per_pid
$SESSION_NAME "channel0"
57 enable_ust_lttng_event
$SESSION_NAME $EVENT_NAME "channel0"
58 start_lttng_tracing
$SESSION_NAME
60 for i
in `seq 1 5`; do
61 $TESTAPP_BIN $NR_ITER $NR_USEC_WAIT >/dev
/null
2>&1
62 ok $?
"Start application $i for tracing"
65 stop_lttng_tracing
$SESSION_NAME
66 destroy_lttng_session
$SESSION_NAME
68 trace_match_only
$EVENT_NAME $
[NR_ITER
* 5] $TRACE_PATH
73 test_before_multiple_apps
() {
77 diag
"Start multiple applications BEFORE tracing is started"
79 for i
in `seq 1 5`; do
80 $TESTAPP_BIN $NR_ITER $NR_USEC_WAIT & >/dev
/null
2>&1
81 ok $?
"Start application $i for tracing"
84 # BEFORE application is spawned
85 create_lttng_session
$SESSION_NAME $TRACE_PATH
86 enable_channel_per_pid
$SESSION_NAME "channel0"
87 enable_ust_lttng_event
$SESSION_NAME $EVENT_NAME "channel0"
88 start_lttng_tracing
$SESSION_NAME
90 diag
"Waiting for applications to end"
94 stop_lttng_tracing
$SESSION_NAME
95 destroy_lttng_session
$SESSION_NAME
97 out
=$
(babeltrace
$TRACE_PATH |
grep $EVENT_NAME |
wc -l)
98 if [ $out -eq 0 ]; then
99 fail
"Trace validation"
100 diag
"No event(s) found. We are supposed to have at least one."
103 pass
"Trace validation"
104 diag
"Found $out event(s). Coherent."
114 diag
"Start application AFTER tracing is started"
116 # BEFORE application is spawned
117 create_lttng_session
$SESSION_NAME $TRACE_PATH
118 enable_channel_per_pid
$SESSION_NAME "channel0"
119 enable_ust_lttng_event
$SESSION_NAME $EVENT_NAME "channel0"
120 start_lttng_tracing
$SESSION_NAME
122 $TESTAPP_BIN $NR_ITER $NR_USEC_WAIT
123 ok $?
"Start application to trace"
125 stop_lttng_tracing
$SESSION_NAME
126 destroy_lttng_session
$SESSION_NAME
128 trace_match_only
$EVENT_NAME $NR_ITER $TRACE_PATH
136 diag
"Start application BEFORE tracing is started"
139 # BEFORE application is spawned
140 create_lttng_session
$SESSION_NAME $TRACE_PATH
141 enable_channel_per_pid
$SESSION_NAME "channel0"
142 enable_ust_lttng_event
$SESSION_NAME $EVENT_NAME "channel0"
144 $TESTAPP_BIN $NR_ITER $NR_USEC_WAIT &
145 ok $?
"Start application to trace"
147 start_lttng_tracing
$SESSION_NAME
151 stop_lttng_tracing
$SESSION_NAME
152 destroy_lttng_session
$SESSION_NAME
154 out
=$
(babeltrace
$TRACE_PATH |
grep $EVENT_NAME |
wc -l)
155 if [ $out -eq 0 ]; then
156 fail
"Trace validation"
157 diag
"No event(s) found. We are supposed to have at least one."
160 pass
"Trace validation"
161 diag
"Found $out event(s). Coherent."
168 test_multiple_channels
() {
171 diag
"Start with multiple channels"
173 # BEFORE application is spawned
174 create_lttng_session
$SESSION_NAME $TRACE_PATH
175 enable_channel_per_pid
$SESSION_NAME "channel0"
176 enable_channel_per_pid
$SESSION_NAME "channel1"
177 enable_channel_per_pid
$SESSION_NAME "channel2"
178 enable_channel_per_pid
$SESSION_NAME "channel3"
179 enable_channel_per_pid
$SESSION_NAME "channel4"
180 # Enable event in all channels.
181 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN enable-event
$EVENT_NAME -c channel0
-s $SESSION_NAME -u >/dev
/null
2>&1
182 ok $?
"Enable event $EVENT_NAME for session $SESSION_NAME in channel0"
183 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN enable-event
$EVENT_NAME -c channel1
-s $SESSION_NAME -u >/dev
/null
2>&1
184 ok $?
"Enable event $EVENT_NAME for session $SESSION_NAME in channel1"
185 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN enable-event
$EVENT_NAME -c channel2
-s $SESSION_NAME -u >/dev
/null
2>&1
186 ok $?
"Enable event $EVENT_NAME for session $SESSION_NAME in channel2"
187 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN enable-event
$EVENT_NAME -c channel3
-s $SESSION_NAME -u >/dev
/null
2>&1
188 ok $?
"Enable event $EVENT_NAME for session $SESSION_NAME in channel3"
189 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN enable-event
$EVENT_NAME -c channel4
-s $SESSION_NAME -u >/dev
/null
2>&1
190 ok $?
"Enable event $EVENT_NAME for session $SESSION_NAME in channel4"
191 start_lttng_tracing
$SESSION_NAME
193 $TESTAPP_BIN $NR_ITER $NR_USEC_WAIT
194 ok $?
"Start application to trace"
196 stop_lttng_tracing
$SESSION_NAME
197 trace_match_only
$EVENT_NAME $
[NR_ITER
* 5] $TRACE_PATH
200 destroy_lttng_session
$SESSION_NAME
205 # MUST set TESTDIR before calling those functions
206 plan_tests
$NUM_TESTS
208 print_test_banner
"$TEST_DESC"
213 "test_after_multiple_apps"
214 "test_before_multiple_apps"
215 "test_multiple_channels"
218 TEST_COUNT
=${#TESTS[@]}
223 while [ $i -lt $TEST_COUNT ]; do
224 TRACE_PATH
=$
(mktemp
-d)