3 # Copyright (C) - 2013 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
="Streaming - Snapshot UST tracing"
20 TESTDIR
=$CURDIR/..
/..
/..
21 EVENT_NAME
="tp:tptest"
25 BIN_NAME
="gen-nevents"
26 TESTAPP_PATH
="$TESTDIR/utils/testapp"
27 TESTAPP_NAME
="gen-ust-events"
28 TESTAPP_BIN
="$TESTAPP_PATH/$TESTAPP_NAME/$TESTAPP_NAME"
33 TRACE_PATH
=$
(mktemp
-d)
37 source $TESTDIR/utils
/utils.sh
39 if [ ! -x "$TESTAPP_BIN" ]; then
40 BAIL_OUT
"No UST events binary detected."
43 # Start trace application and return once one event has been hit.
44 function start_test_app
()
46 local tmp_file
=$
(mktemp
-u)
48 # Start application with a temporary file.
49 $TESTAPP_BIN $NR_ITER $NR_USEC_WAIT $tmp_file &
51 APPS_PID
="${APPS_PID} ${!}"
52 ok
$ret "Start application to trace"
54 # Wait for the application file to appear indicating that at least one
55 # tracepoint has been fired.
56 while [ ! -f "$tmp_file" ]; do
59 diag
"Removing test app temporary file $tmp_file"
63 function stop_test_apps
()
65 diag
"Stopping $TESTAPP_NAME"
66 for p
in ${APPS_PID}; do
73 # Test a snapshot using a default name for the output destination.
74 function test_ust_default_name_with_del
()
76 diag
"Test UST snapshot streaming with default name with delete output"
77 create_lttng_session_no_output
$SESSION_NAME
78 enable_lttng_mmap_overwrite_ust_channel
$SESSION_NAME $CHANNEL_NAME
79 enable_ust_lttng_event_ok
$SESSION_NAME $EVENT_NAME $CHANNEL_NAME
80 start_lttng_tracing_ok
$SESSION_NAME
84 lttng_snapshot_add_output_ok
$SESSION_NAME "net://localhost"
85 lttng_snapshot_record
$SESSION_NAME
88 echo $TRACE_PATH/$HOSTNAME/snapshot-1
89 validate_trace
$EVENT_NAME $TRACE_PATH/$HOSTNAME/snapshot-1
*
95 lttng_snapshot_del_output_ok
$SESSION_NAME 1
96 lttng_snapshot_add_output_ok
$SESSION_NAME "net://localhost"
97 lttng_snapshot_record
$SESSION_NAME
99 # Validate test with the next ID since a del output was done prior.
100 validate_trace
$EVENT_NAME $TRACE_PATH/$HOSTNAME/snapshot-2
*
101 if [ $?
-ne 0 ]; then
106 stop_lttng_tracing_ok
$SESSION_NAME
107 destroy_lttng_session_ok
$SESSION_NAME
114 # Test a snapshot using a default name for the output destination.
115 function test_ust_default_name
()
117 diag
"Test UST snapshot streaming with default name"
118 create_lttng_session_no_output
$SESSION_NAME
119 enable_lttng_mmap_overwrite_ust_channel
$SESSION_NAME $CHANNEL_NAME
120 enable_ust_lttng_event_ok
$SESSION_NAME $EVENT_NAME $CHANNEL_NAME
121 start_lttng_tracing_ok
$SESSION_NAME
125 lttng_snapshot_add_output_ok
$SESSION_NAME "net://localhost"
126 lttng_snapshot_record
$SESSION_NAME
127 stop_lttng_tracing_ok
$SESSION_NAME
128 destroy_lttng_session_ok
$SESSION_NAME
130 validate_trace
$EVENT_NAME $TRACE_PATH/$HOSTNAME/snapshot-1
*
138 function test_ust_default_name_custom_uri
()
140 diag
"Test UST snapshot streaming with default name with custom URL"
141 create_lttng_session_no_output
$SESSION_NAME
142 enable_lttng_mmap_overwrite_ust_channel
$SESSION_NAME $CHANNEL_NAME
143 enable_ust_lttng_event_ok
$SESSION_NAME $EVENT_NAME $CHANNEL_NAME
144 start_lttng_tracing_ok
$SESSION_NAME
148 lttng_snapshot_add_output_ok
$SESSION_NAME "-C tcp://localhost:5342 -D tcp://localhost:5343"
149 lttng_snapshot_record
$SESSION_NAME
150 stop_lttng_tracing_ok
$SESSION_NAME
151 destroy_lttng_session_ok
$SESSION_NAME
153 validate_trace
$EVENT_NAME $TRACE_PATH/$HOSTNAME/snapshot-1
*
161 # Test a snapshot using a custom name for the output destination.
162 function test_ust_custom_name
()
165 local name
="asnapshotname"
167 diag
"Test UST snapshot streaming with custom name"
168 create_lttng_session_no_output
$SESSION_NAME
169 enable_lttng_mmap_overwrite_ust_channel
$SESSION_NAME $CHANNEL_NAME
170 enable_ust_lttng_event_ok
$SESSION_NAME $EVENT_NAME $CHANNEL_NAME
171 start_lttng_tracing_ok
$SESSION_NAME
175 lttng_snapshot_add_output_ok
$SESSION_NAME "net://localhost" "-n $name"
176 lttng_snapshot_record
$SESSION_NAME
177 stop_lttng_tracing_ok
$SESSION_NAME
178 destroy_lttng_session_ok
$SESSION_NAME
180 if ls $TRACE_PATH/$HOSTNAME/$name* &> /dev
/null
; then
181 ok
0 "Custom name snapshot exists"
183 validate_trace
$EVENT_NAME $TRACE_PATH/$HOSTNAME/$name-*
186 fail
"No custom name snapshot found"
195 plan_tests
$NUM_TESTS
197 print_test_banner
"$TEST_DESC"
199 if [ "$(id -u)" == "0" ]; then
205 start_lttng_relayd
"-o $TRACE_PATH"
208 tests
=( test_ust_default_name_with_del test_ust_default_name test_ust_custom_name test_ust_default_name_custom_uri
)
210 for fct_test
in ${tests[@]};
212 SESSION_NAME
=$
(randstring
16 0)
214 if [ $?
-eq 0 ]; then
215 # Only delete if successful