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_ok
$SESSION_NAME $TRACE_PATH
56 enable_channel_per_pid
$SESSION_NAME "channel0"
57 enable_ust_lttng_event_ok
$SESSION_NAME $EVENT_NAME "channel0"
58 start_lttng_tracing_ok
$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"
66 stop_lttng_tracing_ok
$SESSION_NAME
67 destroy_lttng_session
$SESSION_NAME
69 trace_match_only
$EVENT_NAME $
[NR_ITER
* 5] $TRACE_PATH
74 test_before_multiple_apps
() {
77 local file_sync_after_first
=$
(mktemp
-u)
78 local file_sync_before_last
=$
(mktemp
-u)
80 diag
"Start multiple applications BEFORE tracing is started"
82 for i
in `seq 1 5`; do
83 $TESTAPP_BIN $NR_ITER $NR_USEC_WAIT ${file_sync_after_first}_${i} ${file_sync_before_last}_${i} >/dev
/null
2>&1 &
84 ok $?
"Start application $i for tracing"
87 # BEFORE application is spawned
88 create_lttng_session_ok
$SESSION_NAME $TRACE_PATH
89 enable_channel_per_pid
$SESSION_NAME "channel0"
90 enable_ust_lttng_event_ok
$SESSION_NAME $EVENT_NAME "channel0"
91 start_lttng_tracing_ok
$SESSION_NAME
93 for i
in `seq 1 5`; do
94 touch ${file_sync_before_last}_
${i}
97 diag
"Waiting for applications to end"
101 stop_lttng_tracing_ok
$SESSION_NAME
102 destroy_lttng_session
$SESSION_NAME
104 for i
in `seq 1 5`; do
105 rm -f ${file_sync_after_first}_
${i}
106 rm -f ${file_sync_before_last}_
${i}
109 out
=$
(babeltrace
$TRACE_PATH |
grep $EVENT_NAME |
wc -l)
110 if [ $out -eq 0 ]; then
111 fail
"Trace validation"
112 diag
"No event(s) found. We are supposed to have at least one."
115 pass
"Trace validation"
116 diag
"Found $out event(s). Coherent."
126 diag
"Start application AFTER tracing is started"
128 # BEFORE application is spawned
129 create_lttng_session_ok
$SESSION_NAME $TRACE_PATH
130 enable_channel_per_pid
$SESSION_NAME "channel0"
131 enable_ust_lttng_event_ok
$SESSION_NAME $EVENT_NAME "channel0"
132 start_lttng_tracing_ok
$SESSION_NAME
134 $TESTAPP_BIN $NR_ITER $NR_USEC_WAIT &
135 ok $?
"Start application to trace"
138 stop_lttng_tracing_ok
$SESSION_NAME
139 destroy_lttng_session
$SESSION_NAME
141 trace_match_only
$EVENT_NAME $NR_ITER $TRACE_PATH
148 local file_sync_after_first
=$
(mktemp
-u)
149 local file_sync_before_last
=$
(mktemp
-u)
151 diag
"Start application BEFORE tracing is started"
154 # BEFORE application is spawned
155 create_lttng_session_ok
$SESSION_NAME $TRACE_PATH
156 enable_channel_per_pid
$SESSION_NAME "channel0"
157 enable_ust_lttng_event_ok
$SESSION_NAME $EVENT_NAME "channel0"
159 $TESTAPP_BIN $NR_ITER $NR_USEC_WAIT ${file_sync_after_first} ${file_sync_before_last} &
160 ok $?
"Start application to trace"
162 start_lttng_tracing_ok
$SESSION_NAME
164 touch ${file_sync_before_last}
168 stop_lttng_tracing_ok
$SESSION_NAME
169 destroy_lttng_session
$SESSION_NAME
171 rm -f ${file_sync_after_first}
172 rm -f ${file_sync_before_last}
174 out
=$
(babeltrace
$TRACE_PATH |
grep $EVENT_NAME |
wc -l)
175 if [ $out -eq 0 ]; then
176 fail
"Trace validation"
177 diag
"No event(s) found. We are supposed to have at least one."
180 pass
"Trace validation"
181 diag
"Found $out event(s). Coherent."
188 test_multiple_channels
() {
191 diag
"Start with multiple channels"
193 # BEFORE application is spawned
194 create_lttng_session_ok
$SESSION_NAME $TRACE_PATH
195 enable_channel_per_pid
$SESSION_NAME "channel0"
196 enable_channel_per_pid
$SESSION_NAME "channel1"
197 enable_channel_per_pid
$SESSION_NAME "channel2"
198 enable_channel_per_pid
$SESSION_NAME "channel3"
199 enable_channel_per_pid
$SESSION_NAME "channel4"
200 # Enable event in all channels.
201 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN enable-event
$EVENT_NAME -c channel0
-s $SESSION_NAME -u >/dev
/null
2>&1
202 ok $?
"Enable event $EVENT_NAME for session $SESSION_NAME in channel0"
203 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN enable-event
$EVENT_NAME -c channel1
-s $SESSION_NAME -u >/dev
/null
2>&1
204 ok $?
"Enable event $EVENT_NAME for session $SESSION_NAME in channel1"
205 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN enable-event
$EVENT_NAME -c channel2
-s $SESSION_NAME -u >/dev
/null
2>&1
206 ok $?
"Enable event $EVENT_NAME for session $SESSION_NAME in channel2"
207 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN enable-event
$EVENT_NAME -c channel3
-s $SESSION_NAME -u >/dev
/null
2>&1
208 ok $?
"Enable event $EVENT_NAME for session $SESSION_NAME in channel3"
209 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN enable-event
$EVENT_NAME -c channel4
-s $SESSION_NAME -u >/dev
/null
2>&1
210 ok $?
"Enable event $EVENT_NAME for session $SESSION_NAME in channel4"
211 start_lttng_tracing_ok
$SESSION_NAME
213 $TESTAPP_BIN $NR_ITER $NR_USEC_WAIT &
214 ok $?
"Start application to trace"
217 stop_lttng_tracing_ok
$SESSION_NAME
218 trace_match_only
$EVENT_NAME $
[NR_ITER
* 5] $TRACE_PATH
221 destroy_lttng_session
$SESSION_NAME
226 # MUST set TESTDIR before calling those functions
227 plan_tests
$NUM_TESTS
229 print_test_banner
"$TEST_DESC"
234 "test_after_multiple_apps"
235 "test_before_multiple_apps"
236 "test_multiple_channels"
239 TEST_COUNT
=${#TESTS[@]}
244 while [ $i -lt $TEST_COUNT ]; do
245 TRACE_PATH
=$
(mktemp
-d)