]> git.lttng.org Git - lttng-tools.git/commit
Tests: Support redirection to identical stderr/stdout in`_run_lttng_cmd`
authorKienan Stewart <kstewart@efficios.com>
Wed, 8 Jan 2025 14:22:02 +0000 (09:22 -0500)
committerJérémie Galarneau <jeremie.galarneau@efficios.com>
Wed, 8 Jan 2025 16:34:06 +0000 (16:34 +0000)
commitd3d763c4b4fe5f201cf5c9108f14ce0421f170e8
tree281843a56214ef9a8431473e16b5bdd6b17eccda
parentaae350f3c2ac878227bae41281e7abca65e33c0f
Tests: Support redirection to identical stderr/stdout in`_run_lttng_cmd`

Observed issue
==============

`tests/regression/kernel/test_userspace_probe` fails with the
following error:

```
Bail out! The current `_run_lttng_cmd` implementation does not support
redirecting stdout and stderr to the same file.
```

Cause
=====

The commit aae350f3c2ac878227bae41281e7abca65e33c0f ("Tests: Add path
check to prevent incorrect redirection") introduces a
safety check to bail out if the same stderr and stdout file are used
in `_run_lttng_cmd`. This avoids some foot-gun scenarios where output
is expected in a file from both, but the implementation didn't
actually support it.

E.g.,

```
$ (echo stderr >&1 ; echo stdout) > /tmp/a 2>/tmp/a
$ cat /tmp/a
stdout

$ (echo stderr >&1 ; echo stdout) > /tmp/a 2>&1
$ cat /tmp/a
stderr
stdout
```

There has been a number of changes to both `_run_lttng_cmd` for
logging, and it's common for both `stdout_dest` and `stderr_dest` to
be set (usually to `/dev/null`).

In particular, this check ends up being triggered in
`tests/regression/kernel/test_userspace_probe`:

```
1..175
 # Userspace probe - Testing userspace probe on ELF symbol
ok 1 - 0 LTTng modules loaded, expected count = 0
 # export LTTNG_SESSION_CONFIG_XSD_PATH=/root/workspace/lttng-tools_master_root_slesbuild/babeltrace_version/stable-2.0/build/std/conf/agents/liburcu_version/stable-0.14/node/sles15sp4-amd64-rootnode/platform/sles15sp4-amd64/src/lttng-tools/tests/../src/common/
 # env /root/workspace/lttng-tools_master_root_slesbuild/babeltrace_version/stable-2.0/build/std/conf/agents/liburcu_version/stable-0.14/node/sles15sp4-amd64-rootnode/platform/sles15sp4-amd64/src/lttng-tools/tests/../src/bin/lttng-sessiond/lttng-sessiond --consumerd64-path=/root/workspace/lttng-tools_master_root_slesbuild/babeltrace_version/stable-2.0/build/std/conf/agents/liburcu_version/stable-0.14/node/sles15sp4-amd64-rootnode/platform/sles15sp4-amd64/src/lttng-tools/tests/../src/bin/lttng-consumerd/lttng-consumerd 1
ok 2 - Start session daemon
 # Userspace probe enable on non-existant file
 # Killing (signal SIGTERM) lttng-sessiond and lt-lttng-sessiond pids: 18167 18182
Bail out! The current `_run_lttng_cmd` implementation does not support redirecting stdout and stderr to the same file.
 # Looks like you planned 175 tests but only ran 2.
```

Solution
========

Add support for invoking `_run_lttng_cmd` with the same stderr and
stdout destinations.

Known drawbacks
===============

None.

Change-Id: I9133ccfd1f524000dbf02dfc05730feca1c59ab7
Signed-off-by: Kienan Stewart <kstewart@efficios.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
tests/utils/utils.sh
This page took 0.02956 seconds and 4 git commands to generate.