3 # Copyright (C) 2019 Simon Marchi <simon.marchi@efficios.com>
5 # This program is free software; you can redistribute it and/or modify it
6 # under the terms of the GNU General Public License, version 2 only, as
7 # published by the Free Software Foundation.
9 # This program is distributed in the hope that it will be useful, but WITHOUT
10 # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 # FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
14 # You should have received a copy of the GNU General Public License along with
15 # this program; if not, write to the Free Software Foundation, Inc., 51
16 # Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
18 # Test how log level options are applied to sources auto-discovered by the
21 if [ "x${BT_TESTS_SRCDIR:-}" != "x" ]; then
22 UTILSSH
="$BT_TESTS_SRCDIR/utils/utils.sh"
24 UTILSSH
="$(dirname "$0")/../../utils/utils.sh"
27 # shellcheck source=../../utils/utils.sh
28 SH_TAP
=1 source "$UTILSSH"
34 data_dir
="${BT_TESTS_DATADIR}/auto-source-discovery/params-log-level"
35 plugin_dir
="${data_dir}"
36 dir_a
="${data_dir}/dir-a"
37 dir_b
="${data_dir}/dir-b"
38 dir_ab
="${data_dir}/dir-ab"
40 expected_file
=$
(mktemp
-t expected.XXXXXX
)
42 print_log_level
="--params what=\"log-level\""
43 details_sink
=("-c" "sink.text.details" "--params=with-metadata=false")
48 # Apply log level to two components from one non-option argument.
49 cat > "$expected_file" <<END
50 {Trace 0, Stream class ID 0, Stream ID 0}
52 Name: TestSourceA: ${debug}
54 Stream (ID 0, Class ID 0)
56 {Trace 1, Stream class ID 0, Stream ID 0}
58 Name: TestSourceB: ${debug}
60 Stream (ID 0, Class ID 0)
62 {Trace 0, Stream class ID 0, Stream ID 0}
65 {Trace 1, Stream class ID 0, Stream ID 0}
69 bt_diff_cli
"$expected_file" "/dev/null" \
70 --plugin-path "${plugin_dir}" convert \
71 "${dir_ab}" --log-level DEBUG
${print_log_level} \
73 ok
"$?" "apply log level to two components from one non-option argument"
75 # Apply log level to two components from two distinct non-option arguments.
76 cat > "$expected_file" <<END
77 {Trace 0, Stream class ID 0, Stream ID 0}
79 Name: TestSourceA: ${debug}
81 Stream (ID 0, Class ID 0)
83 {Trace 1, Stream class ID 0, Stream ID 0}
85 Name: TestSourceB: ${trace}
87 Stream (ID 0, Class ID 0)
89 {Trace 0, Stream class ID 0, Stream ID 0}
92 {Trace 1, Stream class ID 0, Stream ID 0}
96 bt_diff_cli
"$expected_file" "/dev/null" \
97 --plugin-path "${plugin_dir}" convert \
98 "${dir_a}" --log-level DEBUG ${print_log_level} "${dir_b}" --log-level TRACE ${print_log_level} \
100 ok "$?
" "apply log level to two non-option arguments
"
102 # Apply log level to one component coming from one non-option argument and one component coming from two non-option arguments (1).
103 cat > "$expected_file" <<END
104 {Trace 0, Stream class ID 0, Stream ID 0}
106 Name: TestSourceA: ${trace}
108 Stream (ID 0, Class ID 0)
110 {Trace 1, Stream class ID 0, Stream ID 0}
112 Name: TestSourceB: ${trace}
114 Stream (ID 0, Class ID 0)
116 {Trace 0, Stream class ID 0, Stream ID 0}
119 {Trace 1, Stream class ID 0, Stream ID 0}
123 bt_diff_cli "$expected_file" "/dev
/null
" \
124 --plugin-path "${plugin_dir}" convert \
125 "${dir_a}" --log-level DEBUG ${print_log_level} "${dir_ab}" --log-level TRACE ${print_log_level} \
127 ok
"$?" "apply log level to one component coming from one non-option argument and one component coming from two non-option arguments (1)"
129 # Apply log level to one component coming from one non-option argument and one component coming from two non-option arguments (2).
130 cat > "$expected_file" <<END
131 {Trace 0, Stream class ID 0, Stream ID 0}
133 Name: TestSourceA: ${trace}
135 Stream (ID 0, Class ID 0)
137 {Trace 1, Stream class ID 0, Stream ID 0}
139 Name: TestSourceB: ${debug}
141 Stream (ID 0, Class ID 0)
143 {Trace 0, Stream class ID 0, Stream ID 0}
146 {Trace 1, Stream class ID 0, Stream ID 0}
150 bt_diff_cli
"$expected_file" "/dev/null" \
151 --plugin-path "${plugin_dir}" convert \
152 "${dir_ab}" --log-level DEBUG ${print_log_level} "${dir_a}" --log-level TRACE ${print_log_level} \
154 ok "$?
" "apply log level to one component coming from one non-option argument and one component coming from two non-option arguments
(2)"
156 rm -f "$expected_file"