tests: fix shellcheck warnings in plugins/flt.lttng-utils.debug-info/test_succeed
[babeltrace.git] / tests / plugins / flt.lttng-utils.debug-info / test_succeed
CommitLineData
d3765576
FD
1#!/bin/bash
2#
3# Copyright (C) 2019 Philippe Proulx <pproulx@efficios.com>
4# Copyright (C) 2019 Francis Deslauriers <francis.deslauriers@efficios.com>
5#
6# This program is free software; you can redistribute it and/or
7# modify it under the terms of the GNU General Public License
8# as published by the Free Software Foundation; only version 2
9# of the License.
10#
11# This program is distributed in the hope that it will be useful,
12# but WITHOUT ANY WARRANTY; without even the implied warranty of
13# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14# GNU General Public License for more details.
15#
16# You should have received a copy of the GNU General Public License
17# along with this program; if not, write to the Free Software
18# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
19
20# This test validates that a `src.ctf.fs` component successfully reads
21# specific CTF traces and creates the expected messages.
22#
23# Such CTF traces to open either exist (in `tests/ctf-traces/succeed`)
24# or are generated by this test using local trace generators.
25
26SH_TAP=1
27
28if [ "x${BT_TESTS_SRCDIR:-}" != "x" ]; then
29 UTILSSH="$BT_TESTS_SRCDIR/utils/utils.sh"
30else
31 UTILSSH="$(dirname "$0")/../../utils/utils.sh"
32fi
33
ce0098bd 34# shellcheck source=../../utils/utils.sh
d3765576
FD
35source "$UTILSSH"
36
37this_dir_relative="plugins/flt.lttng-utils.debug-info"
d3765576
FD
38succeed_trace_dir="$BT_CTF_TRACES_PATH/succeed"
39expect_dir="$BT_TESTS_DATADIR/$this_dir_relative"
40binary_artefact_dir="$BT_TESTS_DATADIR/$this_dir_relative"
8cca03c6 41data_dir="$BT_TESTS_DATADIR/$this_dir_relative"
d3765576
FD
42
43test_debug_info() {
44 local name="$1"
45 local local_args=(
46 "-c" "flt.lttng-utils.debug-info"
47 "-p" "target-prefix=\"$binary_artefact_dir/x86_64-linux-gnu/dwarf_full\""
48 "-c" "sink.text.details"
49 "-p" "with-trace-name=no,with-stream-name=no"
50 )
51
52 bt_diff_cli "$expect_dir/trace-$name.expect" "/dev/null" \
53 "$succeed_trace_dir/$name" "${local_args[@]}"
54 ok $? "Trace '$name' gives the expected output"
55}
56
140f7e02
FD
57test_compare_to_ctf_fs() {
58 # Compare the `sink.text.details` output of a graph with and without a
59 # `flt.lttng-utils.debug-info` component. Both should be identical for
60 # traces without LTTng debugging fields.
61 local test_name=$1
62 shift 1
63 local cli_args=("$@")
64 local debug_info_cli_args=("-c" "flt.lttng-utils.debug-info")
65 local details_cli_args=(
66 "-c" "sink.text.details"
67 "--params" "with-trace-name=false,with-stream-name=false,with-uuid=false"
68 )
ce0098bd
SM
69 local actual_stdout
70 local actual_stderr
71 local expected_stdout
72 local expected_stderr
140f7e02
FD
73 local ret=0
74
ce0098bd
SM
75 actual_stdout=$(mktemp -t test_debug_info_stdout_actual.XXXXXX)
76 actual_stderr=$(mktemp -t test_debug_info_stderr_actual.XXXXXX)
77 expected_stdout=$(mktemp -t test_debug_info_stdout_expected.XXXXXX)
78 expected_stderr=$(mktemp -t test_debug_info_stderr_expected.XXXXXX)
79
140f7e02
FD
80 # Create expected files using a graph without a `debug-info` component.
81 bt_cli "$expected_stdout" "$expected_stderr" "${cli_args[@]}" \
82 "${details_cli_args[@]}"
83
84 # Read the same trace with a `debug-info` component in the graph.
85 bt_cli "$actual_stdout" "$actual_stderr" "${cli_args[@]}" \
86 "${details_cli_args[@]}" "${debug_info_cli_args[@]}"
87
88 bt_diff "$expected_stdout" "$actual_stdout"
89 ok $? "Input '$test_name' gives the expected stdout"
90
91 bt_diff "$expected_stderr" "$actual_stderr"
92 ok $? "Input '$test_name' gives the expected stderr"
93
94 rm -f "$actual_stdout"
95 rm -f "$actual_stderr"
96 rm -f "$expected_stdout"
97 rm -f "$expected_stderr"
98}
99
100test_compare_ctf_src_trace() {
101 local trace_name=$1
102 local trace_path="$succeed_trace_dir/$trace_name"
103 local cli_args=("$trace_path")
104
105 diag "Comparing output with and without 'flt.lttng-utils.debug-info' on '$trace_name'"
106 test_compare_to_ctf_fs "src.ctf.fs with $trace_name trace" "${cli_args[@]}"
107}
108
8cca03c6
FD
109test_compare_complete_src_trace() {
110
111 local source_name="src.test_debug_info.CompleteSrc"
112 local cli_args=("--plugin-path=$data_dir" "-c" "$source_name")
113 test_compare_to_ctf_fs "$source_name" "${cli_args[@]}"
114}
115
116plan_tests 9
d3765576
FD
117
118test_debug_info debug-info
140f7e02
FD
119
120test_compare_ctf_src_trace smalltrace
121test_compare_ctf_src_trace 2packets
122test_compare_ctf_src_trace session-rotation
8cca03c6
FD
123
124test_compare_complete_src_trace
This page took 0.043259 seconds and 4 git commands to generate.