diff mbox series

[1/1] tst_net.sh: tst_rhost_run(): Go to LTP temporary directory first

Message ID 20260515133613.31249-1-pvorel@suse.cz
State Accepted
Headers show
Series [1/1] tst_net.sh: tst_rhost_run(): Go to LTP temporary directory first | expand

Checks

Context Check Description
ltpci/github-build-doc success success
ltpci/github-build-debian_stable_s390x-linux-gnu-gcc_s390x success success
ltpci/github-build-debian_stable_powerpc64le-linux-gnu-gcc_ppc64el success success
ltpci/github-build-debian_stable_aarch64-linux-gnu-gcc_arm64 success success
ltpci/github-build-ubuntu_jammy_gcc success success
ltpci/github-build-debian_stable_gcc success success
ltpci/github-build-debian_stable_gcc success success
ltpci/github-build-quay-io-centos-centos_stream9_gcc success success
ltpci/github-build-debian_testing_clang success success
ltpci/github-build-fedora_latest_clang success success
ltpci/github-build-debian_oldstable_clang success success
ltpci/github-build-debian_testing_gcc success success
ltpci/github-build-alpine_latest_gcc success success
ltpci/github-build-opensuse-archive_42-2_gcc success success
ltpci/github-build-debian_oldstable_gcc success success
ltpci/github-build-ubuntu_noble_gcc success success
ltpci/github-build-opensuse-leap_latest_gcc success success
ltpci/copilot-review success Approved

Commit Message

Petr Vorel May 15, 2026, 1:36 p.m. UTC
LTP API changes the current working directory when TST_NEEDS_TMPDIR=1
(or .needs_tmpdir = 1S in C API) is set (even legacy shell API test.sh
does that). But this was not true for tst_rhost_run() function in
tst_net.sh, it executed command in the default directory (user home
directory in case of 2 host ssh based setup and / (root) in case of
single host netns based setup).

That is problem on it's own, but it causes problems on read-only root
filesystem.  Wireguard tests in wireguard_lib.sh write file as part of
tst_rhost_run() call:

    tst_rhost_run -s -c "echo '$(cat wg1.key)' > wg1.key"

Which obviously fails on RO /:

    2>&1: line 1: wg1.key: Read-only file system
    wireguard01 1 TBROK: 'echo 'MCqLzPqBbgU/4YOJCH1rrdbOiVFPCWgDpgYZ/hj622A=' > wg1.key' failed on NETNS: ''

While Wireguard tests looks to be the only one which redirect output to
a file in tst_rhost_run() command, it's better to fix the API behavior
instead passing full path ($TST_TMPDIR/wg1.key) to tst_rhost_run().

Reported-by: Petr Cervinka <pcervinka@suse.com>
Fixes: b3906f73cf ("lib: setup rhost TST_TMPDIR if net test sets TST_NEEDS_TMPDIR")
Signed-off-by: Petr Vorel <pvorel@suse.cz>
---
 testcases/lib/tst_net.sh | 3 +++
 1 file changed, 3 insertions(+)

Comments

linuxtestproject.agent@gmail.com May 15, 2026, 3:16 p.m. UTC | #1
Hi Petr,

On Fri, 15 May 2026 15:36:13 +0200, Petr Vorel wrote:
> tst_net.sh: tst_rhost_run(): Go to LTP temporary directory first

> +	[ "$TST_TMPDIR_RHOST" = 1 ] && cmd="cd $TST_TMPDIR; $cmd"

Reviewed-by: LTP AI Reviewer <ltp-ai@noreply.github.com>

Pre-existing issues noticed in the surrounding code (not introduced
by this patch):

- testcases/lib/tst_net.sh:1216 — "workaround" keyword in tst_res_ TINFO
  message; not a G1 violation but worth a note if ever revisiting that path.

---
Note:

Our agent completed the review of the patch. The agent can sometimes
produce false positives although often its findings are genuine. If you
find issues with the review, please comment this email or ignore the
suggestions.

Regards,
LTP AI Reviewer
Andrea Cervesato May 19, 2026, 8:54 a.m. UTC | #2
Reviewed-by: Andrea Cervesato <andrea.cervesato@suse.com>

--
Andrea Cervesato
SUSE QE Automation Engineer Linux
andrea.cervesato@suse.com
Cyril Hrubis May 22, 2026, 2:19 p.m. UTC | #3
Hi!
Reviewed-by: Cyril Hrubis <chrubis@suse.cz>

Have you tested this change? If it does not cause any regression it
should be applied before the release.
Petr Vorel May 24, 2026, 7:22 p.m. UTC | #4
> Hi!
> Reviewed-by: Cyril Hrubis <chrubis@suse.cz>

> Have you tested this change? If it does not cause any regression it
> should be applied before the release.

Yes, I run most of the networking tests. It should be safe so I merged now, in
case of a potential regression is spot early next week.

Kind regards,
Petr
diff mbox series

Patch

diff --git a/testcases/lib/tst_net.sh b/testcases/lib/tst_net.sh
index 38435dea74..4e5c1e854a 100644
--- a/testcases/lib/tst_net.sh
+++ b/testcases/lib/tst_net.sh
@@ -265,6 +265,9 @@  tst_rhost_run()
 		return 1
 	fi
 
+	# go to $TST_TMPDIR before executing the command (once directory created)
+	[ "$TST_TMPDIR_RHOST" = 1 ] && cmd="cd $TST_TMPDIR; $cmd"
+
 	sh_cmd="$pre_cmd $cmd $post_cmd"
 
 	if [ -n "${TST_USE_NETNS:-}" ]; then