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
20 EVENT_NAME
="sched_switch"
24 TRACE_PATH
=$
(mktemp
-d)
26 source $TESTDIR/utils.sh
28 echo -e "\n---------------------------"
29 echo -e " Streaming - Kernel tracing "
30 echo -e "----------------------------"
32 if [ "$(id -u)" != "0" ]; then
33 echo "This test must be running as root. Aborting"
34 # Exit status 0 so the tests can continue
38 # LTTng kernel modules check
39 out
=`ls /lib/modules/$(uname -r)/extra | grep lttng`
40 if [ -z "$out" ]; then
41 echo "LTTng modules not detected. Aborting kernel tests!"
43 # Exit status 0 so the tests can continue
47 function lttng_create_session
49 echo -n "Creating session $SESSION_NAME... "
50 # Create session with default path
51 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN create
$SESSION_NAME >/dev
/null
2>&1
53 echo -e '\e[1;31mFAILED\e[0m'
56 echo -e "\e[1;32mOK\e[0m"
60 function lttng_enable_consumer_localhost
62 echo -n "Enabling network consumer... "
63 # Create session with default path
64 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN enable-consumer
-k net
://localhost
>/dev
/null
2>&1
66 echo -e '\e[1;31mFAILED\e[0m'
69 echo -e "\e[1;32mOK\e[0m"
73 function test_kernel_before_start
()
75 echo -e "\n=== Testing kernel streaming with event enable BEFORE start\n"
77 lttng_enable_consumer_localhost
78 lttng_enable_kernel_event
$SESSION_NAME $EVENT_NAME
79 start_tracing
$SESSION_NAME
82 stop_tracing
$SESSION_NAME
83 destroy_lttng_session
$SESSION_NAME
86 # Deactivated since this feature is not yet available where we can enable
87 # an event AFTERE tracing has started.
88 function test_kernel_after_start
()
90 echo -e "\n=== Testing kernel streaming with event enable AFTER start\n"
92 lttng_enable_consumer_localhost
93 start_tracing
$SESSION_NAME
94 lttng_enable_kernel_event
$SESSION_NAME $EVENT_NAME
97 stop_tracing
$SESSION_NAME
98 destroy_lttng_session
$SESSION_NAME
102 lttng_start_relayd
"-o $TRACE_PATH"
104 tests
=( test_kernel_before_start
)
106 for fct_test
in ${tests[@]};
108 SESSION_NAME
=$
(randstring
16 0)
112 validate_trace
$EVENT_NAME $TRACE_PATH/$HOSTNAME/$SESSION_NAME*
113 if [ $?
-eq 0 ]; then
114 # Only delete if successful