Fix: src.ctf.fs: initialize the other_entry variable
[babeltrace.git] / tests / plugins / src.ctf.fs / test_deterministic_ordering
CommitLineData
7b69723d
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# Test the deterministic behavior of the src.ctf.fs component versus the
20# ordering of the given input paths.
21#
22# In presence of multiple copies of the same packet, we want it to pick the
23# copy of the packet to read in a deterministic fashion.
24#
25# This test is written assuming the specific implementation of the src.ctf.fs
26# component class, which sorts its input paths lexicographically.
27#
28# There are three traces (a-corrupted, b-not-corrupted and c-corrupted) with the
29# same UUID and the same packet, except that this packet is corrupted in
30# a-corrupted and c-corrupted. In these cases, there is an event with an
31# invalid id. When reading these corrupted packets, we expect babeltrace to
32# emit an error.
33#
34# When reading a-corrupted and b-not-corrupted together, the copy of the packet
35# from a-corrupted is read, and babeltrace exits with an error.
36#
37# When reading b-not-corrupted and c-corrupted together, the copy of the packet
38# from b-not-corrupted is read, and babeltrace executes successfully.
39
40SH_TAP=1
41
42if [ "x${BT_TESTS_SRCDIR:-}" != "x" ]; then
43 UTILSSH="$BT_TESTS_SRCDIR/utils/utils.sh"
44else
45 UTILSSH="$(dirname "$0")/../../utils/utils.sh"
46fi
47
26ab3283 48# shellcheck source=../../utils/utils.sh
7b69723d
SM
49source "$UTILSSH"
50
51traces_dir="${BT_CTF_TRACES_PATH}/deterministic-ordering"
52trace_a_corrupted="${traces_dir}/a-corrupted"
53trace_b_not_corrupted="${traces_dir}/b-not-corrupted"
54trace_c_corrupted="${traces_dir}/c-corrupted"
55
56if [ "$BT_OS_TYPE" = "mingw" ]; then
57 # The MSYS2 shell makes a mess trying to convert the Unix-like paths
58 # to Windows-like paths, so just disable the automatic conversion and
59 # do it by hand.
60 export MSYS2_ARG_CONV_EXCL="*"
61 trace_a_corrupted=$(cygpath -m "${trace_a_corrupted}")
62 trace_b_not_corrupted=$(cygpath -m "${trace_b_not_corrupted}")
63 trace_c_corrupted=$(cygpath -m "${trace_c_corrupted}")
64fi
65
66stdout_file=$(mktemp -t test_deterministic_ordering_stdout.XXXXXX)
67stderr_file=$(mktemp -t test_deterministic_ordering_stderr.XXXXXX)
68
69expect_failure() {
70 local test_name
71 local inputs
72
73 test_name="$1"
74 inputs="$2"
75
76 bt_cli "${stdout_file}" "${stderr_file}" \
77 -c src.ctf.fs -p "inputs=[${inputs}]"
78 isnt 0 "$?" "${test_name}: exit status is not 0"
79
80 grep --silent "^ERROR: " "${stderr_file}"
81 ok "$?" "${test_name}: error stack is produced"
82
83 grep --silent "No event class with ID of event class ID to use in stream class" "${stderr_file}"
84 ok "$?" "${test_name}: expected error message is present"
85}
86
87expect_success() {
88 local test_name
89 local inputs
90
91 test_name="$1"
92 inputs="$2"
93
94 bt_cli "${stdout_file}" "${stderr_file}" \
95 -c src.ctf.fs -p "inputs=[${inputs}]" \
96 -c sink.text.details -p 'with-trace-name=no,with-stream-name=no,with-metadata=no,compact=yes'
97 ok "$?" "${test_name}: exit status is 0"
98
99 bt_diff "${traces_dir}/b-c.expect" "${stdout_file}"
100 ok "$?" "${test_name}: expected output is produced"
101}
102
103plan_tests 10
104
105# Trace with corrupted packet comes first lexicographically, expect a failure.
106
107expect_failure "ab" "\"${trace_a_corrupted}\",\"${trace_b_not_corrupted}\""
108expect_failure "ba" "\"${trace_b_not_corrupted}\",\"${trace_a_corrupted}\""
109
110# Trace with non-corrupted packet comes first lexicographically, expect a success.
111
112expect_success "bc" "\"${trace_b_not_corrupted}\",\"${trace_c_corrupted}\""
113expect_success "cb" "\"${trace_c_corrupted}\",\"${trace_b_not_corrupted}\""
114
115rm -f "${stdout_file}" "${stderr_file}"
This page took 0.030527 seconds and 4 git commands to generate.