Fix: src.ctf.fs: initialize the other_entry variable
[babeltrace.git] / tests / plugins / src.ctf.fs / fail / test_fail
CommitLineData
29a8227a
SM
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
22SH_TAP=1
23
24if [ "x${BT_TESTS_SRCDIR:-}" != "x" ]; then
25 UTILSSH="$BT_TESTS_SRCDIR/utils/utils.sh"
26else
27 UTILSSH="$(dirname "$0")/../../../utils/utils.sh"
28fi
29
30# shellcheck source=../../../utils/utils.sh
31source "$UTILSSH"
32
33fail_trace_dir="$BT_CTF_TRACES_PATH/fail"
34
35stdout_file=$(mktemp -t test_ctf_fail_stdout.XXXXXX)
36stderr_file=$(mktemp -t test_ctf_fail_stderr.XXXXXX)
cbca1c06 37data_dir="${BT_TESTS_SRCDIR}/data/plugins/src.ctf.fs/fail"
29a8227a
SM
38
39test_fail() {
40 local name="$1"
cbca1c06
SM
41 local expected_stdout_file="$2"
42 local expected_error_msg="$3"
29a8227a
SM
43
44 bt_cli "${stdout_file}" "${stderr_file}" \
cbca1c06 45 -c sink.text.details -p "with-trace-name=no,with-stream-name=no" "${fail_trace_dir}/${name}"
29a8227a
SM
46 isnt $? 0 "Trace ${name}: babeltrace exits with an error"
47
cbca1c06
SM
48 bt_diff "${expected_stdout_file}" "${stdout_file}"
49 ok $? "Trace ${name}: babeltrace produces the expected stdout"
50
51 # The expected error message will likely be found in the error stream
52 # even if Babeltrace aborts (e.g. hits an assert). Check that the
53 # Babeltrace CLI finishes gracefully by checking that the error stream
54 # contains an error stack printed by the CLI.
55 grep --silent "^CAUSED BY " "${stderr_file}"
56 ok $? "Trace ${name}: babeltrace produces an error stack"
57
29a8227a
SM
58 grep --silent "${expected_error_msg}" "${stderr_file}"
59 ok $? "Trace ${name}: babeltrace produces the expected error message"
60}
61
62
cbca1c06
SM
63plan_tests 8
64
65test_fail \
66 "invalid-packet-size/trace" \
67 "/dev/null" \
68 "Failed to index CTF stream file '.*channel0_3'"
29a8227a 69
cbca1c06
SM
70test_fail \
71 "valid-events-then-invalid-events" \
72 "${data_dir}/valid-events-then-invalid-events.expect" \
73 "No event class with ID of event class ID to use in stream class: .*stream-class-id=0, event-class-id=255"
29a8227a
SM
74
75rm -f "${stdout_file}" "${stderr_file}"
This page took 0.033256 seconds and 4 git commands to generate.