tests: fix shellcheck warnings in cli/convert/test_auto_source_discovery_{log_level...
[babeltrace.git] / tests / cli / convert / test_auto_source_discovery_params
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 parameters are applied to sources auto-discovered by the convert
19 # 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_test_params=("--params" 'what="test-params"')
43 details_sink=("-c" "sink.text.details" "--params=with-metadata=false")
44
45 # Apply params to two components from one non-option argument.
46 cat > "$expected_file" <<END
47 {Trace 0, Stream class ID 0, Stream ID 0}
48 Stream beginning:
49 Name: TestSourceA: ('test-allo', 'madame')
50 Trace:
51 Stream (ID 0, Class ID 0)
52
53 {Trace 1, Stream class ID 0, Stream ID 0}
54 Stream beginning:
55 Name: TestSourceB: ('test-allo', 'madame')
56 Trace:
57 Stream (ID 0, Class ID 0)
58
59 {Trace 0, Stream class ID 0, Stream ID 0}
60 Stream end
61
62 {Trace 1, Stream class ID 0, Stream ID 0}
63 Stream end
64 END
65
66 bt_diff_cli "$expected_file" "/dev/null" \
67 --plugin-path "${plugin_dir}" convert \
68 "${dir_ab}" --params 'test-allo="madame"' "${print_test_params[@]}" \
69 "${details_sink[@]}"
70 ok "$?" "apply params to two components from one non-option argument"
71
72 # Apply params to two components from two distinct non-option arguments.
73 cat > "$expected_file" <<END
74 {Trace 0, Stream class ID 0, Stream ID 0}
75 Stream beginning:
76 Name: TestSourceA: ('test-allo', 'madame')
77 Trace:
78 Stream (ID 0, Class ID 0)
79
80 {Trace 1, Stream class ID 0, Stream ID 0}
81 Stream beginning:
82 Name: TestSourceB: ('test-bonjour', 'monsieur')
83 Trace:
84 Stream (ID 0, Class ID 0)
85
86 {Trace 0, Stream class ID 0, Stream ID 0}
87 Stream end
88
89 {Trace 1, Stream class ID 0, Stream ID 0}
90 Stream end
91 END
92
93 bt_diff_cli "$expected_file" "/dev/null" \
94 --plugin-path "${plugin_dir}" convert \
95 "${dir_a}" --params 'test-allo="madame"' "${print_test_params[@]}" "${dir_b}" --params 'test-bonjour="monsieur"' "${print_test_params[@]}" \
96 "${details_sink[@]}"
97 ok "$?" "apply params to two non-option arguments"
98
99 # Apply params to one component coming from one non-option argument and one component coming from two non-option arguments (1).
100 cat > "$expected_file" <<END
101 {Trace 0, Stream class ID 0, Stream ID 0}
102 Stream beginning:
103 Name: TestSourceA: ('test-allo', 'madame'), ('test-bonjour', 'monsieur')
104 Trace:
105 Stream (ID 0, Class ID 0)
106
107 {Trace 1, Stream class ID 0, Stream ID 0}
108 Stream beginning:
109 Name: TestSourceB: ('test-bonjour', 'monsieur')
110 Trace:
111 Stream (ID 0, Class ID 0)
112
113 {Trace 0, Stream class ID 0, Stream ID 0}
114 Stream end
115
116 {Trace 1, Stream class ID 0, Stream ID 0}
117 Stream end
118 END
119
120 bt_diff_cli "$expected_file" "/dev/null" \
121 --plugin-path "${plugin_dir}" convert \
122 "${dir_a}" --params 'test-allo="madame"' "${print_test_params[@]}" "${dir_ab}" --params 'test-bonjour="monsieur"' "${print_test_params[@]}" \
123 "${details_sink[@]}"
124 ok "$?" "apply params to one component coming from one non-option argument and one component coming from two non-option arguments (1)"
125
126 # Apply params to one component coming from one non-option argument and one component coming from two non-option arguments (2).
127 cat > "$expected_file" <<END
128 {Trace 0, Stream class ID 0, Stream ID 0}
129 Stream beginning:
130 Name: TestSourceA: ('test-bonjour', 'monsieur'), ('test-salut', 'les amis')
131 Trace:
132 Stream (ID 0, Class ID 0)
133
134 {Trace 1, Stream class ID 0, Stream ID 0}
135 Stream beginning:
136 Name: TestSourceB: ('test-bonjour', 'madame'), ('test-salut', 'les amis')
137 Trace:
138 Stream (ID 0, Class ID 0)
139
140 {Trace 0, Stream class ID 0, Stream ID 0}
141 Stream end
142
143 {Trace 1, Stream class ID 0, Stream ID 0}
144 Stream end
145 END
146
147 bt_diff_cli "$expected_file" "/dev/null" \
148 --plugin-path "${plugin_dir}" convert \
149 "${dir_ab}" --params 'test-bonjour="madame",test-salut="les amis"' "${print_test_params[@]}" "${dir_a}" --params 'test-bonjour="monsieur"' "${print_test_params[@]}" \
150 "${details_sink[@]}"
151 ok "$?" "apply params to one component coming from one non-option argument and one component coming from two non-option arguments (2)"
152
153 rm -f "$expected_file"
This page took 0.033506 seconds and 4 git commands to generate.