Commit | Line | Data |
---|---|---|
b6a0ac97 SM |
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 | ||
449944d5 SM |
18 | # Test how log level options are applied to sources auto-discovered by the |
19 | # convert command. | |
b6a0ac97 SM |
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 | ||
e186f629 | 34 | data_dir="${BT_TESTS_DATADIR}/auto-source-discovery/params-log-level" |
b6a0ac97 SM |
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) | |
b6a0ac97 | 41 | |
449944d5 SM |
42 | print_log_level="--params what=\"log-level\"" |
43 | details_sink=("-c" "sink.text.details" "--params=with-metadata=false") | |
b6a0ac97 SM |
44 | |
45 | debug=2 | |
46 | trace=1 | |
47 | ||
8d5247bd | 48 | # Apply log level to two components from one non-option argument. |
b6a0ac97 | 49 | cat > "$expected_file" <<END |
449944d5 SM |
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 | |
b6a0ac97 SM |
67 | END |
68 | ||
449944d5 | 69 | bt_diff_cli "$expected_file" "/dev/null" \ |
d36258d0 | 70 | --plugin-path "${plugin_dir}" convert \ |
449944d5 SM |
71 | "${dir_ab}" --log-level DEBUG ${print_log_level} \ |
72 | ${details_sink[@]} | |
8d5247bd | 73 | ok "$?" "apply log level to two components from one non-option argument" |
b6a0ac97 | 74 | |
8d5247bd | 75 | # Apply log level to two components from two distinct non-option arguments. |
b6a0ac97 | 76 | cat > "$expected_file" <<END |
449944d5 SM |
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 | |
b6a0ac97 SM |
94 | END |
95 | ||
449944d5 | 96 | bt_diff_cli "$expected_file" "/dev/null" \ |
d36258d0 | 97 | --plugin-path "${plugin_dir}" convert \ |
449944d5 SM |
98 | "${dir_a}" --log-level DEBUG ${print_log_level} "${dir_b}" --log-level TRACE ${print_log_level} \ |
99 | ${details_sink[@]} | |
8d5247bd | 100 | ok "$?" "apply log level to two non-option arguments" |
b6a0ac97 | 101 | |
8d5247bd | 102 | # Apply log level to one component coming from one non-option argument and one component coming from two non-option arguments (1). |
b6a0ac97 | 103 | cat > "$expected_file" <<END |
449944d5 SM |
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 | |
b6a0ac97 SM |
121 | END |
122 | ||
449944d5 | 123 | bt_diff_cli "$expected_file" "/dev/null" \ |
d36258d0 | 124 | --plugin-path "${plugin_dir}" convert \ |
449944d5 SM |
125 | "${dir_a}" --log-level DEBUG ${print_log_level} "${dir_ab}" --log-level TRACE ${print_log_level} \ |
126 | ${details_sink[@]} | |
8d5247bd | 127 | ok "$?" "apply log level to one component coming from one non-option argument and one component coming from two non-option arguments (1)" |
b6a0ac97 | 128 | |
8d5247bd | 129 | # Apply log level to one component coming from one non-option argument and one component coming from two non-option arguments (2). |
b6a0ac97 | 130 | cat > "$expected_file" <<END |
449944d5 SM |
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 | |
b6a0ac97 SM |
148 | END |
149 | ||
449944d5 | 150 | bt_diff_cli "$expected_file" "/dev/null" \ |
d36258d0 | 151 | --plugin-path "${plugin_dir}" convert \ |
449944d5 SM |
152 | "${dir_ab}" --log-level DEBUG ${print_log_level} "${dir_a}" --log-level TRACE ${print_log_level} \ |
153 | ${details_sink[@]} | |
8d5247bd | 154 | ok "$?" "apply log level to one component coming from one non-option argument and one component coming from two non-option arguments (2)" |
b6a0ac97 SM |
155 | |
156 | rm -f "$expected_file" |