Commit | Line | Data |
---|---|---|
1b2b6649 SM |
1 | #!/bin/bash |
2 | # | |
0235b0db | 3 | # SPDX-License-Identifier: GPL-2.0-only |
1b2b6649 | 4 | # |
0235b0db | 5 | # Copyright (C) 2019 Simon Marchi <simon.marchi@efficios.com> |
1b2b6649 | 6 | # |
1b2b6649 | 7 | |
dc807017 SM |
8 | # Test how log level options are applied to sources auto-discovered by the |
9 | # convert command. | |
1b2b6649 SM |
10 | |
11 | if [ "x${BT_TESTS_SRCDIR:-}" != "x" ]; then | |
12 | UTILSSH="$BT_TESTS_SRCDIR/utils/utils.sh" | |
13 | else | |
14 | UTILSSH="$(dirname "$0")/../../utils/utils.sh" | |
15 | fi | |
16 | ||
17 | # shellcheck source=../../utils/utils.sh | |
18 | SH_TAP=1 source "$UTILSSH" | |
19 | ||
20 | NUM_TESTS=4 | |
21 | ||
22 | plan_tests $NUM_TESTS | |
23 | ||
a83410cd | 24 | data_dir="${BT_TESTS_DATADIR}/auto-source-discovery/params-log-level" |
1b2b6649 SM |
25 | plugin_dir="${data_dir}" |
26 | dir_a="${data_dir}/dir-a" | |
27 | dir_b="${data_dir}/dir-b" | |
28 | dir_ab="${data_dir}/dir-ab" | |
29 | ||
30 | expected_file=$(mktemp -t expected.XXXXXX) | |
1b2b6649 | 31 | |
e511a264 | 32 | print_log_level=(--params 'what="log-level"') |
dc807017 | 33 | details_sink=("-c" "sink.text.details" "--params=with-metadata=false") |
1b2b6649 SM |
34 | |
35 | debug=2 | |
36 | trace=1 | |
37 | ||
24594611 | 38 | # Apply log level to two components from one non-option argument. |
1b2b6649 | 39 | cat > "$expected_file" <<END |
dc807017 SM |
40 | {Trace 0, Stream class ID 0, Stream ID 0} |
41 | Stream beginning: | |
42 | Name: TestSourceA: ${debug} | |
43 | Trace: | |
44 | Stream (ID 0, Class ID 0) | |
45 | ||
46 | {Trace 1, Stream class ID 0, Stream ID 0} | |
47 | Stream beginning: | |
48 | Name: TestSourceB: ${debug} | |
49 | Trace: | |
50 | Stream (ID 0, Class ID 0) | |
51 | ||
52 | {Trace 0, Stream class ID 0, Stream ID 0} | |
53 | Stream end | |
54 | ||
55 | {Trace 1, Stream class ID 0, Stream ID 0} | |
56 | Stream end | |
1b2b6649 SM |
57 | END |
58 | ||
dc807017 | 59 | bt_diff_cli "$expected_file" "/dev/null" \ |
02510056 | 60 | --plugin-path "${plugin_dir}" convert \ |
e511a264 SM |
61 | "${dir_ab}" --log-level DEBUG "${print_log_level[@]}" \ |
62 | "${details_sink[@]}" | |
24594611 | 63 | ok "$?" "apply log level to two components from one non-option argument" |
1b2b6649 | 64 | |
24594611 | 65 | # Apply log level to two components from two distinct non-option arguments. |
1b2b6649 | 66 | cat > "$expected_file" <<END |
dc807017 SM |
67 | {Trace 0, Stream class ID 0, Stream ID 0} |
68 | Stream beginning: | |
69 | Name: TestSourceA: ${debug} | |
70 | Trace: | |
71 | Stream (ID 0, Class ID 0) | |
72 | ||
73 | {Trace 1, Stream class ID 0, Stream ID 0} | |
74 | Stream beginning: | |
75 | Name: TestSourceB: ${trace} | |
76 | Trace: | |
77 | Stream (ID 0, Class ID 0) | |
78 | ||
79 | {Trace 0, Stream class ID 0, Stream ID 0} | |
80 | Stream end | |
81 | ||
82 | {Trace 1, Stream class ID 0, Stream ID 0} | |
83 | Stream end | |
1b2b6649 SM |
84 | END |
85 | ||
dc807017 | 86 | bt_diff_cli "$expected_file" "/dev/null" \ |
02510056 | 87 | --plugin-path "${plugin_dir}" convert \ |
e511a264 SM |
88 | "${dir_a}" --log-level DEBUG "${print_log_level[@]}" "${dir_b}" --log-level TRACE "${print_log_level[@]}" \ |
89 | "${details_sink[@]}" | |
24594611 | 90 | ok "$?" "apply log level to two non-option arguments" |
1b2b6649 | 91 | |
24594611 | 92 | # Apply log level to one component coming from one non-option argument and one component coming from two non-option arguments (1). |
1b2b6649 | 93 | cat > "$expected_file" <<END |
dc807017 SM |
94 | {Trace 0, Stream class ID 0, Stream ID 0} |
95 | Stream beginning: | |
96 | Name: TestSourceA: ${trace} | |
97 | Trace: | |
98 | Stream (ID 0, Class ID 0) | |
99 | ||
100 | {Trace 1, Stream class ID 0, Stream ID 0} | |
101 | Stream beginning: | |
102 | Name: TestSourceB: ${trace} | |
103 | Trace: | |
104 | Stream (ID 0, Class ID 0) | |
105 | ||
106 | {Trace 0, Stream class ID 0, Stream ID 0} | |
107 | Stream end | |
108 | ||
109 | {Trace 1, Stream class ID 0, Stream ID 0} | |
110 | Stream end | |
1b2b6649 SM |
111 | END |
112 | ||
dc807017 | 113 | bt_diff_cli "$expected_file" "/dev/null" \ |
02510056 | 114 | --plugin-path "${plugin_dir}" convert \ |
e511a264 SM |
115 | "${dir_a}" --log-level DEBUG "${print_log_level[@]}" "${dir_ab}" --log-level TRACE "${print_log_level[@]}" \ |
116 | "${details_sink[@]}" | |
24594611 | 117 | ok "$?" "apply log level to one component coming from one non-option argument and one component coming from two non-option arguments (1)" |
1b2b6649 | 118 | |
24594611 | 119 | # Apply log level to one component coming from one non-option argument and one component coming from two non-option arguments (2). |
1b2b6649 | 120 | cat > "$expected_file" <<END |
dc807017 SM |
121 | {Trace 0, Stream class ID 0, Stream ID 0} |
122 | Stream beginning: | |
123 | Name: TestSourceA: ${trace} | |
124 | Trace: | |
125 | Stream (ID 0, Class ID 0) | |
126 | ||
127 | {Trace 1, Stream class ID 0, Stream ID 0} | |
128 | Stream beginning: | |
129 | Name: TestSourceB: ${debug} | |
130 | Trace: | |
131 | Stream (ID 0, Class ID 0) | |
132 | ||
133 | {Trace 0, Stream class ID 0, Stream ID 0} | |
134 | Stream end | |
135 | ||
136 | {Trace 1, Stream class ID 0, Stream ID 0} | |
137 | Stream end | |
1b2b6649 SM |
138 | END |
139 | ||
dc807017 | 140 | bt_diff_cli "$expected_file" "/dev/null" \ |
02510056 | 141 | --plugin-path "${plugin_dir}" convert \ |
e511a264 SM |
142 | "${dir_ab}" --log-level DEBUG "${print_log_level[@]}" "${dir_a}" --log-level TRACE "${print_log_level[@]}" \ |
143 | "${details_sink[@]}" | |
24594611 | 144 | ok "$?" "apply log level to one component coming from one non-option argument and one component coming from two non-option arguments (2)" |
1b2b6649 SM |
145 | |
146 | rm -f "$expected_file" |