3 # SPDX-License-Identifier: GPL-2.0-only
5 # Copyright (C) 2019 Efficios, Inc.
8 # Test the deterministic behavior of the src.ctf.fs component versus the
9 # ordering of the given input paths.
11 # In presence of multiple copies of the same packet, we want it to pick the
12 # copy of the packet to read in a deterministic fashion.
14 # This test is written assuming the specific implementation of the src.ctf.fs
15 # component class, which sorts its input paths lexicographically.
17 # There are three traces (a-corrupted, b-not-corrupted and c-corrupted) with the
18 # same UUID and the same packet, except that this packet is corrupted in
19 # a-corrupted and c-corrupted. In these cases, there is an event with an
20 # invalid id. When reading these corrupted packets, we expect babeltrace to
23 # When reading a-corrupted and b-not-corrupted together, the copy of the packet
24 # from a-corrupted is read, and babeltrace exits with an error.
26 # When reading b-not-corrupted and c-corrupted together, the copy of the packet
27 # from b-not-corrupted is read, and babeltrace executes successfully.
31 if [ -n "${BT_TESTS_SRCDIR:-}" ]; then
32 UTILSSH
="$BT_TESTS_SRCDIR/utils/utils.sh"
34 UTILSSH
="$(dirname "$0")/../../utils/utils.sh"
37 # shellcheck source=../../utils/utils.sh
40 traces_dir
="${BT_CTF_TRACES_PATH}/deterministic-ordering"
41 trace_a_corrupted
="${traces_dir}/a-corrupted"
42 trace_b_not_corrupted
="${traces_dir}/b-not-corrupted"
43 trace_c_corrupted
="${traces_dir}/c-corrupted"
45 if [ "$BT_TESTS_OS_TYPE" = "mingw" ]; then
46 # The MSYS2 shell makes a mess trying to convert the Unix-like paths
47 # to Windows-like paths, so just disable the automatic conversion and
49 export MSYS2_ARG_CONV_EXCL
="*"
50 trace_a_corrupted
=$
(cygpath
-m "${trace_a_corrupted}")
51 trace_b_not_corrupted
=$
(cygpath
-m "${trace_b_not_corrupted}")
52 trace_c_corrupted
=$
(cygpath
-m "${trace_c_corrupted}")
55 stdout_file
=$
(mktemp
-t test_deterministic_ordering_stdout.XXXXXX
)
56 stderr_file
=$
(mktemp
-t test_deterministic_ordering_stderr.XXXXXX
)
65 bt_cli
"${stdout_file}" "${stderr_file}" \
66 -c src.ctf.fs
-p "inputs=[${inputs}]"
67 isnt
0 "$?" "${test_name}: exit status is not 0"
69 grep --silent "^ERROR: " "${stderr_file}"
70 ok
"$?" "${test_name}: error stack is produced"
72 grep --silent "No event class with ID of event class ID to use in stream class" "${stderr_file}"
73 ok
"$?" "${test_name}: expected error message is present"
83 bt_cli
"${stdout_file}" "${stderr_file}" \
84 -c src.ctf.fs
-p "inputs=[${inputs}]" \
85 -c sink.text.details
-p 'with-trace-name=no,with-stream-name=no,with-metadata=no,compact=yes'
86 ok
"$?" "${test_name}: exit status is 0"
88 bt_diff
"${traces_dir}/b-c.expect" "${stdout_file}"
89 ok
"$?" "${test_name}: expected output is produced"
94 # Trace with corrupted packet comes first lexicographically, expect a failure.
96 expect_failure
"ab" "\"${trace_a_corrupted}\",\"${trace_b_not_corrupted}\""
97 expect_failure
"ba" "\"${trace_b_not_corrupted}\",\"${trace_a_corrupted}\""
99 # Trace with non-corrupted packet comes first lexicographically, expect a success.
101 expect_success
"bc" "\"${trace_b_not_corrupted}\",\"${trace_c_corrupted}\""
102 expect_success
"cb" "\"${trace_c_corrupted}\",\"${trace_b_not_corrupted}\""
104 rm -f "${stdout_file}" "${stderr_file}"