Tests: waitformount() and waitforunmount() introduced.
This commit is contained in:
@@ -1,5 +1,6 @@
|
|||||||
import os
|
import os
|
||||||
import socket
|
import socket
|
||||||
|
import subprocess
|
||||||
import time
|
import time
|
||||||
|
|
||||||
import pytest
|
import pytest
|
||||||
@@ -49,6 +50,37 @@ def waitforsocket(port):
|
|||||||
pytest.fail('Can\'t connect to the 127.0.0.1:' + 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):
|
def getns(nstype):
|
||||||
# read namespace id from symlink file:
|
# read namespace id from symlink file:
|
||||||
# it points to: '<nstype>:[<ns id>]'
|
# it points to: '<nstype>:[<ns id>]'
|
||||||
|
|||||||
Reference in New Issue
Block a user