summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorAndrei Zeliankou <zelenkov@nginx.com>2022-12-12 16:27:02 +0000
committerAndrei Zeliankou <zelenkov@nginx.com>2022-12-12 16:27:02 +0000
commit12e2cbae8a0bf190c8e7d98de6c08aff57d2ae4f (patch)
treefad5218a0d5759c621db575ee318dfd836ccbbc8
parent648e91a623d3822e8ab4780b452da211ea3ba257 (diff)
downloadunit-12e2cbae8a0bf190c8e7d98de6c08aff57d2ae4f.tar.gz
unit-12e2cbae8a0bf190c8e7d98de6c08aff57d2ae4f.tar.bz2
Tests: stop execution if can't unmount any filesystem.
-rw-r--r--test/conftest.py6
-rw-r--r--test/unit/utils.py11
2 files changed, 15 insertions, 2 deletions
diff --git a/test/conftest.py b/test/conftest.py
index c2680744..4a1aa7cc 100644
--- a/test/conftest.py
+++ b/test/conftest.py
@@ -26,8 +26,10 @@ from unit.http import TestHTTP
from unit.log import Log
from unit.option import option
from unit.status import Status
+from unit.utils import check_findmnt
from unit.utils import public_dir
from unit.utils import waitforfiles
+from unit.utils import waitforunmount
def pytest_addoption(parser):
@@ -87,6 +89,7 @@ _fds_info = {
},
}
http = TestHTTP()
+is_findmnt = check_findmnt()
def pytest_configure(config):
@@ -315,6 +318,9 @@ def run(request):
if not option.restart:
_clear_conf(unit['temp_dir'] + '/control.unit.sock', log=log)
+ if is_findmnt and not waitforunmount(unit['temp_dir'], timeout=600):
+ exit('Could not unmount some filesystems in tmp dir.')
+
for item in os.listdir(unit['temp_dir']):
if item not in [
'control.unit.sock',
diff --git a/test/unit/utils.py b/test/unit/utils.py
index f9e9d08a..d6590b97 100644
--- a/test/unit/utils.py
+++ b/test/unit/utils.py
@@ -72,12 +72,19 @@ def waitforsocket(port):
pytest.fail('Can\'t connect to the 127.0.0.1:' + str(port))
-def findmnt():
+def check_findmnt():
try:
- out = subprocess.check_output(
+ return subprocess.check_output(
['findmnt', '--raw'], stderr=subprocess.STDOUT
).decode()
except FileNotFoundError:
+ return False
+
+
+def findmnt():
+ out = check_findmnt()
+
+ if not out:
pytest.skip('requires findmnt')
return out