tests: fix shellcheck warning in plugins/src.ctf.lttng-live/test_live
authorSimon Marchi <simon.marchi@efficios.com>
Tue, 25 Feb 2020 19:29:28 +0000 (14:29 -0500)
committerSimon Marchi <simon.marchi@efficios.com>
Wed, 26 Feb 2020 14:10:00 +0000 (09:10 -0500)
shellcheck says:

    In test_live line 143:
            if ! "$BT_TESTS_BT2_BIN" $cli_args 1>"$cli_stdout_file" 2>"$cli_stderr_file"; then
                                     ^-------^ SC2086: Double quote to prevent globbing and word splitting.

    Did you mean:
            if ! "$BT_TESTS_BT2_BIN" "$cli_args" 1>"$cli_stdout_file" 2>"$cli_stderr_file"; then

In this case, we do want to pass the $cli_args string as multiple
arguments, so we don't want to just double-quote it.  Circumvent the
warning by splitting it explicitly into an array, then passing the array
using array expansion.  I think this is clearer anyway, as it shows the
intent of splitting the arguments more explicitly than relying in the
implicit splitting done by the shell.

Also, change it to use bt_cli, instead of running the babeltrace binary
by hand.

Change-Id: Idd277fc792e9a426213932566c3c096a53b56d9e
Signed-off-by: Simon Marchi <simon.marchi@efficios.com>
Reviewed-on: https://review.lttng.org/c/babeltrace/+/3140
Tested-by: jenkins <jenkins@lttng.org>
tests/plugins/src.ctf.lttng-live/test_live

index 891ce45ae858a7878d8e679043b040dc2317fb83..b06a72ef123d370081cc0ba3eb25cd9a39179815 100755 (executable)
@@ -139,8 +139,10 @@ get_cli_output_with_lttng_live_server() {
 
        cli_args=${cli_args_template//@PORT@/$port}
 
-       diag "Running CLI: 'babeltrace2 $cli_args'"
-       if ! "$BT_TESTS_BT2_BIN" $cli_args 1>"$cli_stdout_file" 2>"$cli_stderr_file"; then
+       # Split argument string by spaces into an array.
+       IFS=' ' read -ra cli_args <<< "$cli_args"
+
+       if ! bt_cli "$cli_stdout_file" "$cli_stderr_file" "${cli_args[@]}"; then
                # CLI failed: cancel everything else
                kill_lttng_live_server "$server_pid_file"
                wait
This page took 0.02539 seconds and 4 git commands to generate.