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 start_sessiond
()
45 echo -n "Starting session daemon... "
46 validate_kernel_version
48 echo -e "\n*** Kernel to old for session daemon tests ***\n"
52 if [ -z $
(pidof lt-
$SESSIOND_BIN) ]; then
53 $TESTDIR/..
/src
/bin
/lttng-sessiond
/$SESSIOND_BIN --daemonize --quiet --consumerd32-path="$(pwd)/../src/bin/lttng-consumerd/lttng-consumerd" --consumerd64-path="$(pwd)/../src/bin/lttng-consumerd/lttng-consumerd"
55 echo -e "\e[1;31mFAILED\e[0m"
58 echo -e "\e[1;32mOK\e[0m"
65 function stop_sessiond
()
67 PID_SESSIOND
=`pidof lt-$SESSIOND_BIN`
69 echo -e -n "Killing session daemon... "
70 kill $PID_SESSIOND >/dev
/null
2>&1
72 echo -e "\e[1;31mFAILED\e[0m"
76 while [ -n "$out" ]; do
77 out
=$
(pidof lt-
$SESSIOND_BIN)
80 echo -e "\e[1;32mOK\e[0m"
84 function create_lttng_session
()
89 echo -n "Creating lttng session $SESSION_NAME in $TRACE_PATH "
90 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN create
$sess_name -o $trace_path >/dev
/null
2>&1
92 echo -e "\e[1;31mFAILED\e[0m"
95 echo -e "\e[1;32mOK\e[0m"
96 #echo $out | grep "written in" | cut -d' ' -f6
100 function enable_ust_lttng_event
()
105 echo -n "Enabling lttng event $event_name for session $sess_name "
106 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN enable-event
$event_name -s $sess_name -u >/dev
/null
2>&1
107 if [ $?
-eq 1 ]; then
108 echo -e '\e[1;31mFAILED\e[0m'
111 echo -e "\e[1;32mOK\e[0m"
115 function start_tracing
()
119 echo -n "Start lttng tracing for session $sess_name "
120 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN start
$sess_name >/dev
/null
2>&1
121 if [ $?
-eq 1 ]; then
122 echo -e '\e[1;31mFAILED\e[0m'
125 echo -e "\e[1;32mOK\e[0m"
129 function stop_tracing
()
133 echo -n "Stop lttng tracing for session $sess_name "
134 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN stop
$sess_name >/dev
/null
2>&1
135 if [ $?
-eq 1 ]; then
136 echo -e '\e[1;31mFAILED\e[0m'
139 echo -e "\e[1;32mOK\e[0m"
143 function destroy_lttng_session
()
147 echo -n "Destroy lttng session $sess_name "
148 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN destroy
$sess_name >/dev
/null
2>&1
149 if [ $?
-eq 1 ]; then
150 echo -e '\e[1;31mFAILED\e[0m'
153 echo -e "\e[1;32mOK\e[0m"
157 function trace_matches
()
163 which $BABELTRACE_BIN >/dev
/null
164 if [ $?
-eq 1 ]; then
165 echo "Babeltrace binary not found. Skipping trace matches"
169 echo -n "Looking for $nr_iter $event_name in $trace_path "
171 count
=$
($BABELTRACE_BIN $trace_path |
grep $event_name |
wc -l)
172 if [ "$count" -ne "$nr_iter" ]; then
173 echo -e "$count found in trace \e[1;31mFAILED\e[0m"
176 echo -e "Trace is coherent \e[1;32mOK\e[0m"