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
18 SESSIOND_BIN
="lttng-sessiond"
20 BABELTRACE_BIN
="babeltrace"
22 # Minimal kernel version supported for session daemon tests
23 KERNEL_MAJOR_VERSION
=2
24 KERNEL_MINOR_VERSION
=6
25 KERNEL_PATCHLEVEL_VERSION
=27
27 alias realpath
='readlink -f'
29 function validate_kernel_version
()
31 kern_version
=($
(uname
-r |
awk -F.
'{ printf("%d.%d.%d\n",$1,$2,$3); }' |
tr '.' '\n'))
32 if [ ${kern_version[0]} -gt $KERNEL_MAJOR_VERSION ]; then
35 if [ ${kern_version[1]} -gt $KERNEL_MINOR_VERSION ]; then
38 if [ ${kern_version[2]} -ge $KERNEL_PATCHLEVEL_VERSION ]; then
44 function spawn_sessiond
()
47 echo -n "Starting session daemon... "
48 validate_kernel_version
50 echo -e "\n*** Kernel to old for session daemon tests ***\n"
54 DIR
=$
(realpath
$TESTDIR)
56 if [ -z $
(pidof lt-
$SESSIOND_BIN) ]; then
57 $DIR/..
/src
/bin
/lttng-sessiond
/$SESSIOND_BIN --daemonize --quiet --consumerd32-path="$DIR/../src/bin/lttng-consumerd/lttng-consumerd" --consumerd64-path="$DIR/../src/bin/lttng-consumerd/lttng-consumerd"
59 echo -e "\e[1;31mFAILED\e[0m"
62 echo -e "\e[1;32mOK\e[0m"
69 function start_sessiond
()
71 if [ -n $TEST_NO_SESSIOND ] && [ "$TEST_NO_SESSIOND" == "1" ]; then
72 # Env variable requested no session daemon
78 if [ $out -eq 2 ]; then
79 # Kernel version is not compatible.
81 elif [ $out -ne 0 ]; then
86 # Simply wait for the session daemon bootstrap
87 echo "Waiting for the session daemon to bootstrap (2 secs)"
91 function stop_sessiond
()
93 if [ -n $TEST_NO_SESSIOND ] && [ "$TEST_NO_SESSIOND" == "1" ]; then
94 # Env variable requested no session daemon
98 PID_SESSIOND
=`pidof lt-$SESSIOND_BIN`
100 echo -e -n "Killing session daemon... "
101 kill $PID_SESSIOND >/dev
/null
2>&1
102 if [ $?
-eq 1 ]; then
103 echo -e "\e[1;31mFAILED\e[0m"
106 echo -e "\e[1;32mOK\e[0m"
110 function create_lttng_session
()
115 echo -n "Creating lttng session $sess_name in $trace_path"
116 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN create
$sess_name -o $trace_path >/dev
/null
2>&1
117 if [ $?
-eq 1 ]; then
118 echo -e "\e[1;31mFAILED\e[0m"
121 echo -e "\e[1;32mOK\e[0m"
125 function enable_lttng_channel
()
130 echo -n "Enabling lttng channel $channel_name for session $sess_name"
131 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN enable-channel
$channel_name -s $sess_name >/dev
/null
2>&1
132 if [ $?
-eq 1 ]; then
133 echo -e "\e[1;31mFAILED\e[0m"
136 echo -e "\e[1;32mOK\e[0m"
140 function disable_lttng_channel
()
145 echo -n "Disabling lttng channel $channel_name for session $sess_name"
146 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN disable-channel
$channel_name -s $sess_name >/dev
/null
2>&1
147 if [ $?
-eq 1 ]; then
148 echo -e "\e[1;31mFAILED\e[0m"
151 echo -e "\e[1;32mOK\e[0m"
155 function enable_ust_lttng_event
()
160 echo -n "Enabling lttng event $event_name for session $sess_name "
161 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN enable-event
$event_name -s $sess_name -u >/dev
/null
2>&1
162 if [ $?
-eq 1 ]; then
163 echo -e '\e[1;31mFAILED\e[0m'
166 echo -e "\e[1;32mOK\e[0m"
170 function start_tracing
()
174 echo -n "Start lttng tracing for session $sess_name "
175 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN start
$sess_name >/dev
/null
2>&1
176 if [ $?
-eq 1 ]; then
177 echo -e '\e[1;31mFAILED\e[0m'
180 echo -e "\e[1;32mOK\e[0m"
184 function stop_tracing
()
188 echo -n "Stop lttng tracing for session $sess_name "
189 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN stop
$sess_name >/dev
/null
2>&1
190 if [ $?
-eq 1 ]; then
191 echo -e '\e[1;31mFAILED\e[0m'
194 echo -e "\e[1;32mOK\e[0m"
198 function destroy_lttng_session
()
202 echo -n "Destroy lttng session $sess_name "
203 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN destroy
$sess_name >/dev
/null
2>&1
204 if [ $?
-eq 1 ]; then
205 echo -e '\e[1;31mFAILED\e[0m'
208 echo -e "\e[1;32mOK\e[0m"
212 function trace_matches
()
218 which $BABELTRACE_BIN >/dev
/null
219 if [ $?
-eq 1 ]; then
220 echo "Babeltrace binary not found. Skipping trace matches"
224 echo -n "Looking for $nr_iter $event_name in $trace_path "
226 count
=$
($BABELTRACE_BIN $trace_path |
grep $event_name |
wc -l)
227 if [ "$count" -ne "$nr_iter" ]; then
228 echo -e "$count found in trace \e[1;31mFAILED\e[0m"
231 echo -e "Trace is coherent \e[1;32mOK\e[0m"