summaryrefslogtreecommitdiffhomepage
path: root/test/unit/utils.py
diff options
context:
space:
mode:
authorAndrei Belov <defan@nginx.com>2021-08-19 18:17:12 +0300
committerAndrei Belov <defan@nginx.com>2021-08-19 18:17:12 +0300
commitdb442f1be7e713e6a219621ff97a51046590dbd6 (patch)
tree913734275bc890ec175e51fcb0f36b01a3c52c24 /test/unit/utils.py
parenta1d2ced6fc2317d36bc917c5d0ac339bc647dc34 (diff)
parent13c0025dfa6e041563d0ad5dd81679b44522694c (diff)
downloadunit-db442f1be7e713e6a219621ff97a51046590dbd6.tar.gz
unit-db442f1be7e713e6a219621ff97a51046590dbd6.tar.bz2
Merged with the default branch.1.25.0-1
Diffstat (limited to 'test/unit/utils.py')
-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