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 source $TESTDIR/utils.sh
26 echo -e "\n---------------------------"
27 echo -e " Streaming - Kernel tracing "
28 echo -e "----------------------------"
30 if [ "$(id -u)" != "0" ]; then
31 echo "This test must be running as root. Aborting"
32 # Exit status 0 so the tests can continue
36 # LTTng kernel modules check
37 out
=`ls /lib/modules/$(uname -r)/extra | grep lttng`
38 if [ -z "$out" ]; then
39 echo "LTTng modules not detected. Aborting kernel tests!"
41 # Exit status 0 so the tests can continue
45 function lttng_create_session
47 echo -n "Creating session $SESSION_NAME... "
48 # Create session with default path
49 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN create
$SESSION_NAME >/dev
/null
2>&1
51 echo -e '\e[1;31mFAILED\e[0m'
54 echo -e "\e[1;32mOK\e[0m"
58 function lttng_enable_consumer_localhost
60 echo -n "Enabling network consumer... "
61 # Create session with default path
62 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN enable-consumer
-k net
://localhost
>/dev
/null
2>&1
64 echo -e '\e[1;31mFAILED\e[0m'
67 echo -e "\e[1;32mOK\e[0m"
71 function test_kernel_before_start
()
73 echo -e "\n=== Testing kernel streaming with event enable BEFORE start\n"
75 lttng_enable_consumer_localhost
76 lttng_enable_kernel_event
$SESSION_NAME $EVENT_NAME
77 start_tracing
$SESSION_NAME
80 stop_tracing
$SESSION_NAME
81 destroy_lttng_session
$SESSION_NAME
84 function test_kernel_after_start
()
86 echo -e "\n=== Testing kernel streaming with event enable AFTER start\n"
88 lttng_enable_consumer_localhost
89 start_tracing
$SESSION_NAME
90 lttng_enable_kernel_event
$SESSION_NAME $EVENT_NAME
93 stop_tracing
$SESSION_NAME
94 destroy_lttng_session
$SESSION_NAME
100 tests
=( test_kernel_before_start test_kernel_after_start
)
102 for fct_test
in ${tests[@]};
104 SESSION_NAME
=$
(randstring
16 0)
108 validate_trace
$EVENT_NAME ~
/lttng-traces
/$HOSTNAME/$SESSION_NAME*
109 if [ $?
-eq 0 ]; then
110 # Only delete if successful
111 rm -rf ~
/lttng-traces
/$HOSTNAME/$SESSION_NAME*
112 rm -rf ~
/lttng-traces
/$SESSION_NAME*