[LTP] [PATCH 1/1] tst_net.sh: tst_rhost_run(): Go to LTP temporary directory first
Petr Vorel
pvorel@suse.cz
Fri May 15 15:36:13 CEST 2026
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
More information about the ltp
mailing list