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 log level options are applied to sources auto-discovered by the convert
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}/cli/convert/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
)
41 stderr_expected
=/dev
/null
43 print_log_level
="--params print=\"log-level\""
48 # Apply log level to two components from one non-option argument.
49 cat > "$expected_file" <<END
54 bt_diff_cli_sorted
"$expected_file" "$stderr_expected" \
55 convert
--plugin-path "${plugin_dir}" \
56 "${dir_ab}" --log-level DEBUG
${print_log_level}
57 ok
"$?" "apply log level to two components from one non-option argument"
59 # Apply log level to two components from two distinct non-option arguments.
60 cat > "$expected_file" <<END
65 bt_diff_cli_sorted
"$expected_file" "$stderr_expected" \
66 convert
--plugin-path "${plugin_dir}" \
67 "${dir_a}" --log-level DEBUG ${print_log_level} "${dir_b}" --log-level TRACE ${print_log_level}
68 ok "$?
" "apply log level to two non-option arguments
"
70 # Apply log level to one component coming from one non-option argument and one component coming from two non-option arguments (1).
71 cat > "$expected_file" <<END
76 bt_diff_cli_sorted "$expected_file" "$stderr_expected" \
77 convert --plugin-path "${plugin_dir}" \
78 "${dir_a}" --log-level DEBUG ${print_log_level} "${dir_ab}" --log-level TRACE ${print_log_level}
79 ok
"$?" "apply log level to one component coming from one non-option argument and one component coming from two non-option arguments (1)"
81 # Apply log level to one component coming from one non-option argument and one component coming from two non-option arguments (2).
82 cat > "$expected_file" <<END
87 bt_diff_cli_sorted
"$expected_file" "$stderr_expected" \
88 convert
--plugin-path "${plugin_dir}" \
89 "${dir_ab}" --log-level DEBUG ${print_log_level} "${dir_a}" --log-level TRACE ${print_log_level}
90 ok "$?
" "apply log level to one component coming from one non-option argument and one component coming from two non-option arguments
(2)"
92 rm -f "$expected_file"