Tests: stop execution if can't unmount any filesystem.
This commit is contained in:
@@ -26,8 +26,10 @@ from unit.http import TestHTTP
|
|||||||
from unit.log import Log
|
from unit.log import Log
|
||||||
from unit.option import option
|
from unit.option import option
|
||||||
from unit.status import Status
|
from unit.status import Status
|
||||||
|
from unit.utils import check_findmnt
|
||||||
from unit.utils import public_dir
|
from unit.utils import public_dir
|
||||||
from unit.utils import waitforfiles
|
from unit.utils import waitforfiles
|
||||||
|
from unit.utils import waitforunmount
|
||||||
|
|
||||||
|
|
||||||
def pytest_addoption(parser):
|
def pytest_addoption(parser):
|
||||||
@@ -87,6 +89,7 @@ _fds_info = {
|
|||||||
},
|
},
|
||||||
}
|
}
|
||||||
http = TestHTTP()
|
http = TestHTTP()
|
||||||
|
is_findmnt = check_findmnt()
|
||||||
|
|
||||||
|
|
||||||
def pytest_configure(config):
|
def pytest_configure(config):
|
||||||
@@ -315,6 +318,9 @@ def run(request):
|
|||||||
if not option.restart:
|
if not option.restart:
|
||||||
_clear_conf(unit['temp_dir'] + '/control.unit.sock', log=log)
|
_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']):
|
for item in os.listdir(unit['temp_dir']):
|
||||||
if item not in [
|
if item not in [
|
||||||
'control.unit.sock',
|
'control.unit.sock',
|
||||||
|
|||||||
@@ -72,12 +72,19 @@ def waitforsocket(port):
|
|||||||
pytest.fail('Can\'t connect to the 127.0.0.1:' + str(port))
|
pytest.fail('Can\'t connect to the 127.0.0.1:' + str(port))
|
||||||
|
|
||||||
|
|
||||||
def findmnt():
|
def check_findmnt():
|
||||||
try:
|
try:
|
||||||
out = subprocess.check_output(
|
return subprocess.check_output(
|
||||||
['findmnt', '--raw'], stderr=subprocess.STDOUT
|
['findmnt', '--raw'], stderr=subprocess.STDOUT
|
||||||
).decode()
|
).decode()
|
||||||
except FileNotFoundError:
|
except FileNotFoundError:
|
||||||
|
return False
|
||||||
|
|
||||||
|
|
||||||
|
def findmnt():
|
||||||
|
out = check_findmnt()
|
||||||
|
|
||||||
|
if not out:
|
||||||
pytest.skip('requires findmnt')
|
pytest.skip('requires findmnt')
|
||||||
|
|
||||||
return out
|
return out
|
||||||
|
|||||||
Reference in New Issue
Block a user