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 Kernel tracing"
20 TESTDIR
=$CURDIR/..
/..
/..
21 EVENT_NAME
="sched_switch"
26 TRACE_PATH
=$
(mktemp
-d)
30 source $TESTDIR/utils
/utils.sh
32 function snapshot_add_output
()
39 if [ ! -z $name ]; then
43 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN snapshot add-output
-s $sess_name $extra_opt $trace_path >/dev
/null
2>&1
44 ok $?
"Added snapshot output $trace_path"
47 # Test a snapshot using a default name for the output destination.
48 function test_kernel_default_name_with_del
()
50 diag
"Test kernel snapshot streaming with default name with delete output"
51 create_lttng_session_no_output
$SESSION_NAME
52 enable_lttng_mmap_overwrite_kernel_channel
$SESSION_NAME $CHANNEL_NAME
53 lttng_enable_kernel_event
$SESSION_NAME $EVENT_NAME $CHANNEL_NAME
54 start_lttng_tracing_ok
$SESSION_NAME
55 snapshot_add_output
$SESSION_NAME "net://localhost"
56 lttng_snapshot_record
$SESSION_NAME
59 validate_trace
$EVENT_NAME $TRACE_PATH/$HOSTNAME/snapshot-1
*
64 lttng_snapshot_del_output_ok
$SESSION_NAME 1
65 snapshot_add_output
$SESSION_NAME "net://localhost"
66 lttng_snapshot_record
$SESSION_NAME
68 # Validate test with the next ID since a del output was done prior.
69 validate_trace
$EVENT_NAME $TRACE_PATH/$HOSTNAME/snapshot-2
*
74 stop_lttng_tracing_ok
$SESSION_NAME
75 destroy_lttng_session_ok
$SESSION_NAME
80 # Test a snapshot using a default name for the output destination.
81 function test_kernel_default_name
()
83 diag
"Test kernel snapshot streaming with default name"
84 create_lttng_session_no_output
$SESSION_NAME
85 enable_lttng_mmap_overwrite_kernel_channel
$SESSION_NAME $CHANNEL_NAME
86 lttng_enable_kernel_event
$SESSION_NAME $EVENT_NAME $CHANNEL_NAME
87 start_lttng_tracing_ok
$SESSION_NAME
88 snapshot_add_output
$SESSION_NAME "net://localhost"
89 lttng_snapshot_record
$SESSION_NAME
90 stop_lttng_tracing_ok
$SESSION_NAME
91 destroy_lttng_session_ok
$SESSION_NAME
93 validate_trace
$EVENT_NAME $TRACE_PATH/$HOSTNAME/snapshot-1
*
99 # Test a snapshot using a custom name for the output destination.
100 function test_kernel_custom_name
()
103 local name
="asnapshotname"
105 diag
"Test kernel snapshot streaming with custom name"
106 create_lttng_session_no_output
$SESSION_NAME
107 enable_lttng_mmap_overwrite_kernel_channel
$SESSION_NAME $CHANNEL_NAME
108 lttng_enable_kernel_event
$SESSION_NAME $EVENT_NAME $CHANNEL_NAME
109 start_lttng_tracing_ok
$SESSION_NAME
110 snapshot_add_output
$SESSION_NAME "net://localhost" $name
111 lttng_snapshot_record
$SESSION_NAME
112 stop_lttng_tracing_ok
$SESSION_NAME
113 destroy_lttng_session_ok
$SESSION_NAME
115 if ls $TRACE_PATH/$HOSTNAME/$name* &> /dev
/null
; then
116 ok
0 "Custom name snapshot exists"
118 validate_trace
$EVENT_NAME $TRACE_PATH/$HOSTNAME/$name-*
121 fail
"No custom name snapshot found"
128 plan_tests
$NUM_TESTS
130 print_test_banner
"$TEST_DESC"
132 if [ "$(id -u)" == "0" ]; then
138 skip
$isroot "Root access is needed. Skipping all kernel streaming tests." $NUM_TESTS ||
140 validate_lttng_modules_present
142 start_lttng_relayd
"-o $TRACE_PATH"
145 tests
=( test_kernel_default_name test_kernel_custom_name \
146 test_kernel_default_name_with_del
)
148 for fct_test
in ${tests[@]};
150 SESSION_NAME
=$
(randstring
16 0)
152 if [ $?
-eq 0 ]; then
153 # Only delete if successful