Skip to contentSkip to conversation

Revert "tests: py: use `os.unshare` Python function"

PATCH In review Phil Sutter 1 participant 2 messages Mar 13 netfilter

lore
Share & tools
lore

Phil Sutter

author reviewer
#0 lore raw

PATCH 1/1 Revert "tests: py: use `os.unshare` Python function"

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")
---
 tests/py/nft-test.py | 9 +--------
 1 file changed, 1 insertion(+), 8 deletions(-)
tests/py/nft-test.py +1 -8
index 64837da360359..53fd3f7ae6fea 100755
@@ -1466,14 +1466,7 @@ def set_delete_elements(set_element, set_name, table, filename=None,
     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)
Signature · 1 line
2.51.0
author reviewer
#1 lore raw
Quoted 10 lines · Phil Sutter

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")

Patch applied.