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"
32 TRACE_PATH
=$
(mktemp
-d)
36 source $TESTDIR/utils
/utils.sh
38 if [ ! -x "$TESTAPP_BIN" ]; then
39 BAIL_OUT
"No UST events binary detected."
42 function snapshot_add_output
()
49 if [ ! -z $name ]; then
53 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN snapshot add-output
-s $sess_name $extra_opt $trace_path >/dev
/null
2>&1
54 ok $?
"Added snapshot output $trace_path"
57 # Test a snapshot using a default name for the output destination.
58 function test_ust_default_name_with_del
()
60 diag
"Test UST snapshot streaming with default name with delete output"
61 create_lttng_session_no_output
$SESSION_NAME
62 enable_lttng_mmap_overwrite_ust_channel
$SESSION_NAME $CHANNEL_NAME
63 enable_ust_lttng_event
$SESSION_NAME $EVENT_NAME $CHANNEL_NAME
64 start_lttng_tracing
$SESSION_NAME
65 $TESTAPP_BIN $NR_ITER $NR_USEC_WAIT &
66 ok $?
"Start application to trace"
67 snapshot_add_output
$SESSION_NAME "net://localhost"
68 lttng_snapshot_record
$SESSION_NAME
71 echo $TRACE_PATH/$HOSTNAME/snapshot-1
72 validate_trace
$EVENT_NAME $TRACE_PATH/$HOSTNAME/snapshot-1
*
77 lttng_snapshot_del_output
$SESSION_NAME 1
78 snapshot_add_output
$SESSION_NAME "net://localhost"
79 lttng_snapshot_record
$SESSION_NAME
81 # Validate test with the next ID since a del output was done prior.
82 validate_trace
$EVENT_NAME $TRACE_PATH/$HOSTNAME/snapshot-2
*
87 stop_lttng_tracing
$SESSION_NAME
88 destroy_lttng_session
$SESSION_NAME
90 diag
"Killing $TESTAPP_NAME"
91 PID_APP
=`pidof $TESTAPP_NAME`
92 kill $PID_APP >/dev
/null
2>&1
97 # Test a snapshot using a default name for the output destination.
98 function test_ust_default_name
()
100 diag
"Test UST snapshot streaming with default name"
101 create_lttng_session_no_output
$SESSION_NAME
102 enable_lttng_mmap_overwrite_ust_channel
$SESSION_NAME $CHANNEL_NAME
103 enable_ust_lttng_event
$SESSION_NAME $EVENT_NAME $CHANNEL_NAME
104 start_lttng_tracing
$SESSION_NAME
105 $TESTAPP_BIN $NR_ITER $NR_USEC_WAIT &
106 ok $?
"Start application to trace"
107 snapshot_add_output
$SESSION_NAME "net://localhost"
108 lttng_snapshot_record
$SESSION_NAME
109 stop_lttng_tracing
$SESSION_NAME
110 destroy_lttng_session
$SESSION_NAME
112 validate_trace
$EVENT_NAME $TRACE_PATH/$HOSTNAME/snapshot-1
*
115 diag
"Killing $TESTAPP_NAME"
116 PID_APP
=`pidof $TESTAPP_NAME`
117 kill $PID_APP >/dev
/null
2>&1
122 # Test a snapshot using a custom name for the output destination.
123 function test_ust_custom_name
()
126 local name
="asnapshotname"
128 diag
"Test UST snapshot streaming with custom name"
129 create_lttng_session_no_output
$SESSION_NAME
130 enable_lttng_mmap_overwrite_ust_channel
$SESSION_NAME $CHANNEL_NAME
131 enable_ust_lttng_event
$SESSION_NAME $EVENT_NAME $CHANNEL_NAME
132 start_lttng_tracing
$SESSION_NAME
133 $TESTAPP_BIN $NR_ITER $NR_USEC_WAIT &
134 ok $?
"Start application to trace"
135 snapshot_add_output
$SESSION_NAME "net://localhost" $name
136 lttng_snapshot_record
$SESSION_NAME
137 stop_lttng_tracing
$SESSION_NAME
138 destroy_lttng_session
$SESSION_NAME
140 if ls $TRACE_PATH/$HOSTNAME/$name* &> /dev
/null
; then
141 ok
0 "Custom name snapshot exists"
143 validate_trace
$EVENT_NAME $TRACE_PATH/$HOSTNAME/$name-*
146 fail
"No custom name snapshot found"
150 diag
"Killing $TESTAPP_NAME"
151 PID_APP
=`pidof $TESTAPP_NAME`
152 kill $PID_APP >/dev
/null
2>&1
157 plan_tests
$NUM_TESTS
159 print_test_banner
"$TEST_DESC"
161 if [ "$(id -u)" == "0" ]; then
167 start_lttng_relayd
"-o $TRACE_PATH"
170 tests
=( test_ust_default_name_with_del test_ust_default_name test_ust_custom_name
)
172 for fct_test
in ${tests[@]};
174 SESSION_NAME
=$
(randstring
16 0)
176 if [ $?
-eq 0 ]; then
177 # Only delete if successful