tests: Use diff -u
[babeltrace.git] / tests / cli / test_trimmer
CommitLineData
e5a54f3f
JD
1#!/bin/bash
2#
644e0364 3# Copyright (C) 2017 Julien Desfossez <jdesfossez@efficios.com>
e5a54f3f
JD
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
644e0364
MJ
18SH_TAP=1
19
20if [ "x${BT_TESTS_SRCDIR:-}" != "x" ]; then
21 UTILSSH="$BT_TESTS_SRCDIR/utils/utils.sh"
22else
23 UTILSSH="$(dirname "$0")/../utils/utils.sh"
24fi
25
26# shellcheck source=../utils/utils.sh
27source "$UTILSSH"
e5a54f3f 28
bbff0ab4 29TRACE_PATH="${BT_CTF_TRACES_PATH}/succeed/wk-heartbeat-u/"
e5a54f3f 30
93fb46c6 31NUM_TESTS=40
e5a54f3f
JD
32
33plan_tests $NUM_TESTS
34
35tmp_out=$(mktemp)
36
93fb46c6
SM
37# Run Babeltrace with some command line arguments, verify exit status and
38# number of output events (i.e. number of output lines)
39#
40# Arguments:
41#
42# $1: expected number of events
43# $2: test description
44# remaining arguments: command-line arguments to pass to Babeltrace
45
46function expect_success()
47{
48 local expected_num_events="$1"
49 shift
50 local msg="$1"
51 shift
52
644e0364 53 "${BT_TESTS_BT2_BIN}" "${TRACE_PATH}" "$@" 2>/dev/null > "${tmp_out}"
93fb46c6
SM
54 ok $? "trimmer: ${msg}: exit status"
55 num_events=$(wc -l < "${tmp_out}")
891c35e4
MJ
56 # Use bash parameter expansion to strip spaces added by BSD 'wc' on macOs and Solaris
57 is "${num_events// /}" "${expected_num_events}" "trimmer: ${msg}: number of events (${expected_num_events})"
93fb46c6
SM
58}
59
60expect_success 18 "--begin, GMT relative timestamps" \
61 --clock-gmt --begin 17:48:17.587029529
62expect_success 9 "--end, GMT relative timestamps" \
63 --clock-gmt --end 17:48:17.588680018
64expect_success 7 "--begin and --end, GMT relative timestamps" \
65 --clock-gmt --begin 17:48:17.587029529 --end 17:48:17.588680018
66expect_success 0 "--begin, out of range, GMT relative timestamps" \
67 --clock-gmt --begin 18:48:17.587029529
68expect_success 0 "--end, out of range, GMT relative timestamps" \
69 --clock-gmt --end 16:48:17.588680018
70
71expect_success 18 "--begin, GMT absolute timestamps" \
72 --clock-gmt --begin "2012-10-29 17:48:17.587029529"
73expect_success 9 "--end, GMT absolute timestamps" \
74 --clock-gmt --end "2012-10-29 17:48:17.588680018"
75expect_success 7 "--begin and --end, GMT absolute timestamps" \
76 --clock-gmt --begin "2012-10-29 17:48:17.587029529" --end "2012-10-29 17:48:17.588680018"
77expect_success 0 "--begin, out of range, GMT absolute timestamps" \
78 --clock-gmt --begin "2012-10-29 18:48:17.587029529"
79expect_success 0 "--begin, out of range, GMT absolute timestamps" \
80 --clock-gmt --end "2012-10-29 16:48:17.588680018"
95abf2a0
MJ
81
82export TZ=EST
83
93fb46c6
SM
84expect_success 18 "--begin, EST relative timestamps" \
85 --begin "12:48:17.587029529"
86expect_success 9 "--end, EST relative timestamps" \
87 --end "12:48:17.588680018"
88expect_success 7 "--begin and --end, EST relative timestamps" \
89 --begin "12:48:17.587029529" --end "12:48:17.588680018"
90expect_success 0 "--begin, out of range, EST relative timestamps" \
91 --begin "13:48:17.587029529"
92expect_success 0 "--end, out of range, EST relative timestamps" \
93 --end "11:48:17.588680018"
94
95expect_success 18 "--begin, EST absolute timestamps" \
96 --begin "2012-10-29 12:48:17.587029529"
97expect_success 9 "--end, EST absolute timestamps" \
98 --end "12:48:17.588680018"
99expect_success 7 "--begin and --end, EST absolute timestamps" \
100 --begin "2012-10-29 12:48:17.587029529" --end "2012-10-29 12:48:17.588680018"
101expect_success 0 "--begin, out of range, EST absolute timestamps" \
102 --begin "2012-10-29 13:48:17.587029529"
103expect_success 0 "--end, out of range, EST absolute timestamps" \
104 --end "2012-10-29 11:48:17.588680018"
e5a54f3f 105
03f007c8 106rm "${tmp_out}"
This page took 0.039972 seconds and 4 git commands to generate.