cli: make --plugin-path and --omit-{system,home}-plugin-path global opts
[babeltrace.git] / tests / cli / convert / test_auto_source_discovery_log_level
CommitLineData
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
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
e186f629 34data_dir="${BT_TESTS_DATADIR}/auto-source-discovery/params-log-level"
b6a0ac97
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)
b6a0ac97 41
449944d5
SM
42print_log_level="--params what=\"log-level\""
43details_sink=("-c" "sink.text.details" "--params=with-metadata=false")
b6a0ac97
SM
44
45debug=2
46trace=1
47
8d5247bd 48# Apply log level to two components from one non-option argument.
b6a0ac97 49cat > "$expected_file" <<END
449944d5
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
b6a0ac97
SM
67END
68
449944d5 69bt_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 73ok "$?" "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 76cat > "$expected_file" <<END
449944d5
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
b6a0ac97
SM
94END
95
449944d5 96bt_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 100ok "$?" "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 103cat > "$expected_file" <<END
449944d5
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
b6a0ac97
SM
121END
122
449944d5 123bt_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 127ok "$?" "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 130cat > "$expected_file" <<END
449944d5
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
b6a0ac97
SM
148END
149
449944d5 150bt_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 154ok "$?" "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
156rm -f "$expected_file"
This page took 0.030417 seconds and 4 git commands to generate.