]> git.ipfire.org Git - thirdparty/nftables.git/commitdiff
tests: monitor: Run in own netns
authorPhil Sutter <phil@nwl.cc>
Wed, 2 Oct 2024 16:17:07 +0000 (18:17 +0200)
committerPhil Sutter <phil@nwl.cc>
Wed, 6 Nov 2024 10:00:21 +0000 (11:00 +0100)
Have the script call itself prefixed by unshare. This won't prevent
clashing test case contents, but at least leave the host netns alone.

Signed-off-by: Phil Sutter <phil@nwl.cc>
tests/monitor/run-tests.sh

index f1ac790acf80c343f8b30adaf073517f031b643e..214512d269e8da6fc1265503c9901a97fb3c82f0 100755 (executable)
@@ -120,6 +120,14 @@ echo_run_test() {
        return $rc
 }
 
+netns=true
+for arg in "$@"; do
+       [[ "$arg" == "--no-netns" ]] && netns=false
+done
+if $netns; then
+       exec unshare -n $0 --no-netns "$@"
+fi
+
 testcases=""
 while [ -n "$1" ]; do
        case "$1" in
@@ -131,6 +139,9 @@ while [ -n "$1" ]; do
                test_json=true
                shift
                ;;
+       --no-netns)
+               shift
+               ;;
        -H|--host)
                nft=nft
                shift