From: Yu Watanabe Date: Thu, 24 Feb 2022 07:24:49 +0000 (+0900) Subject: test-network: check existence before calling networkctl or ip command X-Git-Tag: v251-rc1~225^2~1 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=459c35d4c51058b98ea1f7676acb25aecc351785;p=thirdparty%2Fsystemd.git test-network: check existence before calling networkctl or ip command --- diff --git a/test/test-network/systemd-networkd-tests.py b/test/test-network/systemd-networkd-tests.py index 39f5e58bef9..0498a818945 100755 --- a/test/test-network/systemd-networkd-tests.py +++ b/test/test-network/systemd-networkd-tests.py @@ -609,11 +609,13 @@ class Utilities(): needle = f'{link}: Bringing link {state}' flag = state.upper() for iteration in range(timeout+1): + if iteration != 0: + time.sleep(1) + if not link_exists(link): + continue output = check_output('journalctl _SYSTEMD_INVOCATION_ID=' + invocation_id) if needle in output and flag in check_output(f'ip link show {link}'): return True - if iteration < timeout: - time.sleep(1) if fail_assert: self.fail(f'Timed out waiting for {link} activated.') return False @@ -638,13 +640,14 @@ class Utilities(): setup_state = r'\S+' for secs in range(setup_timeout + 1): + if secs != 0: + time.sleep(1) + if not link_exists(link): + continue output = check_output(*networkctl_cmd, '-n', '0', 'status', link, env=env) print(output) if re.search(rf'(?m)^\s*State:\s+{operstate}\s+\({setup_state}\)\s*$', output): return True - # don't bother sleeping if time is up - if secs < setup_timeout: - time.sleep(1) if fail_assert: self.fail(f'Timed out waiting for {link} to reach state {operstate}/{setup_state}') return False