Add UST test for n events using validation
[lttng-tools.git] / tests / utils.sh
CommitLineData
d3e8f6bb
DG
1#!/bin/bash
2#
3# Copyright (C) - 2012 David Goulet <dgoulet@efficios.com>
4#
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.
8#
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
12# details.
13#
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
17
18SESSIOND_BIN="lttng-sessiond"
19LTTNG_BIN="lttng"
20BABELTRACE_BIN="babeltrace"
21
22function start_sessiond ()
23{
24 if [ -z $(pidof $SESSIOND_BIN) ]; then
25 echo -n "Starting session daemon... "
26 $TESTDIR/../lttng-sessiond/$SESSIOND_BIN --daemonize --quiet
27 if [ $? -eq 1 ]; then
28 echo -e "\e[1;31mFAILED\e[0m"
29 return 1
30 else
31 echo -e "\e[1;32mOK\e[0m"
32 fi
33 fi
34}
35
36function stop_sessiond ()
37{
38 PID_SESSIOND=`pidof lt-$SESSIOND_BIN`
39
40 echo -e -n "Killing session daemon... "
41 kill $PID_SESSIOND >/dev/null 2>&1
42 if [ $? -eq 1 ]; then
43 echo -e "\e[1;31mFAILED\e[0m"
44 return 1
45 else
46 echo -e "\e[1;32mOK\e[0m"
47 fi
48}
49
50function create_lttng_session ()
51{
52 sess_name=$1
53 trace_path=$2
54
55 echo -n "Creating lttng session $SESSION_NAME in $TRACE_PATH "
56 $TESTDIR/../lttng/$LTTNG_BIN create $sess_name -o $trace_path >/dev/null 2>&1
57 if [ $? -eq 1 ]; then
58 echo -e "\e[1;31mFAILED\e[0m"
59 return 1
60 else
61 echo -e "\e[1;32mOK\e[0m"
62 #echo $out | grep "written in" | cut -d' ' -f6
63 fi
64}
65
66function enable_ust_lttng_event ()
67{
68 sess_name=$1
69 event_name=$2
70
71 echo -n "Enabling lttng event $event_name for session $sess_name "
72 $TESTDIR/../lttng/$LTTNG_BIN enable-event $event_name -s $sess_name -u >/dev/null 2>&1
73 if [ $? -eq 1 ]; then
74 echo -e '\e[1;31mFAILED\e[0m'
75 return 1
76 else
77 echo -e "\e[1;32mOK\e[0m"
78 fi
79}
80
81function start_tracing ()
82{
83 sess_name=$1
84
85 echo -n "Start lttng tracing for session $sess_name "
86 $TESTDIR/../lttng/$LTTNG_BIN start $sess_name >/dev/null 2>&1
87 if [ $? -eq 1 ]; then
88 echo -e '\e[1;31mFAILED\e[0m'
89 return 1
90 else
91 echo -e "\e[1;32mOK\e[0m"
92 fi
93}
94
95function stop_tracing ()
96{
97 sess_name=$1
98
99 echo -n "Stop lttng tracing for session $sess_name "
100 $TESTDIR/../lttng/$LTTNG_BIN stop $sess_name >/dev/null 2>&1
101 if [ $? -eq 1 ]; then
102 echo -e '\e[1;31mFAILED\e[0m'
103 return 1
104 else
105 echo -e "\e[1;32mOK\e[0m"
106 fi
107}
108
109function destroy_lttng_session ()
110{
111 sess_name=$1
112
113 echo -n "Destroy lttng session $sess_name "
114 $TESTDIR/../lttng/$LTTNG_BIN destroy $sess_name >/dev/null 2>&1
115 if [ $? -eq 1 ]; then
116 echo -e '\e[1;31mFAILED\e[0m'
117 return 1
118 else
119 echo -e "\e[1;32mOK\e[0m"
120 fi
121}
122
123function trace_matches ()
124{
125 event_name=$1
126 nr_iter=$2
127 trace_path=$3
128
129 echo -n "Looking for $nr_iter $event_name in $trace_path "
130
131 count=$($BABELTRACE_BIN $trace_path | grep $event_name | wc -l)
132 if [ "$count" -ne "$nr_iter" ]; then
133 echo -e "$count found in trace \e[1;31mFAILED\e[0m"
134 return 1
135 else
136 echo -e "Trace is coherent \e[1;32mOK\e[0m"
137 return 0
138 fi
139}
This page took 0.031864 seconds and 4 git commands to generate.