From aae350f3c2ac878227bae41281e7abca65e33c0f Mon Sep 17 00:00:00 2001 From: Erica Bugden Date: Mon, 8 Jul 2024 12:07:17 -0400 Subject: [PATCH] Tests: Add path check to prevent incorrect redirection MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit The current implementation of `run_lttng_cmd` does not support redirecting `stdout` and `stderr` to the same file. In the current implementation: $TESTDIR/../src/bin/lttng/$LTTNG_BIN "$@" 1> "$stdout_dest" 2> "$stderr_dest" the redirection of stderr would overwrite the redirection of stdout. Add a check to bail out if the redirection paths are the same since the test will not be as expected. Change-Id: Ia8883f4978e4c0e534db1422a5aebf392403e723 Signed-off-by: Erica Bugden Signed-off-by: Jérémie Galarneau --- tests/utils/utils.sh | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/tests/utils/utils.sh b/tests/utils/utils.sh index a6412ceab..9daaa03c9 100644 --- a/tests/utils/utils.sh +++ b/tests/utils/utils.sh @@ -521,6 +521,12 @@ function _run_lttng_cmd local stderr_dest="$2" shift 2 + if [ "$stdout_dest" = "$stderr_dest" ]; then + # The redirection of stderr would overwrite the redirection of + # stdout. We cannot proceed. + LTTNG_BAIL_OUT "The current \`_run_lttng_cmd\` implementation does not support redirecting stdout and stderr to the same file." + fi + opts=("${@}") if [[ -n "${LTTNG_TEST_VERBOSE_CLIENT}" ]] ; then opts=('-vvv' "${opts[@]}") -- 2.39.5