summaryrefslogtreecommitdiffhomepage
path: root/test/unit
diff options
context:
space:
mode:
authorAndrei Zeliankou <zelenkov@nginx.com>2021-01-13 06:24:26 +0000
committerAndrei Zeliankou <zelenkov@nginx.com>2021-01-13 06:24:26 +0000
commitdb9b70932b2e3e4df8b4bcdb24fedce042da15aa (patch)
treededd05da4454b40dc66eb2f1d62fb758ed84dfc3 /test/unit
parent6dc9c47ccd26b23b61b7522803a667c2e515e260 (diff)
downloadunit-db9b70932b2e3e4df8b4bcdb24fedce042da15aa.tar.gz
unit-db9b70932b2e3e4df8b4bcdb24fedce042da15aa.tar.bz2
Tests: waitformount() and waitforunmount() introduced.
Diffstat (limited to 'test/unit')
-rw-r--r--test/unit/utils.py32
1 files changed, 32 insertions, 0 deletions
diff --git a/test/unit/utils.py b/test/unit/utils.py
index 1307a4f6..7a0a3fe5 100644
--- a/test/unit/utils.py
+++ b/test/unit/utils.py
@@ -1,5 +1,6 @@
import os
import socket
+import subprocess
import time
import pytest
@@ -49,6 +50,37 @@ def waitforsocket(port):
pytest.fail('Can\'t connect to the 127.0.0.1:' + port)
+def findmnt():
+ try:
+ out = subprocess.check_output(
+ ['findmnt', '--raw'], stderr=subprocess.STDOUT
+ ).decode()
+ except FileNotFoundError:
+ pytest.skip('requires findmnt')
+
+ return out
+
+
+def waitformount(template, wait=50):
+ for i in range(wait):
+ if findmnt().find(template) != -1:
+ return True
+
+ time.sleep(0.1)
+
+ return False
+
+
+def waitforunmount(template, wait=50):
+ for i in range(wait):
+ if findmnt().find(template) == -1:
+ return True
+
+ time.sleep(0.1)
+
+ return False
+
+
def getns(nstype):
# read namespace id from symlink file:
# it points to: '<nstype>:[<ns id>]'