summaryrefslogtreecommitdiffhomepage
path: root/test/unit/utils.py
diff options
context:
space:
mode:
authorAndrei Zeliankou <zelenkov@nginx.com>2020-12-09 16:15:50 +0000
committerAndrei Zeliankou <zelenkov@nginx.com>2020-12-09 16:15:50 +0000
commit4c846ae69308983050a55f6467c2d53e78120e0b (patch)
treee3554147a322a883fb63cdfd7d1740980da12589 /test/unit/utils.py
parent783cdc2a3d99bd9fb8d75218d679ddb571420e98 (diff)
downloadunit-4c846ae69308983050a55f6467c2d53e78120e0b.tar.gz
unit-4c846ae69308983050a55f6467c2d53e78120e0b.tar.bz2
Tests: isolation check moved to the pytest_sessionstart().
This change eliminates the need for some classes to run Unit one more time before running tests.
Diffstat (limited to '')
-rw-r--r--test/unit/utils.py12
1 files changed, 12 insertions, 0 deletions
diff --git a/test/unit/utils.py b/test/unit/utils.py
index f24e9728..1307a4f6 100644
--- a/test/unit/utils.py
+++ b/test/unit/utils.py
@@ -48,3 +48,15 @@ def waitforsocket(port):
pytest.fail('Can\'t connect to the 127.0.0.1:' + port)
+
+def getns(nstype):
+ # read namespace id from symlink file:
+ # it points to: '<nstype>:[<ns id>]'
+ # # eg.: 'pid:[4026531836]'
+ nspath = '/proc/self/ns/' + nstype
+ data = None
+
+ if os.path.exists(nspath):
+ data = int(os.readlink(nspath)[len(nstype) + 2 : -1])
+
+ return data