Commit | Line | Data |
---|---|---|
e72d66a6 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 | |
c38b5107 | 17 | TEST_DESC="UST tracer - Testing high events throughput" |
e72d66a6 DG |
18 | |
19 | CURDIR=$(dirname $0)/ | |
20 | TESTDIR=$CURDIR/../.. | |
21 | NR_ITER=20 | |
22 | BIN_NAME="gen-events" | |
23 | SESSION_NAME="high-throughput" | |
24 | EVENT_NAME="tp:tptest" | |
25 | ||
26 | source $TESTDIR/utils.sh | |
27 | ||
c38b5107 | 28 | print_test_banner "$TEST_DESC" |
e72d66a6 | 29 | |
8acbe07d | 30 | if [ ! -x "$CURDIR/$BIN_NAME" ]; then |
e72d66a6 DG |
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 | ||
fb3268e3 | 39 | start_lttng_sessiond |
e72d66a6 DG |
40 | |
41 | create_lttng_session $SESSION_NAME $TRACE_PATH | |
42 | ||
43 | enable_ust_lttng_event $SESSION_NAME $EVENT_NAME | |
fb3268e3 | 44 | start_lttng_tracing $SESSION_NAME |
e72d66a6 DG |
45 | |
46 | for i in `seq 1 $NR_ITER`; do | |
47 | ./$CURDIR/$BIN_NAME & >/dev/null 2>&1 | |
48 | done | |
49 | ||
908ee7bd DG |
50 | echo "Waiting for applications to end" |
51 | while [ -n "$(pidof $BIN_NAME)" ]; do | |
52 | echo -n "." | |
53 | sleep 0.5 | |
54 | done | |
55 | echo "" | |
e72d66a6 | 56 | |
fb3268e3 | 57 | stop_lttng_tracing $SESSION_NAME |
e72d66a6 DG |
58 | destroy_lttng_session $SESSION_NAME |
59 | ||
fb3268e3 | 60 | stop_lttng_sessiond |
e72d66a6 DG |
61 | |
62 | # Validate test | |
63 | ||
64 | TEMP_FILE=$(mktemp) | |
65 | TEMP_FILE_2=$(mktemp) | |
66 | ||
67 | traced=$(babeltrace $TRACE_PATH 2>/dev/null | wc -l) | |
68 | babeltrace $TRACE_PATH >/dev/null 2>$TEMP_FILE_2 | |
69 | ||
70 | cat $TEMP_FILE_2 | cut -f4 -d " " >$TEMP_FILE | |
71 | ||
72 | dropped=0 | |
73 | while read line; | |
74 | do | |
75 | let dropped=$dropped+$line | |
76 | done < $TEMP_FILE | |
77 | ||
78 | let total=$dropped+$traced | |
79 | let wanted=$NR_ITER*1000000 | |
80 | ||
81 | if [ $wanted -ne $total ]; then | |
82 | echo -n "Expected $wanted. Dropped $dropped. Recorded $traced. Total $total... " | |
c38b5107 | 83 | print_fail |
e72d66a6 DG |
84 | out=1 |
85 | else | |
86 | echo -n "Expected $wanted. Dropped $dropped. Recorded $traced. Total $total... " | |
c38b5107 | 87 | print_ok |
e72d66a6 DG |
88 | out=0 |
89 | fi | |
90 | ||
91 | rm -rf $TRACE_PATH | |
92 | rm $TEMP_FILE $TEMP_FILE_2 | |
93 | ||
94 | exit $out |