From 9e05e3387153daa3c3b7ce77e99a1d75fd8b7a2a Mon Sep 17 00:00:00 2001 From: Yu Watanabe Date: Sat, 23 Nov 2024 03:32:34 +0900 Subject: networkd-test.py: fix interface state checker After 259125d53d98541623b69e83000b5543f2352f5e, network interfaces declared by .netdev files are created after systemd-networkd sends READY notification. So, even when networkd is started, the netdevs may not be created yet, and 'ip' command may fail. Let's also check the return code of the command. This also - drops never worked stdout checks, - makes the test fail if the interface is not created within the timeout. --- test/networkd-test.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'test') diff --git a/test/networkd-test.py b/test/networkd-test.py index 929290eab7..7c201c484c 100755 --- a/test/networkd-test.py +++ b/test/networkd-test.py @@ -960,10 +960,13 @@ exec $(systemctl cat systemd-networkd.service | sed -n '/^ExecStart=/ {{ s/^.*=/ # wait until devices got created for _ in range(50): - out = subprocess.check_output(['ip', 'a', 'show', 'dev', self.if_router]) - if b'state UP' in out and b'scope global' in out: + if subprocess.run(['ip', 'link', 'show', 'dev', self.if_router], + stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL).returncode == 0: break time.sleep(0.1) + else: + subprocess.call(['ip', 'link', 'show', 'dev', self.if_router]) + self.fail('Timed out waiting for {ifr} created.'.format(ifr=self.if_router)) def shutdown_iface(self): '''Remove test interface and stop DHCP server''' -- cgit v1.2.3