diff options
author | Yu Watanabe <watanabe.yu+github@gmail.com> | 2024-11-22 19:32:34 +0100 |
---|---|---|
committer | Yu Watanabe <watanabe.yu+github@gmail.com> | 2024-11-23 09:33:43 +0100 |
commit | 9e05e3387153daa3c3b7ce77e99a1d75fd8b7a2a (patch) | |
tree | 9ee9fffcbfd5dc425242649086bf808c3a06a491 /test | |
parent | nspawn: improve log message on bad incoming sd_notify() message (diff) | |
download | systemd-9e05e3387153daa3c3b7ce77e99a1d75fd8b7a2a.tar.xz systemd-9e05e3387153daa3c3b7ce77e99a1d75fd8b7a2a.zip |
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.
Diffstat (limited to 'test')
-rwxr-xr-x | test/networkd-test.py | 7 |
1 files changed, 5 insertions, 2 deletions
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''' |