All of lore.kernel.org
 help / color / mirror / Atom feed
* [LTP] [PATCH 1/1] tst_net.sh: tst_rhost_run(): Go to LTP temporary directory first
@ 2026-05-15 13:36 Petr Vorel
  2026-05-15 15:16 ` [LTP] " linuxtestproject.agent
                   ` (2 more replies)
  0 siblings, 3 replies; 5+ messages in thread
From: Petr Vorel @ 2026-05-15 13:36 UTC (permalink / raw)
  To: ltp

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(+)

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
-- 
2.54.0


-- 
Mailing list info: https://lists.linux.it/listinfo/ltp

^ permalink raw reply related	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2026-05-24 19:22 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-05-15 13:36 [LTP] [PATCH 1/1] tst_net.sh: tst_rhost_run(): Go to LTP temporary directory first Petr Vorel
2026-05-15 15:16 ` [LTP] " linuxtestproject.agent
2026-05-19  8:54 ` [LTP] [PATCH 1/1] " Andrea Cervesato via ltp
2026-05-22 14:19 ` Cyril Hrubis
2026-05-24 19:22   ` Petr Vorel

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.