cli: apply log levels (`--log-level` option) to leftovers
[babeltrace.git] / tests / cli / convert / test_auto_source_discovery_log_level
1 #!/bin/bash
2 #
3 # Copyright (C) 2019 Simon Marchi <simon.marchi@efficios.com>
4 #
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.
8 #
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
12 # more details.
13 #
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.
17
18 # Test log level options are applied to sources auto-discovered by the convert
19 # command.
20
21 if [ "x${BT_TESTS_SRCDIR:-}" != "x" ]; then
22 UTILSSH="$BT_TESTS_SRCDIR/utils/utils.sh"
23 else
24 UTILSSH="$(dirname "$0")/../../utils/utils.sh"
25 fi
26
27 # shellcheck source=../../utils/utils.sh
28 SH_TAP=1 source "$UTILSSH"
29
30 NUM_TESTS=4
31
32 plan_tests $NUM_TESTS
33
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"
39
40 expected_file=$(mktemp -t expected.XXXXXX)
41 stderr_expected=/dev/null
42
43 print_log_level="--params print=\"log-level\""
44
45 debug=2
46 trace=1
47
48 # Apply log level to two components from one leftover.
49 cat > "$expected_file" <<END
50 TestSourceA: ${debug}
51 TestSourceB: ${debug}
52 END
53
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 leftover"
58
59 # Apply log level to two components from two distinct leftovers.
60 cat > "$expected_file" <<END
61 TestSourceA: ${debug}
62 TestSourceB: ${trace}
63 END
64
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 leftovers"
69
70 # Apply log level to one component coming from one leftover and one component coming from two leftovers (1).
71 cat > "$expected_file" <<END
72 TestSourceA: ${trace}
73 TestSourceB: ${trace}
74 END
75
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 leftover and one component coming from two leftovers (1)"
80
81 # Apply log level to one component coming from one leftover and one component coming from two leftovers (2).
82 cat > "$expected_file" <<END
83 TestSourceA: ${trace}
84 TestSourceB: ${debug}
85 END
86
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 leftover and one component coming from two leftovers (2)"
91
92 rm -f "$expected_file"
This page took 0.032369 seconds and 5 git commands to generate.