summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rwxr-xr-xtests/py/nft-test.py6
-rwxr-xr-xtests/shell/run-tests.sh9
2 files changed, 15 insertions, 0 deletions
diff --git a/tests/py/nft-test.py b/tests/py/nft-test.py
index 01ee6c98..df97ed8e 100755
--- a/tests/py/nft-test.py
+++ b/tests/py/nft-test.py
@@ -1394,6 +1394,12 @@ def main():
# Change working directory to repository root
os.chdir(TESTS_PATH + "/../..")
+ try:
+ import unshare
+ unshare.unshare(unshare.CLONE_NEWNET)
+ except:
+ print_warning("cannot run in own namespace, connectivity might break")
+
check_lib_path = True
if args.library is None:
if args.host:
diff --git a/tests/shell/run-tests.sh b/tests/shell/run-tests.sh
index 26f8f46d..51c90c9b 100755
--- a/tests/shell/run-tests.sh
+++ b/tests/shell/run-tests.sh
@@ -22,6 +22,15 @@ if [ "$(id -u)" != "0" ] ; then
msg_error "this requires root!"
fi
+if [ "${1}" != "run" ]; then
+ if unshare -f -n true; then
+ unshare -n "${0}" run $@
+ exit $?
+ fi
+ msg_warn "cannot run in own namespace, connectivity might break"
+fi
+shift
+
[ -z "$NFT" ] && NFT=$SRC_NFT
if [ ! -x "$NFT" ] ; then
msg_error "no nft binary!"