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"
21 EVENT_NAME
="sched_switch"
25 TRACE_PATH
=$
(mktemp
-d)
27 source $TESTDIR/utils.sh
29 print_test_banner
"$TEST_DESC"
31 if [ "$(id -u)" != "0" ]; then
32 echo "This test must be running as root. Aborting"
33 # Exit status 0 so the tests can continue
37 # LTTng kernel modules check
38 out
=`ls /lib/modules/$(uname -r)/extra | grep lttng`
39 if [ -z "$out" ]; then
40 echo "LTTng modules not detected. Aborting kernel tests!"
42 # Exit status 0 so the tests can continue
46 function lttng_create_session_uri
48 echo -n "Creating session $SESSION_NAME... "
49 # Create session with default path
50 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN create
$SESSION_NAME -U net
://localhost
>/dev
/null
2>&1
59 function test_kernel_before_start
()
61 echo -e "\n=== Testing kernel streaming with event enable BEFORE start\n"
62 lttng_create_session_uri
63 lttng_enable_kernel_event
$SESSION_NAME $EVENT_NAME
64 start_lttng_tracing
$SESSION_NAME
67 stop_lttng_tracing
$SESSION_NAME
68 destroy_lttng_session
$SESSION_NAME
70 # We can not predict _yet_ when the trace is available so we have to do a
71 # arbitratry sleep to validate the trace.
72 echo -n "Waiting 3 seconds for the trace to be written on disk "
73 for i
in `seq 1 3`; do
80 # Deactivated since this feature is not yet available where we can enable
81 # an event AFTERE tracing has started.
82 function test_kernel_after_start
()
84 echo -e "\n=== Testing kernel streaming with event enable AFTER start\n"
85 lttng_create_session_uri
86 start_lttng_tracing
$SESSION_NAME
87 lttng_enable_kernel_event
$SESSION_NAME $EVENT_NAME
90 stop_lttng_tracing
$SESSION_NAME
91 destroy_lttng_session
$SESSION_NAME
95 start_lttng_relayd
"-o $TRACE_PATH"
97 tests
=( test_kernel_before_start
)
99 for fct_test
in ${tests[@]};
101 SESSION_NAME
=$
(randstring
16 0)
105 validate_trace
$EVENT_NAME $TRACE_PATH/$HOSTNAME/$SESSION_NAME*
106 if [ $?
-eq 0 ]; then
107 # Only delete if successful