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 and periodical flush"
20 TESTDIR
=$CURDIR/..
/..
/..
23 TESTAPP_PATH
="$TESTDIR/utils/testapp"
24 TESTAPP_NAME
="gen-ust-events"
25 TESTAPP_BIN
="$TESTAPP_PATH/$TESTAPP_NAME/$TESTAPP_NAME"
26 SESSION_NAME
="periodical-flush"
27 EVENT_NAME
="tp:tptest"
28 BIN_NAME
="gen-nevents"
30 APP_TMP_FILE
="/tmp/lttng_test_ust.42.file"
32 source $TESTDIR/utils
/utils.sh
34 if [ ! -x "$TESTAPP_BIN" ]; then
35 BAIL_OUT
"No UST events binary detected."
38 # MUST set TESTDIR before calling those functions
40 function enable_channel_per_uid
()
45 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN enable-channel
--buffers-uid -u $channel_name -s $sess_name --switch-timer 100000 >/dev
/null
2>&1
46 ok $?
"Enable channel $channel_name per UID for session $sess_name"
49 function enable_channel_per_pid
()
54 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN enable-channel
--buffers-pid -u $channel_name -s $sess_name --switch-timer 100000 >/dev
/null
2>&1
55 ok $?
"Enable channel $channel_name per UID for session $sess_name"
58 function enable_metadata_per_uid
()
61 local channel_name
="metadata"
63 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN enable-channel
--buffers-uid -u $channel_name -s $sess_name --switch-timer 200000 >/dev
/null
2>&1
64 ok $?
"Enable channel $channel_name per UID for session $sess_name"
67 function enable_metadata_per_pid
()
70 local channel_name
="metadata"
72 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN enable-channel
--buffers-pid -u $channel_name -s $sess_name --switch-timer 200000 >/dev
/null
2>&1
73 ok $?
"Enable channel $channel_name per PID for session $sess_name"
78 diag
"Waiting for applications to end..."
79 while [ -n "$(pidof $TESTAPP_NAME)" ]; do
84 function validate_trace
()
88 out
=$
(babeltrace
$TRACE_PATH |
grep $EVENT_NAME |
wc -l)
89 if [ $out -eq 0 ]; then
90 fail
"Trace validation"
91 diag
"No event(s) found. We are supposed to have at least one."
94 pass
"Trace validation"
95 diag
"Found $out event(s). Coherent."
102 function check_app_tmp_file
()
104 # Wait for the application file to appear indicating that at least one
105 # tracepoint has been fired.
106 while [ ! -f "$APP_TMP_FILE" ]; do
109 diag
"Removing test app temporary file $APP_TMP_FILE"
113 function start_trace_app
()
115 # Start application with a temporary file.
116 $TESTAPP_BIN $NR_ITER $NR_USEC_WAIT $APP_TMP_FILE &
117 ok $?
"Start application to trace"
120 function start_check_trace_app
()
126 test_after_app_pid
() {
129 diag
"Start application AFTER tracing is started"
131 create_lttng_session
$SESSION_NAME $TRACE_PATH
132 enable_metadata_per_pid
$SESSION_NAME
133 enable_channel_per_pid
$SESSION_NAME "channel0"
134 enable_ust_lttng_event
$SESSION_NAME $EVENT_NAME "channel0"
135 start_lttng_tracing
$SESSION_NAME
137 # Start application after tracing
138 start_check_trace_app
139 # After this point we are sure that at least one event has been hit.
141 # Make sure the application does not generate any more data,
142 # thus ensuring that we are not flushing a packet concurrently
143 # with validate_trace.
144 killall
-SIGSTOP -q $TESTAPP_NAME
146 # Give time to the consumer to write inflight data.
152 stop_lttng_tracing
$SESSION_NAME
153 destroy_lttng_session
$SESSION_NAME
155 killall
-SIGKILL -q $TESTAPP_NAME
161 test_before_app_pid
() {
163 local tmp_file
="/tmp/lttng_test_ust.42.file"
165 diag
"Start application BEFORE tracing is started"
169 # Start application before tracing
170 create_lttng_session
$SESSION_NAME $TRACE_PATH
171 enable_metadata_per_pid
$SESSION_NAME
172 enable_channel_per_pid
$SESSION_NAME "channel0"
173 enable_ust_lttng_event
$SESSION_NAME $EVENT_NAME "channel0"
174 start_lttng_tracing
$SESSION_NAME
177 # Let the application at least perform a flush!
180 # Make sure the application does not generate any more data,
181 # thus ensuring that we are not flushing a packet concurrently
182 # with validate_trace.
183 killall
-SIGSTOP -q $TESTAPP_NAME
185 # Give time to the consumer to write inflight data.
191 stop_lttng_tracing
$SESSION_NAME
192 destroy_lttng_session
$SESSION_NAME
194 killall
-SIGKILL -q $TESTAPP_NAME
200 test_after_app_uid
() {
203 diag
"Start application AFTER tracing is started"
205 create_lttng_session
$SESSION_NAME $TRACE_PATH
206 enable_metadata_per_uid
$SESSION_NAME
207 enable_channel_per_uid
$SESSION_NAME "channel0"
208 enable_ust_lttng_event
$SESSION_NAME $EVENT_NAME "channel0"
209 start_lttng_tracing
$SESSION_NAME
211 # Start application after tracing
212 start_check_trace_app
213 # After this point we are sure that at least one event has been hit.
215 # Make sure the application does not generate any more data,
216 # thus ensuring that we are not flushing a packet concurrently
217 # with validate_trace.
218 killall
-SIGSTOP -q $TESTAPP_NAME
220 # Give time to the consumer to write inflight data.
226 stop_lttng_tracing
$SESSION_NAME
227 destroy_lttng_session
$SESSION_NAME
229 killall
-SIGKILL -q $TESTAPP_NAME
235 test_before_app_uid
() {
238 diag
"Start application BEFORE tracing is started"
240 # Start application before tracing
243 create_lttng_session
$SESSION_NAME $TRACE_PATH
244 enable_metadata_per_uid
$SESSION_NAME
245 enable_channel_per_uid
$SESSION_NAME "channel0"
246 enable_ust_lttng_event
$SESSION_NAME $EVENT_NAME "channel0"
247 start_lttng_tracing
$SESSION_NAME
250 # Let the application at least perform a flush!
253 # Make sure the application does not generate any more data,
254 # thus ensuring that we are not flushing a packet concurrently
255 # with validate_trace.
256 killall
-SIGSTOP -q $TESTAPP_NAME
258 # Give time to the consumer to write inflight data.
264 stop_lttng_tracing
$SESSION_NAME
265 destroy_lttng_session
$SESSION_NAME
267 killall
-SIGKILL -q $TESTAPP_NAME
273 # MUST set TESTDIR before calling those functions
274 plan_tests
$NUM_TESTS
276 print_test_banner
"$TEST_DESC"
279 "test_before_app_uid"
281 "test_before_app_pid"
285 TEST_COUNT
=${#TESTS[@]}
290 while [ $i -lt $TEST_COUNT ]; do
291 TRACE_PATH
=$
(mktemp
-d)
This page took 0.035626 seconds and 4 git commands to generate.