src.ctf.fs: error out when failing to create index
[babeltrace.git] / tests / plugins / src.ctf.fs / fail / test_fail
1 #!/bin/bash
2 #
3 # Copyright (C) 2019 EfficiOS Inc.
4 #
5 # This program is free software; you can redistribute it and/or
6 # modify it under the terms of the GNU General Public License
7 # as published by the Free Software Foundation; only version 2
8 # of the License.
9 #
10 # This program is distributed in the hope that it will be useful,
11 # but WITHOUT ANY WARRANTY; without even the implied warranty of
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 # GNU General Public License for more details.
14 #
15 # You should have received a copy of the GNU General Public License
16 # along with this program; if not, write to the Free Software
17 # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18
19 # This test validates that a `src.ctf.fs` component handles gracefully invalid
20 # CTF traces and produces the expected error message.
21
22 SH_TAP=1
23
24 if [ "x${BT_TESTS_SRCDIR:-}" != "x" ]; then
25 UTILSSH="$BT_TESTS_SRCDIR/utils/utils.sh"
26 else
27 UTILSSH="$(dirname "$0")/../../../utils/utils.sh"
28 fi
29
30 # shellcheck source=../../../utils/utils.sh
31 source "$UTILSSH"
32
33 fail_trace_dir="$BT_CTF_TRACES_PATH/fail"
34
35 stdout_file=$(mktemp -t test_ctf_fail_stdout.XXXXXX)
36 stderr_file=$(mktemp -t test_ctf_fail_stderr.XXXXXX)
37
38 test_fail() {
39 local name="$1"
40 local expected_error_msg="$2"
41
42 bt_cli "${stdout_file}" "${stderr_file}" \
43 "${fail_trace_dir}/${name}"
44 isnt $? 0 "Trace ${name}: babeltrace exits with an error"
45
46 grep --silent "${expected_error_msg}" "${stderr_file}"
47 ok $? "Trace ${name}: babeltrace produces the expected error message"
48 }
49
50
51 plan_tests 2
52
53 test_fail "invalid-packet-size/trace" "Failed to index CTF stream file '.*channel0_3'"
54
55 rm -f "${stdout_file}" "${stderr_file}"
This page took 0.032515 seconds and 4 git commands to generate.