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"
76 function validate_trace
()
80 out
=$
(babeltrace
$TRACE_PATH |
grep $EVENT_NAME |
wc -l)
81 if [ $out -eq 0 ]; then
82 fail
"Trace validation"
83 diag
"No event(s) found. We are supposed to have at least one."
86 pass
"Trace validation"
87 diag
"Found $out event(s). Coherent."
94 function check_app_tmp_file
()
96 # Wait for the application file to appear indicating that at least one
97 # tracepoint has been fired.
98 while [ ! -f "$APP_TMP_FILE" ]; do
101 diag
"Removing test app temporary file $APP_TMP_FILE"
105 function start_trace_app
()
107 # Start application with a temporary file.
108 $TESTAPP_BIN $NR_ITER $NR_USEC_WAIT $APP_TMP_FILE &
109 ok $?
"Start application to trace"
112 function start_check_trace_app
()
118 test_after_app_pid
() {
121 diag
"Start application AFTER tracing is started"
123 create_lttng_session
$SESSION_NAME $TRACE_PATH
124 enable_metadata_per_pid
$SESSION_NAME
125 enable_channel_per_pid
$SESSION_NAME "channel0"
126 enable_ust_lttng_event
$SESSION_NAME $EVENT_NAME "channel0"
127 start_lttng_tracing
$SESSION_NAME
129 # Start application after tracing
130 start_check_trace_app
131 # After this point we are sure that at least one event has been hit.
133 # Make sure the application does not generate any more data,
134 # thus ensuring that we are not flushing a packet concurrently
135 # with validate_trace.
136 killall
-SIGSTOP -q $TESTAPP_NAME
138 # Give time to the consumer to write inflight data.
144 killall
-SIGKILL -q $TESTAPP_NAME
145 stop_lttng_tracing
$SESSION_NAME
146 destroy_lttng_session
$SESSION_NAME
153 test_before_app_pid
() {
155 local tmp_file
="/tmp/lttng_test_ust.42.file"
157 diag
"Start application BEFORE tracing is started"
161 # Start application before tracing
162 create_lttng_session
$SESSION_NAME $TRACE_PATH
163 enable_metadata_per_pid
$SESSION_NAME
164 enable_channel_per_pid
$SESSION_NAME "channel0"
165 enable_ust_lttng_event
$SESSION_NAME $EVENT_NAME "channel0"
166 start_lttng_tracing
$SESSION_NAME
169 # Let the application at least perform a flush!
172 # Make sure the application does not generate any more data,
173 # thus ensuring that we are not flushing a packet concurrently
174 # with validate_trace.
175 killall
-SIGSTOP -q $TESTAPP_NAME
177 # Give time to the consumer to write inflight data.
183 killall
-SIGKILL -q $TESTAPP_NAME
184 stop_lttng_tracing
$SESSION_NAME
185 destroy_lttng_session
$SESSION_NAME
192 test_after_app_uid
() {
195 diag
"Start application AFTER tracing is started"
197 create_lttng_session
$SESSION_NAME $TRACE_PATH
198 enable_metadata_per_uid
$SESSION_NAME
199 enable_channel_per_uid
$SESSION_NAME "channel0"
200 enable_ust_lttng_event
$SESSION_NAME $EVENT_NAME "channel0"
201 start_lttng_tracing
$SESSION_NAME
203 # Start application after tracing
204 start_check_trace_app
205 # After this point we are sure that at least one event has been hit.
207 # Make sure the application does not generate any more data,
208 # thus ensuring that we are not flushing a packet concurrently
209 # with validate_trace.
210 killall
-SIGSTOP -q $TESTAPP_NAME
212 # Give time to the consumer to write inflight data.
218 killall
-SIGKILL -q $TESTAPP_NAME
219 stop_lttng_tracing
$SESSION_NAME
220 destroy_lttng_session
$SESSION_NAME
227 test_before_app_uid
() {
230 diag
"Start application BEFORE tracing is started"
232 # Start application before tracing
235 create_lttng_session
$SESSION_NAME $TRACE_PATH
236 enable_metadata_per_uid
$SESSION_NAME
237 enable_channel_per_uid
$SESSION_NAME "channel0"
238 enable_ust_lttng_event
$SESSION_NAME $EVENT_NAME "channel0"
239 start_lttng_tracing
$SESSION_NAME
242 # Let the application at least perform a flush!
245 # Make sure the application does not generate any more data,
246 # thus ensuring that we are not flushing a packet concurrently
247 # with validate_trace.
248 killall
-SIGSTOP -q $TESTAPP_NAME
250 # Give time to the consumer to write inflight data.
256 killall
-SIGKILL -q $TESTAPP_NAME
257 stop_lttng_tracing
$SESSION_NAME
258 destroy_lttng_session
$SESSION_NAME
265 # MUST set TESTDIR before calling those functions
266 plan_tests
$NUM_TESTS
268 print_test_banner
"$TEST_DESC"
271 "test_before_app_uid"
273 "test_before_app_pid"
277 TEST_COUNT
=${#TESTS[@]}
282 while [ $i -lt $TEST_COUNT ]; do
283 TRACE_PATH
=$
(mktemp
-d)
This page took 0.035964 seconds and 4 git commands to generate.