| 1 | #!/bin/bash |
| 2 | # |
| 3 | # Copyright (C) - 2017 Julien Desfossez <jdesfossez@efficios.com> |
| 4 | # |
| 5 | # This program is free software; you can redistribute it and/or modify it |
| 6 | # under the terms of the GNU General Public License, version 2 only, as |
| 7 | # published by the Free Software Foundation. |
| 8 | # |
| 9 | # This program is distributed in the hope that it will be useful, but WITHOUT |
| 10 | # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
| 11 | # FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for |
| 12 | # more details. |
| 13 | # |
| 14 | # You should have received a copy of the GNU General Public License along with |
| 15 | # this program; if not, write to the Free Software Foundation, Inc., 51 |
| 16 | # Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. |
| 17 | |
| 18 | BABELTRACE_BIN=@abs_top_builddir@/cli/babeltrace |
| 19 | |
| 20 | TRACE_PATH=@abs_top_srcdir@/tests/ctf-traces/succeed/wk-heartbeat-u/ |
| 21 | |
| 22 | source @abs_top_srcdir@/tests/utils/tap/tap.sh |
| 23 | |
| 24 | NUM_TESTS=10 |
| 25 | |
| 26 | plan_tests $NUM_TESTS |
| 27 | |
| 28 | tmp_out=$(mktemp) |
| 29 | |
| 30 | $BABELTRACE_BIN --clock-gmt --begin 17:48:17.587029529 --end 17:48:17.588680018 \ |
| 31 | ${TRACE_PATH} >/dev/null 2>&1 |
| 32 | ok $? "Read the trace with the trimmer enabled" |
| 33 | |
| 34 | $BABELTRACE_BIN --clock-gmt --begin 17:48:17.587029529 ${TRACE_PATH} \ |
| 35 | 2>/dev/null >${tmp_out} |
| 36 | ok $? "Running with --begin" |
| 37 | cnt=$(cat ${tmp_out} | wc -l) |
| 38 | test $cnt == 18 |
| 39 | ok $? "Expected number of events after trimming begin and end" |
| 40 | |
| 41 | $BABELTRACE_BIN --clock-gmt --end 17:48:17.588680018 ${TRACE_PATH} \ |
| 42 | 2>/dev/null >${tmp_out} |
| 43 | ok $? "Running with --end" |
| 44 | cnt=$(cat ${tmp_out} | wc -l) |
| 45 | test $cnt == 9 |
| 46 | ok $? "Expected number of events after trimming end" |
| 47 | |
| 48 | $BABELTRACE_BIN --clock-gmt --begin 17:48:17.587029529 --end 17:48:17.588680018 \ |
| 49 | ${TRACE_PATH} 2>/dev/null >${tmp_out} |
| 50 | ok $? "Running with --begin and --end" |
| 51 | cnt=$(cat ${tmp_out} | wc -l) |
| 52 | test $cnt == 7 |
| 53 | ok $? "Expected number of events after trimming begin and end" |
| 54 | |
| 55 | $BABELTRACE_BIN --clock-gmt --begin 18:48:17.587029529 ${TRACE_PATH} \ |
| 56 | 2>/dev/null >${tmp_out} |
| 57 | ok $? "Running with --begin out of range" |
| 58 | cnt=$(cat ${tmp_out} | wc -l) |
| 59 | test $cnt == 0 |
| 60 | ok $? "No event output when begin is after the end of the trace" |
| 61 | |
| 62 | $BABELTRACE_BIN --clock-gmt --end 16:48:17.588680018 ${TRACE_PATH} \ |
| 63 | 2>/dev/null >${tmp_out} |
| 64 | cnt=$(cat ${tmp_out} | wc -l) |
| 65 | test $cnt == 0 |
| 66 | ok $? "No event output when end is before the beginning of the trace" |
| 67 | |
| 68 | rm ${tmp_out} |