]> git.ipfire.org Git - thirdparty/nftables.git/commitdiff
Revert "tests: py: use `os.unshare` Python function"
authorPhil Sutter <phil@nwl.cc>
Fri, 13 Mar 2026 10:36:20 +0000 (11:36 +0100)
committerPhil Sutter <phil@nwl.cc>
Fri, 13 Mar 2026 10:44:25 +0000 (11:44 +0100)
This reverts commit c29407ab300f8ed54b5ca27cf4837c0aab920760.

This change breaks 'time' expression tests in py test suite. It looks
like with os.unshare, modifications to os.environ are lost. Neither
unshare module nor unshare command suffer from this problem.

Fixes: c29407ab300f8 ("tests: py: use `os.unshare` Python function")
Suggested-by: Jeremy Sowden <jeremy@azazel.net>
Suggested-by: Pablo Neira Ayuso <pablo@netfilter.org>
Signed-off-by: Phil Sutter <phil@nwl.cc>
tests/py/nft-test.py

index 64837da36035974dd1bcf958c3684c71e5fa40d3..53fd3f7ae6fea1b9f758cff64f48e57c93f564c4 100755 (executable)
@@ -1466,14 +1466,7 @@ def run_test_file(filename, force_all_family_option, specific_file):
     return [tests, passed, total_warning, total_error, total_unit_run]
 
 def spawn_netns():
-    # prefer stdlib unshare function ...
-    try:
-        os.unshare(os.CLONE_NEWNET)
-        return True
-    except Exception as e:
-        pass
-
-    # ... or unshare module
+    # prefer unshare module
     try:
         import unshare
         unshare.unshare(unshare.CLONE_NEWNET)