From da1375faf157c03995f32c8503dc6d9bedb0d309 Mon Sep 17 00:00:00 2001 From: Simon Marchi Date: Tue, 1 Oct 2019 18:21:54 -0400 Subject: [PATCH] tests: remove CR characters from expected file in test_live 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 Change-Id: Ie5fac78260e5bb8102d3c7f9cc3b4a1b21cf773d Reviewed-on: https://review.lttng.org/c/babeltrace/+/2114 Tested-by: jenkins Reviewed-by: Michael Jeanson --- tests/plugins/src.ctf.lttng-live/test_live | 2 ++ tests/utils/utils.sh | 8 +++++++- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/tests/plugins/src.ctf.lttng-live/test_live b/tests/plugins/src.ctf.lttng-live/test_live index 20da1ae9..891ce45a 100755 --- a/tests/plugins/src.ctf.lttng-live/test_live +++ b/tests/plugins/src.ctf.lttng-live/test_live @@ -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" diff --git a/tests/utils/utils.sh b/tests/utils/utils.sh index 36c75fe0..6c87f309 100644 --- a/tests/utils/utils.sh +++ b/tests/utils/utils.sh @@ -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 -- 2.34.1