Tests: whitespace fix in src.ctf.lttng-live/test_live
[babeltrace.git] / tests / plugins / src.ctf.lttng-live / test_live
index 7fed178234082789da66278b72c4d1315c666ba9..58a58514414daa6f6a0dfc81ffc5ed87ec54d8d4 100755 (executable)
@@ -1,20 +1,9 @@
 #!/bin/bash
 #
-# Copyright (C) 2019 Philippe Proulx <pproulx@efficios.com>
-#
-# This program is free software; you can redistribute it and/or
-# modify it under the terms of the GNU General Public License
-# as published by the Free Software Foundation; only version 2
-# of the License.
+# SPDX-License-Identifier: GPL-2.0-only
 #
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-# GNU General Public License for more details.
+# Copyright (C) 2019 Philippe Proulx <pproulx@efficios.com>
 #
-# You should have received a copy of the GNU General Public License
-# along with this program; if not, write to the Free Software
-# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
 
 # This test validates that a `src.ctf.fs` component successfully reads
 # specific CTF traces and creates the expected messages.
@@ -49,6 +38,14 @@ this_dir_relative="plugins/src.ctf.lttng-live"
 test_data_dir="$BT_TESTS_DATADIR/$this_dir_relative"
 trace_dir="$BT_CTF_TRACES_PATH/succeed"
 
+if [ "$BT_OS_TYPE" = "mingw" ]; then
+       # Same as the above, but in Windows form (C:\foo\bar) instead of Unix form
+       # (/c/foo/bar).
+       trace_dir_native=$(cygpath -w "${trace_dir}")
+else
+       trace_dir_native="${trace_dir}"
+fi
+
 lttng_live_server() {
        local port_file="$1"
        local pid_file="$2"
@@ -131,8 +128,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
@@ -178,7 +177,7 @@ run_test() {
        local cli_stderr
        local cli_stdout
        local port_file
-        local port
+       local port
 
        cli_stderr="$(mktemp -t test_live_stderr.XXXXXX)"
        cli_stdout="$(mktemp -t test_live_stdout.XXXXXX)"
@@ -210,7 +209,7 @@ test_list_sessions() {
 
        local test_text="CLI prints the expected session list"
        local cli_args_template="-i lttng-live net://localhost:@PORT@"
-       local server_args="'multi-domains,0,hostname,1,0,${trace_dir}/multi-domains/ust/' 'multi-domains,1,hostname,1,0,${trace_dir}/multi-domains/kernel/' 'trace-with-index,2,hostname,1,0,${trace_dir}/trace-with-index/' "
+       local server_args="'multi-domains,0,hostname,1,0,${trace_dir_native}/multi-domains/ust/' 'multi-domains,1,hostname,1,0,${trace_dir_native}/multi-domains/kernel/' 'trace-with-index,2,hostname,1,0,${trace_dir_native}/trace-with-index/' "
 
        template_expected=$(<"$test_data_dir/cli-list-sessions.expect")
        cli_stderr="$(mktemp -t test_live_list_sessions_stderr.XXXXXX)"
@@ -245,7 +244,7 @@ test_base() {
        # discarded events.
        local test_text="CLI attach and fetch from single-domains session - no discarded events"
        local cli_args_template="-i lttng-live net://localhost:@PORT@/host/hostname/trace-with-index -c sink.text.details"
-       local server_args="'trace-with-index,0,hostname,1,0,${trace_dir}/trace-with-index/'"
+       local server_args="'trace-with-index,0,hostname,1,0,${trace_dir_native}/trace-with-index/'"
        local expected_stdout="${test_data_dir}/cli-base.expect"
        local expected_stderr
 
@@ -262,7 +261,7 @@ test_multi_domains() {
        # events.
        local test_text="CLI attach and fetch from multi-domains session - discarded events"
        local cli_args_template="-i lttng-live net://localhost:@PORT@/host/hostname/multi-domains -c sink.text.details"
-       local server_args="'multi-domains,0,hostname,1,0,${trace_dir}/multi-domains/kernel/,${trace_dir}/multi-domains/ust/'"
+       local server_args="'multi-domains,0,hostname,1,0,${trace_dir_native}/multi-domains/kernel/,${trace_dir_native}/multi-domains/ust/'"
        local expected_stdout="${test_data_dir}/cli-multi-domains.expect"
        local expected_stderr
 
@@ -282,7 +281,7 @@ test_rate_limited() {
        # The packet size of the test trace is 4k. Limit requests to 1k.
        local test_text="CLI many requests per packet"
        local cli_args_template="-i lttng-live net://localhost:@PORT@/host/hostname/trace-with-index -c sink.text.details"
-       local server_args="--max-query-data-response-size 1024 'trace-with-index,0,hostname,1,0,${trace_dir}/trace-with-index/'"
+       local server_args="--max-query-data-response-size 1024 'trace-with-index,0,hostname,1,0,${trace_dir_native}/trace-with-index/'"
        local expected_stdout="${test_data_dir}/cli-base.expect"
        local expected_stderr
 
@@ -301,8 +300,8 @@ test_compare_to_ctf_fs() {
        # that ordering is consistent between live and ctf fs.
        local test_text="CLI src.ctf.fs vs src.ctf.lttng-live"
        local cli_args_template="-i lttng-live net://localhost:@PORT@/host/hostname/multi-domains -c sink.text.details --params with-trace-name=false,with-stream-name=false"
-       local server_args="'multi-domains,0,hostname,1,0,${trace_dir}/multi-domains/kernel/' 'multi-domains,1,hostname,1,0,${trace_dir}/multi-domains/ust/'"
-       local server_args_inverse="'multi-domains,0,hostname,1,0,${trace_dir}/multi-domains/ust/' 'multi-domains,1,hostname,1,0,${trace_dir}/multi-domains/kernel/'"
+       local server_args="'multi-domains,0,hostname,1,0,${trace_dir_native}/multi-domains/kernel/' 'multi-domains,1,hostname,1,0,${trace_dir_native}/multi-domains/ust/'"
+       local server_args_inverse="'multi-domains,0,hostname,1,0,${trace_dir_native}/multi-domains/ust/' 'multi-domains,1,hostname,1,0,${trace_dir_native}/multi-domains/kernel/'"
        local expected_stdout
        local expected_stderr
 
@@ -310,6 +309,8 @@ test_compare_to_ctf_fs() {
        expected_stderr="$(mktemp -t test_live_compare_stderr_expected.XXXXXX)"
 
        bt_cli "$expected_stdout" "$expected_stderr" "${trace_dir}/multi-domains" -c sink.text.details --params "with-trace-name=false,with-stream-name=false"
+       bt_remove_cr "${expected_stdout}"
+       bt_remove_cr "${expected_stderr}"
        run_test "$test_text" "$cli_args_template" "$server_args" "$expected_stdout" "$expected_stderr"
        diag "Inverse session order from lttng-relayd"
        run_test "$test_text" "$cli_args_template" "$server_args_inverse" "$expected_stdout" "$expected_stderr"
This page took 0.025023 seconds and 4 git commands to generate.