Fix tests when lttng-ust is disabled
[lttng-tools.git] / tests / ust / low-throughput / run
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
18 CURDIR=$(dirname $0)/
19 TESTDIR=$CURDIR/../..
20 BIN_NAME="gen-events"
21 SESSION_NAME="low-throughput"
22 EVENT_NAME="tp:slow"
23
24 source $TESTDIR/utils.sh
25
26 echo -e "\n-------------------------------------------"
27 echo -e "UST tracer - Testing low events throughput"
28 echo -e "-------------------------------------------"
29
30 if [ ! -x "$CURDIR/$BIN_NAME" ]; then
31 echo -e "No UST nevents binary detected. Passing."
32 exit 0
33 fi
34
35 TRACE_PATH=$(mktemp -d)
36
37 # MUST set TESTDIR before calling those functions
38
39 start_sessiond
40
41 create_lttng_session $SESSION_NAME $TRACE_PATH
42
43 enable_ust_lttng_event $SESSION_NAME $EVENT_NAME
44 start_tracing $SESSION_NAME
45
46 # This is going to take 20 minutes
47 ./$CURDIR/$BIN_NAME >/dev/null 2>&1
48
49 stop_tracing $SESSION_NAME
50 destroy_lttng_session $SESSION_NAME
51
52 stop_sessiond
53
54 # Validate test
55
56 last_val=0
57 out=0
58
59 babeltrace $TRACE_PATH | while read event;
60 do
61 val=$(echo $event | cut -f10 -d" ")
62 val=${val%?}
63 th=$(echo $event | cut -f13 -d " ")
64
65 if [ $th = '"one"' ]; then
66 ((last_val++))
67 # We expect here a continous value from 1 to 20
68 if [ $last_val -ne $val ]; then
69 echo -n "[-] One minute event failed ($val) "
70 out=1
71 break
72 fi
73 elif [ $th = '"ten"' ]; then
74 # Test 10 minutes counter
75 if [ $val -ne 10 ]; then
76 # Test 20 minutes counter
77 if [ $val -ne 20 ]; then
78 echo -n "[-] Ten minutes event failed ($val) "
79 out=1
80 break
81 fi
82 fi
83 elif [ $th = '"twenty"' ]; then
84 # Test 20 minutes counter
85 if [ $val -ne 20 ]; then
86 echo -n "[-] Twenty minutes event failed ($val) "
87 out=1
88 break
89 fi
90 fi
91 done
92
93 if [ $out -eq 0 ]; then
94 echo -n "Trace is coherent... "
95 echo -e "\e[1;32mOK\e[0m"
96 else
97 echo -e "\e[1;31mFAILED\e[0m"
98 fi
99
100 rm -rf $TRACE_PATH
101
102 exit $out
This page took 0.045899 seconds and 4 git commands to generate.