3 # SPDX-License-Identifier: GPL-2.0-only
5 # Copyright (C) 2019 EfficiOS Inc.
8 # This test validates that a `src.ctf.fs` component handles gracefully invalid
9 # CTF traces and produces the expected error message.
13 if [ -n "${BT_TESTS_SRCDIR:-}" ]; then
14 UTILSSH
="$BT_TESTS_SRCDIR/utils/utils.sh"
16 UTILSSH
="$(dirname "$0")/../../../utils/utils.sh"
19 # shellcheck source=../../../utils/utils.sh
22 fail_trace_dir
="$BT_CTF_TRACES_PATH/fail"
24 stdout_file
=$
(mktemp
-t test_ctf_fail_stdout.XXXXXX
)
25 stderr_file
=$
(mktemp
-t test_ctf_fail_stderr.XXXXXX
)
26 data_dir
="${BT_TESTS_SRCDIR}/data/plugins/src.ctf.fs/fail"
30 local expected_stdout_file
="$2"
31 local expected_error_msg
="$3"
33 bt_cli
"${stdout_file}" "${stderr_file}" \
34 -c sink.text.details
-p "with-trace-name=no,with-stream-name=no" "${fail_trace_dir}/${name}"
35 isnt $?
0 "Trace ${name}: babeltrace exits with an error"
37 bt_diff
"${expected_stdout_file}" "${stdout_file}"
38 ok $?
"Trace ${name}: babeltrace produces the expected stdout"
40 # The expected error message will likely be found in the error stream
41 # even if Babeltrace aborts (e.g. hits an assert). Check that the
42 # Babeltrace CLI finishes gracefully by checking that the error stream
43 # contains an error stack printed by the CLI.
44 grep --silent "^CAUSED BY " "${stderr_file}"
45 ok $?
"Trace ${name}: babeltrace produces an error stack"
47 grep --silent "${expected_error_msg}" "${stderr_file}"
48 ok $?
"Trace ${name}: babeltrace produces the expected error message"
55 "invalid-packet-size/trace" \
57 "Failed to index CTF stream file '.*channel0_3'"
60 "valid-events-then-invalid-events" \
61 "${data_dir}/valid-events-then-invalid-events.expect" \
62 "No event class with ID of event class ID to use in stream class: .*stream-class-id=0, event-class-id=255"
65 "metadata-syntax-error" \
67 "^ At line 3 in metadata stream: syntax error, unexpected CTF_RSBRAC: token=\"]\""
70 "invalid-sequence-length-field-class" \
72 "Sequence field class's length field class is not an unsigned integer field class: "
75 "invalid-variant-selector-field-class" \
77 "Variant field class's tag field class is not an enumeration field class: "
79 rm -f "${stdout_file}" "${stderr_file}"