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"
25 TRACE_PATH
=$
(mktemp
-d)
29 source $TESTDIR/utils
/utils.sh
31 function snapshot_add_output
()
38 if [ ! -z $name ]; then
42 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN snapshot add-output
-s $sess_name $extra_opt $trace_path >/dev
/null
2>&1
43 ok $?
"Added snapshot output $trace_path"
46 # Test a snapshot using a default name for the output destination.
47 function test_kernel_default_name_with_del
()
49 diag
"Test kernel snapshot streaming with default name with delete output"
50 create_lttng_session_no_output
$SESSION_NAME
51 enable_lttng_mmap_overwrite_kernel_channel
$SESSION_NAME $CHANNEL_NAME
52 lttng_enable_kernel_event
$SESSION_NAME $EVENT_NAME $CHANNEL_NAME
53 start_lttng_tracing_ok
$SESSION_NAME
54 snapshot_add_output
$SESSION_NAME "net://localhost"
55 lttng_snapshot_record
$SESSION_NAME
58 validate_trace
$EVENT_NAME $TRACE_PATH/$HOSTNAME/snapshot-1
*
63 lttng_snapshot_del_output_ok
$SESSION_NAME 1
64 snapshot_add_output
$SESSION_NAME "net://localhost"
65 lttng_snapshot_record
$SESSION_NAME
67 # Validate test with the next ID since a del output was done prior.
68 validate_trace
$EVENT_NAME $TRACE_PATH/$HOSTNAME/snapshot-2
*
73 stop_lttng_tracing_ok
$SESSION_NAME
74 destroy_lttng_session_ok
$SESSION_NAME
79 # Test a snapshot using a default name for the output destination.
80 function test_kernel_default_name
()
82 diag
"Test kernel snapshot streaming with default name"
83 create_lttng_session_no_output
$SESSION_NAME
84 enable_lttng_mmap_overwrite_kernel_channel
$SESSION_NAME $CHANNEL_NAME
85 lttng_enable_kernel_event
$SESSION_NAME $EVENT_NAME $CHANNEL_NAME
86 start_lttng_tracing_ok
$SESSION_NAME
87 snapshot_add_output
$SESSION_NAME "net://localhost"
88 lttng_snapshot_record
$SESSION_NAME
89 stop_lttng_tracing_ok
$SESSION_NAME
90 destroy_lttng_session_ok
$SESSION_NAME
92 validate_trace
$EVENT_NAME $TRACE_PATH/$HOSTNAME/snapshot-1
*
98 # Test a snapshot using a custom name for the output destination.
99 function test_kernel_custom_name
()
102 local name
="asnapshotname"
104 diag
"Test kernel snapshot streaming with custom name"
105 create_lttng_session_no_output
$SESSION_NAME
106 enable_lttng_mmap_overwrite_kernel_channel
$SESSION_NAME $CHANNEL_NAME
107 lttng_enable_kernel_event
$SESSION_NAME $EVENT_NAME $CHANNEL_NAME
108 start_lttng_tracing_ok
$SESSION_NAME
109 snapshot_add_output
$SESSION_NAME "net://localhost" $name
110 lttng_snapshot_record
$SESSION_NAME
111 stop_lttng_tracing_ok
$SESSION_NAME
112 destroy_lttng_session_ok
$SESSION_NAME
114 if ls $TRACE_PATH/$HOSTNAME/$name* &> /dev
/null
; then
115 ok
0 "Custom name snapshot exists"
117 validate_trace
$EVENT_NAME $TRACE_PATH/$HOSTNAME/$name-*
120 fail
"No custom name snapshot found"
127 plan_tests
$NUM_TESTS
129 print_test_banner
"$TEST_DESC"
131 if [ "$(id -u)" == "0" ]; then
137 skip
$isroot "Root access is needed. Skipping all kernel streaming tests." $NUM_TESTS ||
139 validate_lttng_modules_present
141 start_lttng_relayd
"-o $TRACE_PATH"
144 tests
=( test_kernel_default_name test_kernel_custom_name \
145 test_kernel_default_name_with_del
)
147 for fct_test
in ${tests[@]};
149 SESSION_NAME
=$
(randstring
16 0)
151 if [ $?
-eq 0 ]; then
152 # Only delete if successful