cli: make --plugin-path and --omit-{system,home}-plugin-path global opts
[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 how log level options are applied to sources auto-discovered by the
19 # convert 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}/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
42 print_log_level="--params what=\"log-level\""
43 details_sink=("-c" "sink.text.details" "--params=with-metadata=false")
44
45 debug=2
46 trace=1
47
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}
51 Stream beginning:
52 Name: TestSourceA: ${debug}
53 Trace:
54 Stream (ID 0, Class ID 0)
55
56 {Trace 1, Stream class ID 0, Stream ID 0}
57 Stream beginning:
58 Name: TestSourceB: ${debug}
59 Trace:
60 Stream (ID 0, Class ID 0)
61
62 {Trace 0, Stream class ID 0, Stream ID 0}
63 Stream end
64
65 {Trace 1, Stream class ID 0, Stream ID 0}
66 Stream end
67 END
68
69 bt_diff_cli "$expected_file" "/dev/null" \
70 --plugin-path "${plugin_dir}" convert \
71 "${dir_ab}" --log-level DEBUG ${print_log_level} \
72 ${details_sink[@]}
73 ok "$?" "apply log level to two components from one non-option argument"
74
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}
78 Stream beginning:
79 Name: TestSourceA: ${debug}
80 Trace:
81 Stream (ID 0, Class ID 0)
82
83 {Trace 1, Stream class ID 0, Stream ID 0}
84 Stream beginning:
85 Name: TestSourceB: ${trace}
86 Trace:
87 Stream (ID 0, Class ID 0)
88
89 {Trace 0, Stream class ID 0, Stream ID 0}
90 Stream end
91
92 {Trace 1, Stream class ID 0, Stream ID 0}
93 Stream end
94 END
95
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} \
99 ${details_sink[@]}
100 ok "$?" "apply log level to two non-option arguments"
101
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}
105 Stream beginning:
106 Name: TestSourceA: ${trace}
107 Trace:
108 Stream (ID 0, Class ID 0)
109
110 {Trace 1, Stream class ID 0, Stream ID 0}
111 Stream beginning:
112 Name: TestSourceB: ${trace}
113 Trace:
114 Stream (ID 0, Class ID 0)
115
116 {Trace 0, Stream class ID 0, Stream ID 0}
117 Stream end
118
119 {Trace 1, Stream class ID 0, Stream ID 0}
120 Stream end
121 END
122
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} \
126 ${details_sink[@]}
127 ok "$?" "apply log level to one component coming from one non-option argument and one component coming from two non-option arguments (1)"
128
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}
132 Stream beginning:
133 Name: TestSourceA: ${trace}
134 Trace:
135 Stream (ID 0, Class ID 0)
136
137 {Trace 1, Stream class ID 0, Stream ID 0}
138 Stream beginning:
139 Name: TestSourceB: ${debug}
140 Trace:
141 Stream (ID 0, Class ID 0)
142
143 {Trace 0, Stream class ID 0, Stream ID 0}
144 Stream end
145
146 {Trace 1, Stream class ID 0, Stream ID 0}
147 Stream end
148 END
149
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} \
153 ${details_sink[@]}
154 ok "$?" "apply log level to one component coming from one non-option argument and one component coming from two non-option arguments (2)"
155
156 rm -f "$expected_file"
This page took 0.033537 seconds and 5 git commands to generate.