* [PATCH nft] tests: monitor: run-tests.sh: restore cwd before unshare
@ 2024-11-07 12:56 Florian Westphal
2024-11-07 13:39 ` Phil Sutter
0 siblings, 1 reply; 2+ messages in thread
From: Florian Westphal @ 2024-11-07 12:56 UTC (permalink / raw)
To: netfilter-devel; +Cc: phil, Florian Westphal
The monitor script no longer works if not called from tests/monitor directory:
% tests/monitor/run-tests.sh
unshare: failed to execute tests/monitor/run-tests.sh: No such file or directory
... because the script will change the directory.
Stash and restore to old one so unshare $0 can work.
Signed-off-by: Florian Westphal <fw@strlen.de>
---
tests/monitor/run-tests.sh | 2 ++
1 file changed, 2 insertions(+)
diff --git a/tests/monitor/run-tests.sh b/tests/monitor/run-tests.sh
index 214512d269e8..7a8b1a719dc1 100755
--- a/tests/monitor/run-tests.sh
+++ b/tests/monitor/run-tests.sh
@@ -1,5 +1,6 @@
#!/bin/bash
+pushd .
cd $(dirname $0)
nft=${NFT:-../../src/nft}
debug=false
@@ -125,6 +126,7 @@ for arg in "$@"; do
[[ "$arg" == "--no-netns" ]] && netns=false
done
if $netns; then
+ popd
exec unshare -n $0 --no-netns "$@"
fi
--
2.45.2
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH nft] tests: monitor: run-tests.sh: restore cwd before unshare
2024-11-07 12:56 [PATCH nft] tests: monitor: run-tests.sh: restore cwd before unshare Florian Westphal
@ 2024-11-07 13:39 ` Phil Sutter
0 siblings, 0 replies; 2+ messages in thread
From: Phil Sutter @ 2024-11-07 13:39 UTC (permalink / raw)
To: Florian Westphal; +Cc: netfilter-devel
On Thu, Nov 07, 2024 at 01:56:53PM +0100, Florian Westphal wrote:
> The monitor script no longer works if not called from tests/monitor directory:
>
> % tests/monitor/run-tests.sh
> unshare: failed to execute tests/monitor/run-tests.sh: No such file or directory
>
> ... because the script will change the directory.
> Stash and restore to old one so unshare $0 can work.
Still not perfect:
| % sudo ./tests/monitor/run-tests.sh ./tests/monitor/testcases/set-maps.t
| /home/n0-1/git/nftables /home/n0-1/git/nftables
| /home/n0-1/git/nftables
| /home/n0-1/git/nftables /home/n0-1/git/nftables
| unknown option './tests/monitor/testcases/set-maps.t'
| Usage: run-tests.sh [-j|--json] [-d|--debug] [testcase ...]
AFAICT, $(dirname $0) is only needed to locate the local nft binary. Let
me send a patch which eliminates the cd call entirely.
Cheers, Phil
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2024-11-07 13:39 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-11-07 12:56 [PATCH nft] tests: monitor: run-tests.sh: restore cwd before unshare Florian Westphal
2024-11-07 13:39 ` Phil Sutter
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox