]> git.lttng.org Git - lttng-tools.git/commitdiff
Tests: Add path check to prevent incorrect redirection
authorErica Bugden <ebugden@efficios.com>
Mon, 8 Jul 2024 16:07:17 +0000 (12:07 -0400)
committerJérémie Galarneau <jeremie.galarneau@efficios.com>
Tue, 7 Jan 2025 20:52:00 +0000 (20:52 +0000)
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 <ebugden@efficios.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
tests/utils/utils.sh

index a6412ceab2f426e60ffc0be503d531200edc0e19..9daaa03c9eb5a2a4f4fd54f3d5947071ec53ee24 100644 (file)
@@ -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[@]}")
This page took 0.030305 seconds and 4 git commands to generate.