3 # Copyright (C) 2019 EfficiOS Inc.
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
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.
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.
19 # This test validates that a `src.ctf.fs` component handles gracefully invalid
20 # CTF traces and produces the expected error message.
24 if [ "x${BT_TESTS_SRCDIR:-}" != "x" ]; then
25 UTILSSH
="$BT_TESTS_SRCDIR/utils/utils.sh"
27 UTILSSH
="$(dirname "$0")/../../../utils/utils.sh"
30 # shellcheck source=../../../utils/utils.sh
33 fail_trace_dir
="$BT_CTF_TRACES_PATH/fail"
35 stdout_file
=$
(mktemp
-t test_ctf_fail_stdout.XXXXXX
)
36 stderr_file
=$
(mktemp
-t test_ctf_fail_stderr.XXXXXX
)
37 data_dir
="${BT_TESTS_SRCDIR}/data/plugins/src.ctf.fs/fail"
41 local expected_stdout_file
="$2"
42 local expected_error_msg
="$3"
44 bt_cli
"${stdout_file}" "${stderr_file}" \
45 -c sink.text.details
-p "with-trace-name=no,with-stream-name=no" "${fail_trace_dir}/${name}"
46 isnt $?
0 "Trace ${name}: babeltrace exits with an error"
48 bt_diff
"${expected_stdout_file}" "${stdout_file}"
49 ok $?
"Trace ${name}: babeltrace produces the expected stdout"
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"
58 grep --silent "${expected_error_msg}" "${stderr_file}"
59 ok $?
"Trace ${name}: babeltrace produces the expected error message"
66 "invalid-packet-size/trace" \
68 "Failed to index CTF stream file '.*channel0_3'"
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"
75 rm -f "${stdout_file}" "${stderr_file}"