tests: monitor: run-tests.sh: restore cwd before unshare
Florian Westphal
maintainerPATCH 1/1 tests: monitor: run-tests.sh: restore cwd before unshare
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.
--- tests/monitor/run-tests.sh | 2 ++ 1 file changed, 2 insertions(+)
tests/monitor/run-tests.sh +2 -0
@@ -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
Signature · 1 line
2.45.2
Phil Sutter
reviewerQuoted 7 lines · Florian Westphal
The monitor script no longer works if not called from tests/monitor directory:
%
tests/monitor/run-tests.sh
unshare: failed to executetests/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