From b95d35b5ed4d6d47ad68314f68cb7887546cb41d Mon Sep 17 00:00:00 2001 From: Yu Watanabe Date: Mon, 31 Oct 2022 14:00:29 +0900 Subject: [PATCH] test-network: resolve interface name from alternative name --- test/test-network/systemd-networkd-tests.py | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/test/test-network/systemd-networkd-tests.py b/test/test-network/systemd-networkd-tests.py index 62bd1d2d1e7..b255eeba6d2 100755 --- a/test/test-network/systemd-networkd-tests.py +++ b/test/test-network/systemd-networkd-tests.py @@ -413,6 +413,9 @@ def create_service_dropin(service, command, reload_command=None, additional_sett def link_exists(link): return call_quiet(f'ip link show {link}') == 0 +def link_resolve(link): + return check_output(f'ip link show {link}').split(':')[1].strip() + def remove_link(*links, protect=False): for link in links: if protect and link in protected_links: @@ -4236,6 +4239,9 @@ class NetworkdSRIOVTests(unittest.TestCase, Utilities): start_networkd() self.wait_online(['eni99np1:routable']) + # the name eni99np1 may be an alternative name. + ifname = link_resolve('eni99np1') + output = check_output('ip link show dev eni99np1') print(output) self.assertRegex(output, @@ -4250,7 +4256,7 @@ class NetworkdSRIOVTests(unittest.TestCase, Utilities): f.write('[Link]\nSR-IOVVirtualFunctions=4\n') udev_reload() - call(*udevadm_cmd, 'trigger', '--action=add', '--settle', '/sys/devices/netdevsim99/net/eni99np1') + check_output(*udevadm_cmd, 'trigger', '--action=add', '--settle', f'/sys/devices/netdevsim99/net/{ifname}') output = check_output('ip link show dev eni99np1') print(output) @@ -4266,7 +4272,7 @@ class NetworkdSRIOVTests(unittest.TestCase, Utilities): f.write('[Link]\nSR-IOVVirtualFunctions=\n') udev_reload() - call(*udevadm_cmd, 'trigger', '--action=add', '--settle', '/sys/devices/netdevsim99/net/eni99np1') + check_output(*udevadm_cmd, 'trigger', '--action=add', '--settle', f'/sys/devices/netdevsim99/net/{ifname}') output = check_output('ip link show dev eni99np1') print(output) @@ -4282,7 +4288,7 @@ class NetworkdSRIOVTests(unittest.TestCase, Utilities): f.write('[Link]\nSR-IOVVirtualFunctions=2\n') udev_reload() - call(*udevadm_cmd, 'trigger', '--action=add', '--settle', '/sys/devices/netdevsim99/net/eni99np1') + check_output(*udevadm_cmd, 'trigger', '--action=add', '--settle', f'/sys/devices/netdevsim99/net/{ifname}') output = check_output('ip link show dev eni99np1') print(output) @@ -4298,7 +4304,7 @@ class NetworkdSRIOVTests(unittest.TestCase, Utilities): f.write('[Link]\nSR-IOVVirtualFunctions=\n') udev_reload() - call(*udevadm_cmd, 'trigger', '--action=add', '--settle', '/sys/devices/netdevsim99/net/eni99np1') + check_output(*udevadm_cmd, 'trigger', '--action=add', '--settle', f'/sys/devices/netdevsim99/net/{ifname}') output = check_output('ip link show dev eni99np1') print(output) -- 2.47.3