summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrew Bartlett <abartlet@samba.org>2012-02-15 09:29:27 +1100
committerAndrew Bartlett <abartlet@samba.org>2012-02-16 15:20:09 +1100
commit98e438df00111541958b54543b3056c06783fd73 (patch)
tree384431b28cdd28940f71781c67f9db95e8a44132
parent97859d1ce809bab0cd3b6a4235a6cc09efea458f (diff)
downloadsamba-98e438df00111541958b54543b3056c06783fd73.tar.gz
samba-98e438df00111541958b54543b3056c06783fd73.tar.bz2
samba-98e438df00111541958b54543b3056c06783fd73.zip
wintest: Cope with nc not timing out even when -w 1 is specified
-rw-r--r--wintest/wintest.py18
1 files changed, 16 insertions, 2 deletions
diff --git a/wintest/wintest.py b/wintest/wintest.py
index b58cff597d..8b8df2ce43 100644
--- a/wintest/wintest.py
+++ b/wintest/wintest.py
@@ -491,8 +491,22 @@ options {
def port_wait(self, hostname, port, retries=200, delay=3, wait_for_fail=False):
'''wait for a host to come up on the network'''
- self.retry_cmd("nc -v -z -w 1 %s %u" % (hostname, port), ['succeeded'],
- retries=retries, delay=delay, wait_for_fail=wait_for_fail)
+
+ while retries > 0:
+ child = self.pexpect_spawn("nc -v -z -w 1 %s %u" % (hostname, port), crlf=False, timeout=1)
+ i = child.expect(['succeeded', 'failed', pexpect.EOF, pexpect.TIMEOUT])
+ if wait_for_fail:
+ if i > 0:
+ return
+ else:
+ if i == 0:
+ return
+
+ time.sleep(delay)
+ retries -= 1
+ self.info("retrying (retries=%u delay=%u)" % (retries, delay))
+
+ raise RuntimeError("gave up waiting for %s:%d" % (hostname, port))
def run_net_time(self, child):
'''run net time on windows'''