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
="Streaming - Kernel tracing"
20 TESTDIR
=$CURDIR/..
/..
/..
21 EVENT_NAME
="sched_switch"
25 TRACE_PATH
=$
(mktemp
-d)
29 source $TESTDIR/utils
/utils.sh
31 # LTTng kernel modules check
32 out
=`ls /lib/modules/$(uname -r)/extra | grep lttng`
33 if [ -z "$out" ]; then
34 BAIL_OUT
"LTTng modules not detected."
37 function lttng_create_session_uri
39 # Create session with default path
40 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN create
$SESSION_NAME -U net
://localhost
>/dev
/null
2>&1
42 ok $?
"Create session $SESSION_NAME"
45 function test_kernel_before_start
()
47 diag
"Test kernel streaming with event enable BEFORE start"
48 lttng_create_session_uri
49 lttng_enable_kernel_event
$SESSION_NAME $EVENT_NAME
50 start_lttng_tracing_ok
$SESSION_NAME
53 stop_lttng_tracing_ok
$SESSION_NAME
54 destroy_lttng_session_ok
$SESSION_NAME
57 # Deactivated since this feature is not yet available where we can enable
58 # an event AFTERE tracing has started.
59 function test_kernel_after_start
()
61 diag
"Test kernel streaming with event enable AFTER start"
62 lttng_create_session_uri
63 start_lttng_tracing_ok
$SESSION_NAME
64 lttng_enable_kernel_event
$SESSION_NAME $EVENT_NAME
67 stop_lttng_tracing_ok
$SESSION_NAME
68 destroy_lttng_session_ok
$SESSION_NAME
73 print_test_banner
"$TEST_DESC"
75 if [ "$(id -u)" == "0" ]; then
81 skip
$isroot "Root access is needed. Skipping all kernel streaming tests." $NUM_TESTS ||
83 start_lttng_relayd
"-o $TRACE_PATH"
86 tests
=( test_kernel_before_start
)
88 for fct_test
in ${tests[@]};
90 SESSION_NAME
=$
(randstring
16 0)
94 validate_trace
$EVENT_NAME $TRACE_PATH/$HOSTNAME/$SESSION_NAME*
96 # Only delete if successful