cpp-common/bt2c/fmt.hpp: use `wise_enum::string_type` in `EnableIfIsWiseEnum` definition
[babeltrace.git] / tests / plugins / src.ctf.fs / fail / test-fail.sh
1 #!/bin/bash
2 #
3 # SPDX-License-Identifier: GPL-2.0-only
4 #
5 # Copyright (C) 2019 EfficiOS Inc.
6 #
7
8 # This test validates that a `src.ctf.fs` component handles gracefully invalid
9 # CTF traces and produces the expected error message.
10
11 SH_TAP=1
12
13 if [ -n "${BT_TESTS_SRCDIR:-}" ]; then
14 UTILSSH="$BT_TESTS_SRCDIR/utils/utils.sh"
15 else
16 UTILSSH="$(dirname "$0")/../../../utils/utils.sh"
17 fi
18
19 # shellcheck source=../../../utils/utils.sh
20 source "$UTILSSH"
21
22 fail_trace_dir="$BT_CTF_TRACES_PATH/fail"
23
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"
27
28 test_fail() {
29 local name="$1"
30 local expected_stdout_file="$2"
31 local expected_error_msg="$3"
32
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"
36
37 bt_diff "${expected_stdout_file}" "${stdout_file}"
38 ok $? "Trace ${name}: babeltrace produces the expected stdout"
39
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 bt_grep_ok \
45 "^CAUSED BY " \
46 "$stderr_file" \
47 "Trace $name: babeltrace produces an error stack"
48
49 bt_grep_ok \
50 "$expected_error_msg" \
51 "$stderr_file" \
52 "Trace $name: babeltrace produces the expected error message"
53 }
54
55
56 plan_tests 20
57
58 test_fail \
59 "invalid-packet-size/trace" \
60 "/dev/null" \
61 "Failed to index CTF stream file '.*channel0_3'"
62
63 test_fail \
64 "valid-events-then-invalid-events" \
65 "${data_dir}/valid-events-then-invalid-events.expect" \
66 "No event class with ID of event class ID to use in stream class: .*stream-class-id=0, event-class-id=255"
67
68 test_fail \
69 "metadata-syntax-error" \
70 "/dev/null" \
71 "^ At line 3 in metadata stream: syntax error, unexpected CTF_RSBRAC: token=\"]\""
72
73 test_fail \
74 "invalid-sequence-length-field-class" \
75 "/dev/null" \
76 "Sequence field class's length field class is not an unsigned integer field class: "
77
78 test_fail \
79 "invalid-variant-selector-field-class" \
80 "/dev/null" \
81 "Variant field class's tag field class is not an enumeration field class: "
82
83 rm -f "${stdout_file}" "${stderr_file}"
This page took 0.031212 seconds and 4 git commands to generate.