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