Wait for all apps in high-throughput test
[lttng-tools.git] / tests / ust / high-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 NR_ITER=20
21 BIN_NAME="gen-events"
22 SESSION_NAME="high-throughput"
23 EVENT_NAME="tp:tptest"
24
25 source $TESTDIR/utils.sh
26
27 echo -e "\n-------------------------------------------"
28 echo -e "UST tracer - Testing high events throughput"
29 echo -e "-------------------------------------------"
30
31 if [ ! -x "$CURDIR/$BIN_NAME" ]; then
32 echo -e "No UST nevents binary detected. Passing."
33 exit 0
34 fi
35
36 TRACE_PATH=$(mktemp -d)
37
38 # MUST set TESTDIR before calling those functions
39
40 start_sessiond
41
42 create_lttng_session $SESSION_NAME $TRACE_PATH
43
44 enable_ust_lttng_event $SESSION_NAME $EVENT_NAME
45 start_tracing $SESSION_NAME
46
47 for i in `seq 1 $NR_ITER`; do
48 ./$CURDIR/$BIN_NAME & >/dev/null 2>&1
49 done
50
51 echo "Waiting for applications to end"
52 while [ -n "$(pidof $BIN_NAME)" ]; do
53 echo -n "."
54 sleep 0.5
55 done
56 echo ""
57
58 stop_tracing $SESSION_NAME
59 destroy_lttng_session $SESSION_NAME
60
61 stop_sessiond
62
63 # Validate test
64
65 TEMP_FILE=$(mktemp)
66 TEMP_FILE_2=$(mktemp)
67
68 traced=$(babeltrace $TRACE_PATH 2>/dev/null | wc -l)
69 babeltrace $TRACE_PATH >/dev/null 2>$TEMP_FILE_2
70
71 cat $TEMP_FILE_2 | cut -f4 -d " " >$TEMP_FILE
72
73 dropped=0
74 while read line;
75 do
76 let dropped=$dropped+$line
77 done < $TEMP_FILE
78
79 let total=$dropped+$traced
80 let wanted=$NR_ITER*1000000
81
82 if [ $wanted -ne $total ]; then
83 echo -n "Expected $wanted. Dropped $dropped. Recorded $traced. Total $total... "
84 echo -e "\e[1;31mFAILED\e[0m"
85 out=1
86 else
87 echo -n "Expected $wanted. Dropped $dropped. Recorded $traced. Total $total... "
88 echo -e "\e[1;32mOK\e[0m"
89 out=0
90 fi
91
92 rm -rf $TRACE_PATH
93 rm $TEMP_FILE $TEMP_FILE_2
94
95 exit $out
This page took 0.031955 seconds and 5 git commands to generate.