From: Yu Watanabe Date: Tue, 31 May 2022 19:01:10 +0000 (+0900) Subject: test-network: call networkctl only when specified interface exists X-Git-Tag: v252-rc1~880^2 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=refs%2Fpull%2F23576%2Fhead;p=thirdparty%2Fsystemd.git test-network: call networkctl only when specified interface exists Otherwise, this easily trigger another exception: ``` ====================================================================== ERROR: test_erspan_tunnel_v0 (__main__.NetworkdNetDevTests) ---------------------------------------------------------------------- Traceback (most recent call last): File "./test/test-network/systemd-networkd-tests.py", line 686, in wait_online check_output(*args, env=env) File "./test/test-network/systemd-networkd-tests.py", line 65, in check_output return subprocess.check_output(command, universal_newlines=True, **kwargs).rstrip() File "/usr/lib64/python3.6/subprocess.py", line 356, in check_output **kwargs).stdout File "/usr/lib64/python3.6/subprocess.py", line 438, in run output=stdout, stderr=stderr) subprocess.CalledProcessError: Command '['/usr/lib/systemd/systemd-networkd-wait-online', '--timeout=20s', '--interface=erspan99:routable', '--interface=erspan98:routable', '--interface=dummy98:degraded']' returned non-zero exit status 1. During handling of the above exception, another exception occurred: Traceback (most recent call last): File "./test/test-network/systemd-networkd-tests.py", line 1808, in test_erspan_tunnel_v0 self.wait_online(['erspan99:routable', 'erspan98:routable', 'dummy98:degraded']) File "./test/test-network/systemd-networkd-tests.py", line 689, in wait_online output = check_output(*networkctl_cmd, '-n', '0', 'status', link.split(':')[0], env=env) File "./test/test-network/systemd-networkd-tests.py", line 65, in check_output return subprocess.check_output(command, universal_newlines=True, **kwargs).rstrip() File "/usr/lib64/python3.6/subprocess.py", line 356, in check_output **kwargs).stdout File "/usr/lib64/python3.6/subprocess.py", line 438, in run output=stdout, stderr=stderr) subprocess.CalledProcessError: Command '['/usr/bin/networkctl', '-n', '0', 'status', 'erspan99']' returned non-zero exit status 1. ``` --- diff --git a/test/test-network/systemd-networkd-tests.py b/test/test-network/systemd-networkd-tests.py index 7be99f2509c..7a962ba7084 100755 --- a/test/test-network/systemd-networkd-tests.py +++ b/test/test-network/systemd-networkd-tests.py @@ -699,8 +699,10 @@ class Utilities(): check_output(*args, env=env) except subprocess.CalledProcessError: for link in links_with_operstate: - output = check_output(*networkctl_cmd, '-n', '0', 'status', link.split(':')[0], env=env) - print(output) + name = link.split(':')[0] + if link_exists(name): + output = check_output(*networkctl_cmd, '-n', '0', 'status', name, env=env) + print(output) raise if not bool_any and setup_state: for link in links_with_operstate: