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 function validate_kernel_version
()
29 kern_version
=($
(uname
-r |
awk -F.
'{ printf("%d.%d.%d\n",$1,$2,$3); }' |
tr '.' '\n'))
30 if [ ${kern_version[0]} -gt $KERNEL_MAJOR_VERSION ]; then
33 if [ ${kern_version[1]} -gt $KERNEL_MINOR_VERSION ]; then
36 if [ ${kern_version[2]} -ge $KERNEL_PATCHLEVEL_VERSION ]; then
42 function spawn_sessiond
()
45 echo -n "Starting session daemon... "
46 validate_kernel_version
48 echo -e "\n*** Kernel to old for session daemon tests ***\n"
52 DIR
=$
(readlink
-f $TESTDIR)
54 if [ -z $
(pidof lt-
$SESSIOND_BIN) ]; then
55 $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"
57 echo -e "\e[1;31mFAILED\e[0m"
60 echo -e "\e[1;32mOK\e[0m"
67 function start_sessiond
()
69 if [ -n $TEST_NO_SESSIOND ] && [ "$TEST_NO_SESSIOND" == "1" ]; then
70 # Env variable requested no session daemon
76 if [ $out -eq 2 ]; then
77 # Kernel version is not compatible.
79 elif [ $out -ne 0 ]; then
84 # Simply wait for the session daemon bootstrap
85 echo "Waiting for the session daemon to bootstrap (2 secs)"
89 function stop_sessiond
()
91 if [ -n $TEST_NO_SESSIOND ] && [ "$TEST_NO_SESSIOND" == "1" ]; then
92 # Env variable requested no session daemon
96 PID_SESSIOND
=`pidof lt-$SESSIOND_BIN`
98 echo -e -n "Killing session daemon... "
99 kill $PID_SESSIOND >/dev
/null
2>&1
100 if [ $?
-eq 1 ]; then
101 echo -e "\e[1;31mFAILED\e[0m"
104 echo -e "\e[1;32mOK\e[0m"
108 function create_lttng_session
()
113 echo -n "Creating lttng session $sess_name in $trace_path"
114 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN create
$sess_name -o $trace_path >/dev
/null
2>&1
115 if [ $?
-eq 1 ]; then
116 echo -e "\e[1;31mFAILED\e[0m"
119 echo -e "\e[1;32mOK\e[0m"
123 function enable_lttng_channel
()
128 echo -n "Enabling lttng channel $channel_name for session $sess_name"
129 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN enable-channel
$channel_name -s $sess_name >/dev
/null
2>&1
130 if [ $?
-eq 1 ]; then
131 echo -e "\e[1;31mFAILED\e[0m"
134 echo -e "\e[1;32mOK\e[0m"
138 function disable_lttng_channel
()
143 echo -n "Disabling lttng channel $channel_name for session $sess_name"
144 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN disable-channel
$channel_name -s $sess_name >/dev
/null
2>&1
145 if [ $?
-eq 1 ]; then
146 echo -e "\e[1;31mFAILED\e[0m"
149 echo -e "\e[1;32mOK\e[0m"
153 function enable_ust_lttng_event
()
158 echo -n "Enabling lttng event $event_name for session $sess_name "
159 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN enable-event
$event_name -s $sess_name -u >/dev
/null
2>&1
160 if [ $?
-eq 1 ]; then
161 echo -e '\e[1;31mFAILED\e[0m'
164 echo -e "\e[1;32mOK\e[0m"
168 function start_tracing
()
172 echo -n "Start lttng tracing for session $sess_name "
173 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN start
$sess_name >/dev
/null
2>&1
174 if [ $?
-eq 1 ]; then
175 echo -e '\e[1;31mFAILED\e[0m'
178 echo -e "\e[1;32mOK\e[0m"
182 function stop_tracing
()
186 echo -n "Stop lttng tracing for session $sess_name "
187 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN stop
$sess_name >/dev
/null
2>&1
188 if [ $?
-eq 1 ]; then
189 echo -e '\e[1;31mFAILED\e[0m'
192 echo -e "\e[1;32mOK\e[0m"
196 function destroy_lttng_session
()
200 echo -n "Destroy lttng session $sess_name "
201 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN destroy
$sess_name >/dev
/null
2>&1
202 if [ $?
-eq 1 ]; then
203 echo -e '\e[1;31mFAILED\e[0m'
206 echo -e "\e[1;32mOK\e[0m"
210 function trace_matches
()
216 which $BABELTRACE_BIN >/dev
/null
217 if [ $?
-eq 1 ]; then
218 echo "Babeltrace binary not found. Skipping trace matches"
222 echo -n "Looking for $nr_iter $event_name in $trace_path "
224 count
=$
($BABELTRACE_BIN $trace_path |
grep $event_name |
wc -l)
225 if [ "$count" -ne "$nr_iter" ]; then
226 echo -e "$count found in trace \e[1;31mFAILED\e[0m"
229 echo -e "Trace is coherent \e[1;32mOK\e[0m"