From: Yu Watanabe Date: Fri, 14 Jan 2022 23:54:36 +0000 (+0900) Subject: test-network: split out SR-IOV test to new class X-Git-Tag: v251-rc1~497^2~1 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=a03ff4c0fe8561035afc4f9a294995b312d2eca9;p=thirdparty%2Fsystemd.git test-network: split out SR-IOV test to new class --- diff --git a/test/test-network/systemd-networkd-tests.py b/test/test-network/systemd-networkd-tests.py index 101a896459a..709cfc120d2 100755 --- a/test/test-network/systemd-networkd-tests.py +++ b/test/test-network/systemd-networkd-tests.py @@ -2065,7 +2065,6 @@ class NetworkdNetworkTests(unittest.TestCase, Utilities): '25-route-vrf.network', '25-gateway-static.network', '25-gateway-next-static.network', - '25-sriov.network', '25-sysctl-disable-ipv6.network', '25-sysctl.network', '25-test1.network', @@ -3450,32 +3449,6 @@ class NetworkdNetworkTests(unittest.TestCase, Utilities): self.assertRegex(output, 'qdisc fq_pie 3a: root') self.assertRegex(output, 'limit 200000p') - @expectedFailureIfNetdevsimWithSRIOVIsNotAvailable() - def test_sriov(self): - call('rmmod netdevsim', stderr=subprocess.DEVNULL) - call('modprobe netdevsim', stderr=subprocess.DEVNULL) - with open('/sys/bus/netdevsim/new_device', mode='w') as f: - f.write('99 1') - - call('udevadm settle') - call('udevadm info -w10s /sys/devices/netdevsim99/net/eni99np1', stderr=subprocess.DEVNULL) - with open('/sys/class/net/eni99np1/device/sriov_numvfs', mode='w') as f: - f.write('3') - - copy_unit_to_networkd_unit_path('25-sriov.network') - start_networkd() - self.wait_online(['eni99np1:routable']) - - output = check_output('ip link show dev eni99np1') - print(output) - self.assertRegex(output, - 'vf 0 .*00:11:22:33:44:55.*vlan 5, qos 1, vlan protocol 802.1ad, spoof checking on, link-state enable, trust on, query_rss on\n *' - 'vf 1 .*00:11:22:33:44:56.*vlan 6, qos 2, spoof checking off, link-state disable, trust off, query_rss off\n *' - 'vf 2 .*00:11:22:33:44:57.*vlan 7, qos 3, spoof checking off, link-state auto, trust off, query_rss off' - ) - - call('rmmod netdevsim', stderr=subprocess.DEVNULL) - def test_wait_online_ipv4(self): copy_unit_to_networkd_unit_path('25-veth.netdev', 'dhcp-server-with-ipv6-prefix.network', 'dhcp-client-ipv4-ipv6ra-prefix-client-with-delay.network') start_networkd() @@ -3999,6 +3972,44 @@ class NetworkdBridgeTests(unittest.TestCase, Utilities): print(output) self.assertIn('from all to 8.8.8.8 lookup 100', output) +class NetworkdSRIOVTests(unittest.TestCase, Utilities): + units = [ + '25-sriov.network', + ] + + def setUp(self): + stop_networkd(show_logs=False) + call('rmmod netdevsim', stderr=subprocess.DEVNULL) + + def tearDown(self): + remove_unit_from_networkd_path(self.units) + stop_networkd(show_logs=True) + call('rmmod netdevsim', stderr=subprocess.DEVNULL) + + @expectedFailureIfNetdevsimWithSRIOVIsNotAvailable() + def test_sriov(self): + call('modprobe netdevsim', stderr=subprocess.DEVNULL) + + with open('/sys/bus/netdevsim/new_device', mode='w') as f: + f.write('99 1') + + call('udevadm settle') + call('udevadm info -w10s /sys/devices/netdevsim99/net/eni99np1', stderr=subprocess.DEVNULL) + with open('/sys/class/net/eni99np1/device/sriov_numvfs', mode='w') as f: + f.write('3') + + copy_unit_to_networkd_unit_path('25-sriov.network') + start_networkd() + self.wait_online(['eni99np1:routable']) + + output = check_output('ip link show dev eni99np1') + print(output) + self.assertRegex(output, + 'vf 0 .*00:11:22:33:44:55.*vlan 5, qos 1, vlan protocol 802.1ad, spoof checking on, link-state enable, trust on, query_rss on\n *' + 'vf 1 .*00:11:22:33:44:56.*vlan 6, qos 2, spoof checking off, link-state disable, trust off, query_rss off\n *' + 'vf 2 .*00:11:22:33:44:57.*vlan 7, qos 3, spoof checking off, link-state auto, trust off, query_rss off' + ) + class NetworkdLLDPTests(unittest.TestCase, Utilities): links = ['veth99']