3 # SPDX-License-Identifier: GPL-2.0-only
5 # Copyright (C) 2019 Philippe Proulx <pproulx@efficios.com>
8 # This test validates that a `src.ctf.fs` component successfully reads
9 # specific CTF traces and creates the expected messages.
11 # Such CTF traces to open either exist (in `tests/ctf-traces/succeed`)
12 # or are generated by this test using local trace generators.
16 if [ "x${BT_TESTS_SRCDIR:-}" != "x" ]; then
17 UTILSSH
="$BT_TESTS_SRCDIR/utils/utils.sh"
19 UTILSSH
="$(dirname "$0")/../../../utils/utils.sh"
22 # shellcheck source=../../../utils/utils.sh
25 this_dir_relative
="plugins/sink.ctf.fs/succeed"
26 this_dir_build
="$BT_TESTS_BUILDDIR/$this_dir_relative"
27 expect_dir
="$BT_TESTS_DATADIR/$this_dir_relative"
28 succeed_traces
="$BT_CTF_TRACES_PATH/succeed"
32 local in_trace_dir
="$2"
33 local temp_out_trace_dir
35 temp_out_trace_dir
="$(mktemp -d)"
37 diag
"Converting trace '$name' to CTF through 'sink.ctf.fs'"
38 "$BT_TESTS_BT2_BIN" >/dev
/null
"$in_trace_dir" -o ctf
-w "$temp_out_trace_dir"
40 ok
$ret "'sink.ctf.fs' component succeeds with input trace '$name'"
41 converted_test_name
="Converted trace '$name' gives the expected output"
43 if [ $ret -eq 0 ]; then
44 bt_diff_details_ctf_single
"$expect_dir/trace-$name.expect" \
45 "$temp_out_trace_dir" \
46 '-p' 'with-uuid=no,with-trace-name=no,with-stream-name=no'
47 ok $?
"$converted_test_name"
49 fail
"$converted_test_name"
52 rm -rf "$temp_out_trace_dir"
55 test_ctf_existing_single
() {
57 local trace_dir
="$succeed_traces/$name"
59 test_ctf_single
"$name" "$trace_dir"
62 test_ctf_gen_single
() {
64 local temp_gen_trace_dir
66 temp_gen_trace_dir
="$(mktemp -d)"
68 diag
"Generating trace '$name'"
70 if ! "$this_dir_build/gen-trace-$name" "$temp_gen_trace_dir"; then
71 # this is not part of the test itself; it must not fail
72 echo "ERROR: \"$this_dir_build/gen-trace-$name" "$temp_gen_trace_dir\" failed" >&2
73 rm -rf "$temp_gen_trace_dir"
77 test_ctf_single
"$name" "$temp_gen_trace_dir"
78 rm -rf "$temp_gen_trace_dir"
83 test_ctf_gen_single float
84 test_ctf_gen_single double
85 test_ctf_existing_single meta-variant-no-underscore
86 test_ctf_existing_single meta-variant-one-underscore
87 test_ctf_existing_single meta-variant-reserved-keywords
88 test_ctf_existing_single meta-variant-same-with-underscore
89 test_ctf_existing_single meta-variant-two-underscores