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 $SESSION_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"
122 #echo $out | grep "written in" | cut -d' ' -f6
126 function enable_ust_lttng_event
()
131 echo -n "Enabling lttng event $event_name for session $sess_name "
132 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN enable-event
$event_name -s $sess_name -u >/dev
/null
2>&1
133 if [ $?
-eq 1 ]; then
134 echo -e '\e[1;31mFAILED\e[0m'
137 echo -e "\e[1;32mOK\e[0m"
141 function start_tracing
()
145 echo -n "Start lttng tracing for session $sess_name "
146 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN start
$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 stop_tracing
()
159 echo -n "Stop lttng tracing for session $sess_name "
160 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN stop
$sess_name >/dev
/null
2>&1
161 if [ $?
-eq 1 ]; then
162 echo -e '\e[1;31mFAILED\e[0m'
165 echo -e "\e[1;32mOK\e[0m"
169 function destroy_lttng_session
()
173 echo -n "Destroy lttng session $sess_name "
174 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN destroy
$sess_name >/dev
/null
2>&1
175 if [ $?
-eq 1 ]; then
176 echo -e '\e[1;31mFAILED\e[0m'
179 echo -e "\e[1;32mOK\e[0m"
183 function trace_matches
()
189 which $BABELTRACE_BIN >/dev
/null
190 if [ $?
-eq 1 ]; then
191 echo "Babeltrace binary not found. Skipping trace matches"
195 echo -n "Looking for $nr_iter $event_name in $trace_path "
197 count
=$
($BABELTRACE_BIN $trace_path |
grep $event_name |
wc -l)
198 if [ "$count" -ne "$nr_iter" ]; then
199 echo -e "$count found in trace \e[1;31mFAILED\e[0m"
202 echo -e "Trace is coherent \e[1;32mOK\e[0m"