python: define _BaseObject._ptr property
[babeltrace.git] / tests / cli / convert / test-convert-args.sh
1 #!/bin/bash
2 #
3 # SPDX-License-Identifier: GPL-2.0-only
4 #
5 # Copyright (C) 2017 Philippe Proulx <pproulx@efficios.com>
6 #
7
8 SH_TAP=1
9
10 if [ -n "${BT_TESTS_SRCDIR:-}" ]; then
11 UTILSSH="$BT_TESTS_SRCDIR/utils/utils.sh"
12 else
13 UTILSSH="$(dirname "$0")/../../utils/utils.sh"
14 fi
15
16 # shellcheck source=../../utils/utils.sh
17 source "$UTILSSH"
18
19 tmp_stdout=$(mktemp -t test-convert-args-stdout.XXXXXX)
20 tmp_stderr=$(mktemp -t test-convert-args-stderr.XXXXXX)
21
22 test_bt_convert_run_args() {
23 local what="$1"
24 local convert_args="$2"
25 local expected_run_args="$3"
26
27 local run_args
28
29 # Split argument string into array.
30 IFS=' ' read -ra convert_args_array <<< "$convert_args"
31
32 # Execute convert command.
33 bt_cli "${tmp_stdout}" "${tmp_stderr}" convert --run-args "${convert_args_array[@]}"
34 ok $? "${what}: success exit status"
35
36 run_args=$(cat "${tmp_stdout}")
37
38 # Verify output run args.
39 [ "$run_args" = "$expected_run_args" ]
40 ok $? "${what}: run arguments"
41 }
42
43 test_bt_convert_fails() {
44 local what="$1"
45 local convert_args="$2"
46 local expected_error_str="$3"
47
48 # Split argument string into array.
49 IFS=' ' read -ra convert_args_array <<< "$convert_args"
50
51 # Execute convert command.
52 bt_cli "${tmp_stdout}" "${tmp_stderr}" convert --run-args "${convert_args_array[@]}"
53 isnt "$?" 0 "failure exit status"
54
55 # Nothing should be printed on stdout.
56 bt_diff /dev/null "${tmp_stdout}"
57 ok $? "$what: nothing is printed on stdout"
58
59 # Check for expected error string in stderr.
60 bt_grep --quiet --fixed-strings -e "$expected_error_str" "$tmp_stderr"
61 local status=$?
62 ok "$status" "$what: expected error message"
63 if [ "$status" -ne 0 ]; then
64 diag "Expected error string '${expected_error_str}' not found in stderr:"
65 diag "$(cat "${tmp_stderr}")"
66 fi
67 }
68
69 path_to_trace="${BT_CTF_TRACES_PATH}/1/succeed/succeed1"
70 path_to_trace2="${BT_CTF_TRACES_PATH}/1/succeed/succeed2"
71 output_path="/output/path"
72
73 if [ "$BT_TESTS_OS_TYPE" = "mingw" ]; then
74 # Use Windows native paths for comparison because Unix
75 # paths are converted by the shell before they are passed
76 # to the native babeltrace2 binary.
77 path_to_trace=$(cygpath -m "$path_to_trace")
78 path_to_trace2=$(cygpath -m "$path_to_trace2")
79 output_path=$(cygpath -m "$output_path")
80 fi
81
82 plan_tests 161
83
84 test_bt_convert_run_args 'path non-option arg' "$path_to_trace" "--component auto-disc-source-ctf-fs:source.ctf.fs --params 'inputs=[\"$path_to_trace\"]' --component pretty:sink.text.pretty --component muxer:filter.utils.muxer --connect auto-disc-source-ctf-fs:muxer --connect muxer:pretty"
85 test_bt_convert_run_args 'path non-option args' "$path_to_trace $path_to_trace2" "--component auto-disc-source-ctf-fs:source.ctf.fs --params 'inputs=[\"$path_to_trace\", \"${path_to_trace2}\"]' --component pretty:sink.text.pretty --component muxer:filter.utils.muxer --connect auto-disc-source-ctf-fs:muxer --connect muxer:pretty"
86 test_bt_convert_run_args 'path non-option arg + named user source with --params' "$path_to_trace --component ZZ:source.another.source --params salut=yes" "--component ZZ:source.another.source --params salut=yes --component auto-disc-source-ctf-fs:source.ctf.fs --params 'inputs=[\"$path_to_trace\"]' --component pretty:sink.text.pretty --component muxer:filter.utils.muxer --connect ZZ:muxer --connect auto-disc-source-ctf-fs:muxer --connect muxer:pretty"
87 test_bt_convert_run_args 'unnamed user source' '--component source.salut.com' "--component source.salut.com:source.salut.com --component pretty:sink.text.pretty --component muxer:filter.utils.muxer --connect 'source\.salut\.com:muxer' --connect muxer:pretty"
88 test_bt_convert_run_args "path non-option arg + user source named \`auto-disc-source-ctf-fs\`" "--component auto-disc-source-ctf-fs:source.salut.com $path_to_trace" "--component auto-disc-source-ctf-fs:source.salut.com --component auto-disc-source-ctf-fs-0:source.ctf.fs --params 'inputs=[\"$path_to_trace\"]' --component pretty:sink.text.pretty --component muxer:filter.utils.muxer --connect auto-disc-source-ctf-fs:muxer --connect auto-disc-source-ctf-fs-0:muxer --connect muxer:pretty"
89 test_bt_convert_run_args "path non-option arg + user sink named \`pretty\`" "--component pretty:sink.my.sink $path_to_trace" "--component pretty:sink.my.sink --component auto-disc-source-ctf-fs:source.ctf.fs --params 'inputs=[\"$path_to_trace\"]' --component muxer:filter.utils.muxer --connect auto-disc-source-ctf-fs:muxer --connect muxer:pretty"
90 test_bt_convert_run_args "path non-option arg + user filter named \`muxer\`" "--component muxer:filter.salut.com $path_to_trace" "--component muxer:filter.salut.com --component auto-disc-source-ctf-fs:source.ctf.fs --params 'inputs=[\"$path_to_trace\"]' --component pretty:sink.text.pretty --component muxer-0:filter.utils.muxer --connect auto-disc-source-ctf-fs:muxer-0 --connect muxer-0:muxer --connect muxer:pretty"
91 test_bt_convert_run_args "path non-option arg + --begin + user filter named \`trimmer\`" "$path_to_trace --component trimmer:filter.salut.com --begin=abc" "--component trimmer:filter.salut.com --component auto-disc-source-ctf-fs:source.ctf.fs --params 'inputs=[\"$path_to_trace\"]' --component pretty:sink.text.pretty --component muxer:filter.utils.muxer --component trimmer-0:filter.utils.trimmer --params 'begin=\"abc\"' --connect auto-disc-source-ctf-fs:muxer --connect muxer:trimmer-0 --connect trimmer-0:trimmer --connect trimmer:pretty"
92 test_bt_convert_run_args 'path non-option arg + --begin' "$path_to_trace --begin=123" "--component auto-disc-source-ctf-fs:source.ctf.fs --params 'inputs=[\"$path_to_trace\"]' --component pretty:sink.text.pretty --component muxer:filter.utils.muxer --component trimmer:filter.utils.trimmer --params 'begin=\"123\"' --connect auto-disc-source-ctf-fs:muxer --connect muxer:trimmer --connect trimmer:pretty"
93 test_bt_convert_run_args 'path non-option arg + --begin --end' "$path_to_trace --end=456 --begin 123" "--component auto-disc-source-ctf-fs:source.ctf.fs --params 'inputs=[\"$path_to_trace\"]' --component pretty:sink.text.pretty --component muxer:filter.utils.muxer --component trimmer:filter.utils.trimmer --params 'end=\"456\"' --params 'begin=\"123\"' --connect auto-disc-source-ctf-fs:muxer --connect muxer:trimmer --connect trimmer:pretty"
94 test_bt_convert_run_args 'path non-option arg + --timerange' "$path_to_trace --timerange=[abc,xyz]" "--component auto-disc-source-ctf-fs:source.ctf.fs --params 'inputs=[\"$path_to_trace\"]' --component pretty:sink.text.pretty --component muxer:filter.utils.muxer --component trimmer:filter.utils.trimmer --params 'begin=\"abc\"' --params 'end=\"xyz\"' --connect auto-disc-source-ctf-fs:muxer --connect muxer:trimmer --connect trimmer:pretty"
95 test_bt_convert_run_args 'path non-option arg + --clock-cycles' "$path_to_trace --clock-cycles" "--component auto-disc-source-ctf-fs:source.ctf.fs --params 'inputs=[\"$path_to_trace\"]' --component pretty:sink.text.pretty --params clock-cycles=yes --component muxer:filter.utils.muxer --connect auto-disc-source-ctf-fs:muxer --connect muxer:pretty"
96 test_bt_convert_run_args 'path non-option arg + --clock-date' "$path_to_trace --clock-date" "--component auto-disc-source-ctf-fs:source.ctf.fs --params 'inputs=[\"$path_to_trace\"]' --component pretty:sink.text.pretty --params clock-date=yes --component muxer:filter.utils.muxer --connect auto-disc-source-ctf-fs:muxer --connect muxer:pretty"
97 test_bt_convert_run_args 'path non-option arg + --clock-force-correlate' "$path_to_trace --clock-force-correlate" "--component auto-disc-source-ctf-fs:source.ctf.fs --params force-clock-class-origin-unix-epoch=yes --params 'inputs=[\"$path_to_trace\"]' --component pretty:sink.text.pretty --component muxer:filter.utils.muxer --connect auto-disc-source-ctf-fs:muxer --connect muxer:pretty"
98 test_bt_convert_run_args 'path non-option arg + --clock-gmt' "$path_to_trace --clock-gmt" "--component auto-disc-source-ctf-fs:source.ctf.fs --params 'inputs=[\"$path_to_trace\"]' --component pretty:sink.text.pretty --params clock-gmt=yes --component muxer:filter.utils.muxer --connect auto-disc-source-ctf-fs:muxer --connect muxer:pretty"
99 test_bt_convert_run_args 'path non-option arg + --clock-offset' "$path_to_trace --clock-offset=15487" "--component auto-disc-source-ctf-fs:source.ctf.fs --params clock-class-offset-s=15487 --params 'inputs=[\"$path_to_trace\"]' --component pretty:sink.text.pretty --component muxer:filter.utils.muxer --connect auto-disc-source-ctf-fs:muxer --connect muxer:pretty"
100 test_bt_convert_run_args 'path non-option arg + --clock-offset-ns' "$path_to_trace --clock-offset-ns=326159487" "--component auto-disc-source-ctf-fs:source.ctf.fs --params clock-class-offset-ns=326159487 --params 'inputs=[\"$path_to_trace\"]' --component pretty:sink.text.pretty --component muxer:filter.utils.muxer --connect auto-disc-source-ctf-fs:muxer --connect muxer:pretty"
101 test_bt_convert_run_args 'path non-option arg + --clock-seconds' "$path_to_trace --clock-seconds" "--component auto-disc-source-ctf-fs:source.ctf.fs --params 'inputs=[\"$path_to_trace\"]' --component pretty:sink.text.pretty --params clock-seconds=yes --component muxer:filter.utils.muxer --connect auto-disc-source-ctf-fs:muxer --connect muxer:pretty"
102 test_bt_convert_run_args 'path non-option arg + --color' "$path_to_trace --color=never" "--component auto-disc-source-ctf-fs:source.ctf.fs --params 'inputs=[\"$path_to_trace\"]' --component pretty:sink.text.pretty --params 'color=\"never\"' --component muxer:filter.utils.muxer --connect auto-disc-source-ctf-fs:muxer --connect muxer:pretty"
103 test_bt_convert_run_args 'path non-option arg + --debug-info' "$path_to_trace --debug-info" "--component auto-disc-source-ctf-fs:source.ctf.fs --params 'inputs=[\"$path_to_trace\"]' --component pretty:sink.text.pretty --component muxer:filter.utils.muxer --component debug-info:filter.lttng-utils.debug-info --connect auto-disc-source-ctf-fs:muxer --connect muxer:debug-info --connect debug-info:pretty"
104 test_bt_convert_run_args 'path non-option arg + --debug-info-dir' "$path_to_trace --debug-info-dir=${output_path}" "--component auto-disc-source-ctf-fs:source.ctf.fs --params 'inputs=[\"$path_to_trace\"]' --component pretty:sink.text.pretty --component muxer:filter.utils.muxer --component debug-info:filter.lttng-utils.debug-info --params 'debug-info-dir=\"${output_path}\"' --connect auto-disc-source-ctf-fs:muxer --connect muxer:debug-info --connect debug-info:pretty"
105 test_bt_convert_run_args 'path non-option arg + --debug-info-target-prefix' "$path_to_trace --debug-info-target-prefix=${output_path}" "--component auto-disc-source-ctf-fs:source.ctf.fs --params 'inputs=[\"$path_to_trace\"]' --component pretty:sink.text.pretty --component muxer:filter.utils.muxer --component debug-info:filter.lttng-utils.debug-info --params 'target-prefix=\"${output_path}\"' --connect auto-disc-source-ctf-fs:muxer --connect muxer:debug-info --connect debug-info:pretty"
106 test_bt_convert_run_args 'path non-option arg + --debug-info-full-path' "$path_to_trace --debug-info-full-path" "--component auto-disc-source-ctf-fs:source.ctf.fs --params 'inputs=[\"$path_to_trace\"]' --component pretty:sink.text.pretty --component muxer:filter.utils.muxer --component debug-info:filter.lttng-utils.debug-info --params full-path=yes --connect auto-disc-source-ctf-fs:muxer --connect muxer:debug-info --connect debug-info:pretty"
107 test_bt_convert_run_args 'path non-option arg + --fields=trace:domain,loglevel' "--fields=trace:domain,loglevel $path_to_trace" "--component auto-disc-source-ctf-fs:source.ctf.fs --params 'inputs=[\"$path_to_trace\"]' --component pretty:sink.text.pretty --params field-trace:domain=yes,field-loglevel=yes,field-default=hide --component muxer:filter.utils.muxer --connect auto-disc-source-ctf-fs:muxer --connect muxer:pretty"
108 test_bt_convert_run_args 'path non-option arg + --fields=all' "--fields=all $path_to_trace" "--component auto-disc-source-ctf-fs:source.ctf.fs --params 'inputs=[\"$path_to_trace\"]' --component pretty:sink.text.pretty --params field-default=show --component muxer:filter.utils.muxer --connect auto-disc-source-ctf-fs:muxer --connect muxer:pretty"
109 test_bt_convert_run_args 'path non-option arg + --names=context,header' "--names=context,header $path_to_trace" "--component auto-disc-source-ctf-fs:source.ctf.fs --params 'inputs=[\"$path_to_trace\"]' --component pretty:sink.text.pretty --params name-context=yes,name-header=yes,name-default=hide --component muxer:filter.utils.muxer --connect auto-disc-source-ctf-fs:muxer --connect muxer:pretty"
110 test_bt_convert_run_args 'path non-option arg + --names=all' "--names=all $path_to_trace" "--component auto-disc-source-ctf-fs:source.ctf.fs --params 'inputs=[\"$path_to_trace\"]' --component pretty:sink.text.pretty --params name-default=show --component muxer:filter.utils.muxer --connect auto-disc-source-ctf-fs:muxer --connect muxer:pretty"
111 test_bt_convert_run_args 'path non-option arg + --no-delta' "$path_to_trace --no-delta" "--component auto-disc-source-ctf-fs:source.ctf.fs --params 'inputs=[\"$path_to_trace\"]' --component pretty:sink.text.pretty --params no-delta=yes --component muxer:filter.utils.muxer --connect auto-disc-source-ctf-fs:muxer --connect muxer:pretty"
112 test_bt_convert_run_args 'path non-option arg + --output' "$path_to_trace --output $output_path" "--component auto-disc-source-ctf-fs:source.ctf.fs --params 'inputs=[\"$path_to_trace\"]' --component pretty:sink.text.pretty --params 'path=\"$output_path\"' --component muxer:filter.utils.muxer --connect auto-disc-source-ctf-fs:muxer --connect muxer:pretty"
113 test_bt_convert_run_args 'path non-option arg + -i ctf' "$path_to_trace -i ctf" "--component auto-disc-source-ctf-fs:source.ctf.fs --params 'inputs=[\"$path_to_trace\"]' --component pretty:sink.text.pretty --component muxer:filter.utils.muxer --connect auto-disc-source-ctf-fs:muxer --connect muxer:pretty"
114 test_bt_convert_run_args 'URL non-option arg + -i lttng-live' 'net://some-host/host/target/session -i lttng-live' "--component lttng-live:source.ctf.lttng-live --params 'inputs=[\"net://some-host/host/target/session\"]' --params 'session-not-found-action=\"end\"' --component pretty:sink.text.pretty --component muxer:filter.utils.muxer --connect lttng-live:muxer --connect muxer:pretty"
115 test_bt_convert_run_args 'path non-option arg + -o dummy' "$path_to_trace -o dummy" "--component auto-disc-source-ctf-fs:source.ctf.fs --params 'inputs=[\"$path_to_trace\"]' --component dummy:sink.utils.dummy --component muxer:filter.utils.muxer --connect auto-disc-source-ctf-fs:muxer --connect muxer:dummy"
116 test_bt_convert_run_args 'path non-option arg + -o ctf + --output' "$path_to_trace -o ctf --output $output_path" "--component auto-disc-source-ctf-fs:source.ctf.fs --params 'inputs=[\"$path_to_trace\"]' --component sink-ctf-fs:sink.ctf.fs --params 'path=\"$output_path\"' --component muxer:filter.utils.muxer --connect auto-disc-source-ctf-fs:muxer --connect muxer:sink-ctf-fs"
117 test_bt_convert_run_args 'path non-option arg + user sink with log level' "$path_to_trace -c sink.mein.sink -lW" "--component sink.mein.sink:sink.mein.sink --log-level W --component auto-disc-source-ctf-fs:source.ctf.fs --params 'inputs=[\"$path_to_trace\"]' --component muxer:filter.utils.muxer --connect auto-disc-source-ctf-fs:muxer --connect 'muxer:sink\.mein\.sink'"
118
119 test_bt_convert_fails \
120 'bad --component format (plugin only)' \
121 '--component salut' \
122 "Invalid format for --component option's argument:"
123
124 test_bt_convert_fails \
125 'bad --component format (name and plugin only)' \
126 '--component name:salut' \
127 "Missing component class type (\`source\`, \`filter\`, or \`sink\`)."
128
129 test_bt_convert_fails \
130 'bad --component format (name only)' \
131 '--component name:' \
132 "Missing component class type (\`source\`, \`filter\`, or \`sink\`)."
133
134 test_bt_convert_fails \
135 'bad --component format (extra dot found)' \
136 '--component name:source.plugin.comp.cls' \
137 "Invalid format for --component option's argument:"
138
139 test_bt_convert_fails \
140 'duplicate component name' \
141 '--component hello:sink.a.b --component hello:source.c.d' \
142 'Duplicate component instance name:'
143
144 test_bt_convert_fails \
145 'unknown option' \
146 '--component hello:sink.a.b --salut' \
147 "Unknown option \`--salut\`"
148
149 # The error string spans two lines in this error message, it's not convenient to
150 # check for multiple lines, so we just check the first line.
151 test_bt_convert_fails \
152 '--params without current component' \
153 '--params lol=23' \
154 "No current component (--component option) or non-option argument of which to"
155
156 test_bt_convert_fails \
157 'duplicate --begin' \
158 '--begin abc --clock-seconds --begin cde' \
159 'At --begin option: --begin or --timerange option already specified'
160
161 test_bt_convert_fails \
162 'duplicate --end' \
163 '--begin abc --end xyz --clock-seconds --end cde' \
164 'At --end option: --end or --timerange option already specified'
165
166 test_bt_convert_fails \
167 '--begin and --timerange' \
168 '--begin abc --clock-seconds --timerange abc,def' \
169 'At --timerange option: --begin, --end, or --timerange option already specified'
170
171 test_bt_convert_fails \
172 '--end and --timerange' \
173 '--end abc --clock-seconds --timerange abc,def' \
174 'At --timerange option: --begin, --end, or --timerange option already specified'
175
176 test_bt_convert_fails \
177 'bad --timerange format (1)' \
178 '--timerange abc' \
179 "Invalid --timerange option's argument: expecting BEGIN,END or [BEGIN,END]:"
180
181 test_bt_convert_fails \
182 'bad --timerange format (2)' \
183 '--timerange abc,' \
184 "Invalid --timerange option's argument: expecting BEGIN,END or [BEGIN,END]:"
185
186 test_bt_convert_fails \
187 'bad --timerange format (3)' \
188 '--timerange ,cde' \
189 "Invalid --timerange option's argument: expecting BEGIN,END or [BEGIN,END]:"
190
191 test_bt_convert_fails \
192 'bad --fields format' \
193 '--fields salut' \
194 "Unknown field: \`salut\`."
195
196 test_bt_convert_fails \
197 'bad --names format' \
198 '--names salut' \
199 "Unknown name: \`salut\`."
200
201 test_bt_convert_fails \
202 'unknown -i' \
203 '-i lol' \
204 'Unknown legacy input format:'
205
206 test_bt_convert_fails \
207 'duplicate -i' \
208 '-i lttng-live --clock-seconds --input-format=ctf' \
209 'Duplicate --input-format option.'
210
211 test_bt_convert_fails \
212 'unknown -o' \
213 '-o lol' \
214 'Unknown legacy output format:'
215
216 test_bt_convert_fails \
217 'duplicate -o' \
218 '-o dummy --clock-seconds --output-format=text' \
219 'Duplicate --output-format option.'
220
221 test_bt_convert_fails \
222 '--run-args and --run-args-0' \
223 "$path_to_trace --run-args --run-args-0" \
224 'Cannot specify --run-args and --run-args-0.'
225
226 test_bt_convert_fails \
227 '-o ctf-metadata without path' \
228 '-o ctf-metadata' \
229 '--output-format=ctf-metadata specified without a path.'
230
231 test_bt_convert_fails \
232 '-i lttng-live and implicit source.ctf.fs' \
233 '-i lttng-live net://some-host/host/target/session --clock-offset=23' \
234 '--clock-offset specified, but no source.ctf.fs component instantiated.'
235
236 test_bt_convert_fails \
237 'implicit source.ctf.fs without path' \
238 '--clock-offset=23' \
239 '--clock-offset specified, but no source.ctf.fs component instantiated.'
240
241 test_bt_convert_fails \
242 'implicit source.ctf.lttng-live without URL' \
243 '-i lttng-live' \
244 "Missing URL for implicit \`source.ctf.lttng-live\` component."
245
246 test_bt_convert_fails \
247 'no source' \
248 '-o text' \
249 'No source component.'
250
251 test_bt_convert_fails \
252 '-o ctf without --output' \
253 'my-trace -o ctf' \
254 '--output-format=ctf specified without --output (trace output path).'
255
256 # The error string spans two lines in this error message, it's not convenient to
257 # check for multiple lines, so we just check the first line.
258 test_bt_convert_fails \
259 '-o ctf + --output with implicit sink.text.pretty' \
260 "my-trace -o ctf --output $output_path --no-delta" \
261 'Ambiguous --output option: --output-format=ctf specified but another option'
262
263 test_bt_convert_fails \
264 '--stream-intersection' \
265 "$path_to_trace --stream-intersection" \
266 'Cannot specify --stream-intersection with --run-args or --run-args-0.'
267
268 test_bt_convert_fails \
269 'two sinks with -o dummy + --clock-seconds' \
270 "$path_to_trace -o dummy --clock-seconds" \
271 'More than one sink component specified.'
272
273 test_bt_convert_fails \
274 'path non-option arg + user sink + -o text' \
275 "$path_to_trace --component=sink.abc.def -o text" \
276 'More than one sink component specified.'
277
278 rm -f "${tmp_stdout}"
279 rm -f "${tmp_stderr}"
This page took 0.044676 seconds and 5 git commands to generate.