tests: remove CR characters from expected file in test_live
authorSimon Marchi <simon.marchi@efficios.com>
Tue, 1 Oct 2019 22:21:54 +0000 (18:21 -0400)
committerJérémie Galarneau <jeremie.galarneau@efficios.com>
Thu, 3 Oct 2019 14:45:11 +0000 (10:45 -0400)
Tests done by test_compare_to_ctf_fs in test_live don't work on Windows.
When comparing the expected and actual files, the expected file has CRLF
end of lines while the actual file has LF end of lines.  This can be
unexpected, as both are produced by sink.text.details.

The reason is that bt_diff strips CR characters from the actual file.
This is done so actual files match the expect files, which typically are
static (not generated) and don't contain CR characters.

This patch makes test_live also strip CR characters from the expected
files it generates.

One might wonder, why not just make bt_diff strip both files of their CR
characters.  I prefer not to do that, because most files passed as
"expect" files to that function are files from the source tree.  These
files should not be modified by building and testing.  In other words,
it should be possible to run a make check while the source tree is on a
read-only filesystem.

Signed-off-by: Simon Marchi <simon.marchi@efficios.com>
Change-Id: Ie5fac78260e5bb8102d3c7f9cc3b4a1b21cf773d
Reviewed-on: https://review.lttng.org/c/babeltrace/+/2114
Tested-by: jenkins <jenkins@lttng.org>
Reviewed-by: Michael Jeanson <mjeanson@efficios.com>
tests/plugins/src.ctf.lttng-live/test_live
tests/utils/utils.sh

index 20da1ae96edd0c689734f08aaa8923aed7fd97bb..891ce45ae858a7878d8e679043b040dc2317fb83 100755 (executable)
@@ -318,6 +318,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"
index 36c75fe05a350cf5f172a1ecde769ee14f878c02..6c87f309df9efdbb6ac66437fab9727e89d1e358 100644 (file)
@@ -134,6 +134,12 @@ export BT_TESTS_SED_BIN
 BT_TESTS_DATADIR="${BT_TESTS_SRCDIR}/data"
 BT_CTF_TRACES_PATH="${BT_TESTS_DATADIR}/ctf-traces"
 
+# Remove CR characters in file "$1".
+
+bt_remove_cr() {
+       "$BT_TESTS_SED_BIN" -i 's/\r//g' "$1"
+}
+
 # Run the Babeltrace CLI, redirecting stdout and stderr to specified files.
 #
 #   $1: file to redirect stdout to
@@ -173,7 +179,7 @@ bt_diff() {
        # Strip any \r present due to Windows (\n -> \r\n).
        # "diff --string-trailing-cr" is not used since it is not present on
        # Solaris.
-       "$BT_TESTS_SED_BIN" -i 's/\r//g' "$actual_file"
+       bt_remove_cr "$actual_file"
 
        diff -u "$expected_file" "$actual_file" 1>&2
 
This page took 0.025363 seconds and 4 git commands to generate.