tests: fix shellcheck warnings in cli/convert/test_auto_source_discovery_{log_level...
[babeltrace.git] / tests / cli / convert / test_auto_source_discovery_log_level
CommitLineData
1b2b6649
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
dc807017
SM
18# Test how log level options are applied to sources auto-discovered by the
19# convert command.
1b2b6649
SM
20
21if [ "x${BT_TESTS_SRCDIR:-}" != "x" ]; then
22 UTILSSH="$BT_TESTS_SRCDIR/utils/utils.sh"
23else
24 UTILSSH="$(dirname "$0")/../../utils/utils.sh"
25fi
26
27# shellcheck source=../../utils/utils.sh
28SH_TAP=1 source "$UTILSSH"
29
30NUM_TESTS=4
31
32plan_tests $NUM_TESTS
33
a83410cd 34data_dir="${BT_TESTS_DATADIR}/auto-source-discovery/params-log-level"
1b2b6649
SM
35plugin_dir="${data_dir}"
36dir_a="${data_dir}/dir-a"
37dir_b="${data_dir}/dir-b"
38dir_ab="${data_dir}/dir-ab"
39
40expected_file=$(mktemp -t expected.XXXXXX)
1b2b6649 41
e511a264 42print_log_level=(--params 'what="log-level"')
dc807017 43details_sink=("-c" "sink.text.details" "--params=with-metadata=false")
1b2b6649
SM
44
45debug=2
46trace=1
47
24594611 48# Apply log level to two components from one non-option argument.
1b2b6649 49cat > "$expected_file" <<END
dc807017
SM
50{Trace 0, Stream class ID 0, Stream ID 0}
51Stream 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}
57Stream 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}
63Stream end
64
65{Trace 1, Stream class ID 0, Stream ID 0}
66Stream end
1b2b6649
SM
67END
68
dc807017 69bt_diff_cli "$expected_file" "/dev/null" \
02510056 70 --plugin-path "${plugin_dir}" convert \
e511a264
SM
71 "${dir_ab}" --log-level DEBUG "${print_log_level[@]}" \
72 "${details_sink[@]}"
24594611 73ok "$?" "apply log level to two components from one non-option argument"
1b2b6649 74
24594611 75# Apply log level to two components from two distinct non-option arguments.
1b2b6649 76cat > "$expected_file" <<END
dc807017
SM
77{Trace 0, Stream class ID 0, Stream ID 0}
78Stream 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}
84Stream 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}
90Stream end
91
92{Trace 1, Stream class ID 0, Stream ID 0}
93Stream end
1b2b6649
SM
94END
95
dc807017 96bt_diff_cli "$expected_file" "/dev/null" \
02510056 97 --plugin-path "${plugin_dir}" convert \
e511a264
SM
98 "${dir_a}" --log-level DEBUG "${print_log_level[@]}" "${dir_b}" --log-level TRACE "${print_log_level[@]}" \
99 "${details_sink[@]}"
24594611 100ok "$?" "apply log level to two non-option arguments"
1b2b6649 101
24594611 102# Apply log level to one component coming from one non-option argument and one component coming from two non-option arguments (1).
1b2b6649 103cat > "$expected_file" <<END
dc807017
SM
104{Trace 0, Stream class ID 0, Stream ID 0}
105Stream 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}
111Stream 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}
117Stream end
118
119{Trace 1, Stream class ID 0, Stream ID 0}
120Stream end
1b2b6649
SM
121END
122
dc807017 123bt_diff_cli "$expected_file" "/dev/null" \
02510056 124 --plugin-path "${plugin_dir}" convert \
e511a264
SM
125 "${dir_a}" --log-level DEBUG "${print_log_level[@]}" "${dir_ab}" --log-level TRACE "${print_log_level[@]}" \
126 "${details_sink[@]}"
24594611 127ok "$?" "apply log level to one component coming from one non-option argument and one component coming from two non-option arguments (1)"
1b2b6649 128
24594611 129# Apply log level to one component coming from one non-option argument and one component coming from two non-option arguments (2).
1b2b6649 130cat > "$expected_file" <<END
dc807017
SM
131{Trace 0, Stream class ID 0, Stream ID 0}
132Stream 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}
138Stream 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}
144Stream end
145
146{Trace 1, Stream class ID 0, Stream ID 0}
147Stream end
1b2b6649
SM
148END
149
dc807017 150bt_diff_cli "$expected_file" "/dev/null" \
02510056 151 --plugin-path "${plugin_dir}" convert \
e511a264
SM
152 "${dir_ab}" --log-level DEBUG "${print_log_level[@]}" "${dir_a}" --log-level TRACE "${print_log_level[@]}" \
153 "${details_sink[@]}"
24594611 154ok "$?" "apply log level to one component coming from one non-option argument and one component coming from two non-option arguments (2)"
1b2b6649
SM
155
156rm -f "$expected_file"
This page took 0.0421 seconds and 4 git commands to generate.