Fix: Replace bt_timegm with a thread-safe implementation
[babeltrace.git] / tests / cli / test_trimmer.in
CommitLineData
0c305c6e
JD
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
d8e292d4 18. "@abs_top_builddir@/tests/utils/common.sh"
0c305c6e 19
de3fb4cd 20TRACE_PATH="${BT_CTF_TRACES}/succeed/wk-heartbeat-u/"
0c305c6e 21
bcd785aa 22NUM_TESTS=44
0c305c6e
JD
23
24plan_tests $NUM_TESTS
25
26tmp_out=$(mktemp)
27
de3fb4cd
MJ
28"${BT_BIN}" --clock-gmt --begin 17:48:17.587029529 --end 17:48:17.588680018 \
29 "${TRACE_PATH}" >/dev/null 2>&1
bcd785aa 30ok $? "Read a trace with the trimmer enabled (GMT relative timestamps)"
0c305c6e 31
de3fb4cd
MJ
32"${BT_BIN}" --clock-gmt --begin 17:48:17.587029529 "${TRACE_PATH}" \
33 2>/dev/null >"${tmp_out}"
bcd785aa 34ok $? "Ran successfully with --begin (GMT relative timestamps)"
de3fb4cd 35cnt=$(wc -l < "${tmp_out}")
3119de00 36test $cnt == 18
bcd785aa 37ok $? "Received ${cnt}/18 events (GMT relative timestamps)"
0c305c6e 38
de3fb4cd
MJ
39"${BT_BIN}" --clock-gmt --end 17:48:17.588680018 "${TRACE_PATH}" \
40 2>/dev/null >"${tmp_out}"
bcd785aa 41ok $? "Ran successfully with --end (GMT relative timestamps)"
de3fb4cd 42cnt=$(wc -l < "${tmp_out}")
3119de00 43test $cnt == 9
bcd785aa 44ok $? "Received ${cnt}/9 events (GMT relative timestamps)"
0c305c6e 45
de3fb4cd
MJ
46"${BT_BIN}" --clock-gmt --begin 17:48:17.587029529 --end 17:48:17.588680018 \
47 "${TRACE_PATH}" 2>/dev/null >"${tmp_out}"
bcd785aa 48ok $? "Ran successfully with --begin and --end (GMT relative timestamps)"
de3fb4cd 49cnt=$(wc -l < "${tmp_out}")
3119de00 50test $cnt == 7
bcd785aa 51ok $? "Received ${cnt}/7 events (GMT relative timestamps)"
0c305c6e 52
de3fb4cd
MJ
53"${BT_BIN}" --clock-gmt --begin 18:48:17.587029529 "${TRACE_PATH}" \
54 2>/dev/null >"${tmp_out}"
bcd785aa 55ok $? "Ran successfully with --begin out of range (GMT relative timestamps)"
de3fb4cd 56cnt=$(wc -l < "${tmp_out}")
3119de00 57test $cnt == 0
bcd785aa 58ok $? "No events when begin is out of range (GMT relative timestamps)"
0c305c6e 59
de3fb4cd
MJ
60"${BT_BIN}" --clock-gmt --end 16:48:17.588680018 "${TRACE_PATH}" \
61 2>/dev/null >"${tmp_out}"
bcd785aa 62ok $? "Ran successfully with --end out of range (GMT relative timestamps)"
de3fb4cd 63cnt=$(wc -l < "${tmp_out}")
3119de00 64test $cnt == 0
bcd785aa
MJ
65ok $? "No events when end is out of range (GMT relative timestamps)"
66
67
68"${BT_BIN}" --clock-gmt --begin "2012-10-29 17:48:17.587029529" --end "2012-10-29 17:48:17.588680018" \
69 "${TRACE_PATH}" >/dev/null 2>&1
70ok $? "Read a trace with the trimmer enabled (GMT absolute timestamps)"
71
72"${BT_BIN}" --clock-gmt --begin "2012-10-29 17:48:17.587029529" "${TRACE_PATH}" \
73 2>/dev/null >"${tmp_out}"
74ok $? "Ran successfully with --begin (GMT absolute timestamps)"
75cnt=$(wc -l < "${tmp_out}")
76test $cnt == 18
77ok $? "Received ${cnt}/18 events (GMT absolute timestamps)"
78
79"${BT_BIN}" --clock-gmt --end "2012-10-29 17:48:17.588680018" "${TRACE_PATH}" \
80 2>/dev/null >"${tmp_out}"
81ok $? "Ran successfully with --end (GMT absolute timestamps)"
82cnt=$(wc -l < "${tmp_out}")
83test $cnt == 9
84ok $? "Received ${cnt}/9 events (GMT absolute timestamps)"
85
86"${BT_BIN}" --clock-gmt --begin "2012-10-29 17:48:17.587029529" --end "2012-10-29 17:48:17.588680018" \
87 "${TRACE_PATH}" 2>/dev/null >"${tmp_out}"
88ok $? "Ran successfully with --begin and --end (GMT absolute timestamps)"
89cnt=$(wc -l < "${tmp_out}")
90test $cnt == 7
91ok $? "Received ${cnt}/7 events (GMT absolute timestamps)"
92
93"${BT_BIN}" --clock-gmt --begin "2012-10-29 18:48:17.587029529" "${TRACE_PATH}" \
94 2>/dev/null >"${tmp_out}"
95ok $? "Ran successfully with --begin out of range (GMT absolute timestamps)"
96cnt=$(wc -l < "${tmp_out}")
97test $cnt == 0
98ok $? "No events when begin is out of range (GMT absolute timestamps)"
99
100"${BT_BIN}" --clock-gmt --end "2012-10-29 16:48:17.588680018" "${TRACE_PATH}" \
101 2>/dev/null >"${tmp_out}"
102ok $? "Ran successfully with --end out of range (GMT absolute timestamps)"
103cnt=$(wc -l < "${tmp_out}")
104test $cnt == 0
105ok $? "No events when end is out of range (GMT absolute timestamps)"
106
107
108export TZ=EST
109
110"${BT_BIN}" --begin "12:48:17.587029529" --end "12:48:17.588680018" \
111 "${TRACE_PATH}" >/dev/null 2>&1
112ok $? "Read a trace with the trimmer enabled (EST relative timestamps)"
113
114"${BT_BIN}" --begin "12:48:17.587029529" "${TRACE_PATH}" \
115 2>/dev/null >"${tmp_out}"
116ok $? "Ran successfully with --begin (EST relative timestamps)"
117cnt=$(wc -l < "${tmp_out}")
118test $cnt == 18
119ok $? "Received ${cnt}/18 events (EST relative timestamps)"
120
121"${BT_BIN}" --end "12:48:17.588680018" "${TRACE_PATH}" \
122 2>/dev/null >"${tmp_out}"
123ok $? "Ran successfully with --end (EST relative timestamps)"
124cnt=$(wc -l < "${tmp_out}")
125test $cnt == 9
126ok $? "Received ${cnt}/9 events (EST relative timestamps)"
127
128"${BT_BIN}" --begin "12:48:17.587029529" --end "12:48:17.588680018" \
129 "${TRACE_PATH}" 2>/dev/null >"${tmp_out}"
130ok $? "Ran successfully with --begin and --end (EST relative timestamps)"
131cnt=$(wc -l < "${tmp_out}")
132test $cnt == 7
133ok $? "Received ${cnt}/7 events (EST relative timestamps)"
134
135"${BT_BIN}" --begin "13:48:17.587029529" "${TRACE_PATH}" \
136 2>/dev/null >"${tmp_out}"
137ok $? "Ran successfully with --begin out of range (EST relative timestamps)"
138cnt=$(wc -l < "${tmp_out}")
139test $cnt == 0
140ok $? "No events when begin is out of range (EST relative timestamps)"
141
142"${BT_BIN}" --end "11:48:17.588680018" "${TRACE_PATH}" \
143 2>/dev/null >"${tmp_out}"
144ok $? "Ran successfully with --end out of range (EST relative timestamps)"
145cnt=$(wc -l < "${tmp_out}")
146test $cnt == 0
147ok $? "No events when end is out of range (EST relative timestamps)"
148
149
150"${BT_BIN}" --begin "2012-10-29 12:48:17.587029529" --end "2012-10-29 12:48:17.588680018" \
151 "${TRACE_PATH}" >/dev/null 2>&1
152ok $? "Read a trace with the trimmer enabled (EST absolute timestamps)"
153
154"${BT_BIN}" --begin "2012-10-29 12:48:17.587029529" "${TRACE_PATH}" \
155 2>/dev/null >"${tmp_out}"
156ok $? "Ran successfully with --begin (EST absolute timestamps)"
157cnt=$(wc -l < "${tmp_out}")
158test $cnt == 18
159ok $? "Received ${cnt}/18 events (EST absolute timestamps)"
160
161"${BT_BIN}" --end "2012-10-29 12:48:17.588680018" "${TRACE_PATH}" \
162 2>/dev/null >"${tmp_out}"
163ok $? "Ran successfully with --end (EST absolute timestamps)"
164cnt=$(wc -l < "${tmp_out}")
165test $cnt == 9
166ok $? "Received ${cnt}/9 events (EST absolute timestamps)"
167
168"${BT_BIN}" --begin "2012-10-29 12:48:17.587029529" --end "2012-10-29 12:48:17.588680018" \
169 "${TRACE_PATH}" 2>/dev/null >"${tmp_out}"
170ok $? "Ran successfully with --begin and --end (EST absolute timestamps)"
171cnt=$(wc -l < "${tmp_out}")
172test $cnt == 7
173ok $? "Received ${cnt}/7 events (EST absolute timestamps)"
174
175"${BT_BIN}" --begin "2012-10-29 13:48:17.587029529" "${TRACE_PATH}" \
176 2>/dev/null >"${tmp_out}"
177ok $? "Ran successfully with --begin out of range (EST absolute timestamps)"
178cnt=$(wc -l < "${tmp_out}")
179test $cnt == 0
180ok $? "No events when begin is out of range (EST absolute timestamps)"
181
182"${BT_BIN}" --end "2012-10-29 11:48:17.588680018" "${TRACE_PATH}" \
183 2>/dev/null >"${tmp_out}"
184ok $? "Ran successfully with --end out of range (EST absolute timestamps)"
185cnt=$(wc -l < "${tmp_out}")
186test $cnt == 0
187ok $? "No events when end is out of range (EST absolute timestamps)"
0c305c6e 188
de3fb4cd 189rm "${tmp_out}"
This page took 0.033323 seconds and 4 git commands to generate.