summaryrefslogtreecommitdiffhomepage
path: root/test/unit/utils.py
diff options
context:
space:
mode:
authorOisin Canty <o.canty@f5.com>2021-07-02 13:00:57 +0000
committerOisin Canty <o.canty@f5.com>2021-07-02 13:00:57 +0000
commit8c83652c2a0ad7386e27a9ea595c996d3dce018c (patch)
tree154281c0fc0216f5588f6a9c7f96a79c500737a5 /test/unit/utils.py
parent6c14d5d7b1921bd78f2d1b7458eae7d97eee0fcd (diff)
downloadunit-8c83652c2a0ad7386e27a9ea595c996d3dce018c.tar.gz
unit-8c83652c2a0ad7386e27a9ea595c996d3dce018c.tar.bz2
Tests: Ruby hooks.
Diffstat (limited to '')
-rw-r--r--test/unit/utils.py28
1 files changed, 22 insertions, 6 deletions
diff --git a/test/unit/utils.py b/test/unit/utils.py
index a627e9f5..43aaa81b 100644
--- a/test/unit/utils.py
+++ b/test/unit/utils.py
@@ -1,3 +1,4 @@
+import glob
import os
import socket
import subprocess
@@ -16,8 +17,8 @@ def public_dir(path):
os.chmod(os.path.join(root, f), 0o777)
-def waitforfiles(*files):
- for i in range(50):
+def waitforfiles(*files, timeout=50):
+ for i in range(timeout):
wait = False
for f in files:
@@ -33,6 +34,21 @@ def waitforfiles(*files):
return False
+def waitforglob(pattern, count=1, timeout=50):
+ for i in range(timeout):
+ n = 0
+
+ for f in glob.glob(pattern):
+ n += 1
+
+ if n == count:
+ return True
+
+ time.sleep(0.1)
+
+ return False
+
+
def waitforsocket(port):
for i in range(50):
with socket.socket(socket.AF_INET, socket.SOCK_STREAM) as sock:
@@ -72,8 +88,8 @@ def sysctl():
return out
-def waitformount(template, wait=50):
- for i in range(wait):
+def waitformount(template, timeout=50):
+ for i in range(timeout):
if findmnt().find(template) != -1:
return True
@@ -82,8 +98,8 @@ def waitformount(template, wait=50):
return False
-def waitforunmount(template, wait=50):
- for i in range(wait):
+def waitforunmount(template, timeout=50):
+ for i in range(timeout):
if findmnt().find(template) == -1:
return True