From 518808c70944fa6b20e3e9afb1dea4420350ee8c Mon Sep 17 00:00:00 2001 From: James Prestwood Date: Thu, 12 Aug 2021 13:21:54 -0700 Subject: [PATCH] auto-t: testutil.py: add expect_fail flag Several tests tests for connectivity with the expectation that it will fail. This ends up taking 30+ seconds because testutil retries 3 times, each with a 10 second timeout. By passing expect_fail=True this lowers the timeout to zero, and skips any retries. --- autotests/util/testutil.py | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/autotests/util/testutil.py b/autotests/util/testutil.py index c649b387..ea705bad 100644 --- a/autotests/util/testutil.py +++ b/autotests/util/testutil.py @@ -51,7 +51,12 @@ def tx(fromsock, tosock, src, dst): return (frame, fromsock, tosock, src, dst) -def test_connected(if0=None, if1=None, group=True): +def test_connected(if0=None, if1=None, group=True, expect_fail=False): + if expect_fail: + timeout = 0 + else: + timeout = 10 + if if0 is None or if1 is None: iwd_list = [dev.name for dev in iwd.IWD.get_instance().list_devices()] @@ -82,7 +87,7 @@ def test_connected(if0=None, if1=None, group=True): rec.append(False) while not all(rec): - r, w, x = select.select([sock0, sock1], [], [], 10) + r, w, x = select.select([sock0, sock1], [], [], timeout) if not r: raise Exception('timeout waiting for packets: ' + repr(rec)) @@ -110,15 +115,15 @@ def test_connected(if0=None, if1=None, group=True): sock0.close() sock1.close() -def test_ifaces_connected(if0=None, if1=None, group=True): +def test_ifaces_connected(if0=None, if1=None, group=True, expect_fail=False): retry = 0 while True: try: - test_connected(if0, if1, group) + test_connected(if0, if1, group, expect_fail) break except Exception as e: - if retry < 3: + if retry < 3 and not expect_fail: print('retrying connection test: %i' % retry) retry += 1 continue