1
0
mirror of https://github.com/systemd/systemd.git synced 2025-03-31 14:50:15 +03:00

test-network: add test case for Gateway=_dhcp4 with Table=

This commit is contained in:
Yu Watanabe 2025-01-27 05:54:30 +09:00
parent 7befabafad
commit 2ea15435fd
2 changed files with 27 additions and 4 deletions

View File

@ -43,5 +43,9 @@ Destination=192.168.7.0/24
[Route]
Gateway=_dhcp4
Destination=10.0.0.0/8
Table=211
Destination=192.0.2.0/24
[Route]
Gateway=_dhcp4
Destination=198.51.100.0/24
Table=212

View File

@ -7121,7 +7121,14 @@ class NetworkdDHCPClientTests(unittest.TestCase, Utilities):
self.assertRegex(output, f'192.168.5.1 proto dhcp scope link src {address1} metric 24')
self.assertRegex(output, f'192.168.5.6 proto dhcp scope link src {address1} metric 24')
self.assertRegex(output, f'192.168.5.7 proto dhcp scope link src {address1} metric 24')
self.assertIn('10.0.0.0/8 via 192.168.5.1 proto dhcp', output)
self.assertRegex(output, f'192.0.2.0/24 via 192.168.5.1 proto dhcp src {address1}')
print('## ip route show table 212 dev veth99')
output = check_output('ip route show table 212 dev veth99')
print(output)
self.assertRegex(output, f'192.168.5.0/24 proto dhcp scope link src {address1} metric 24')
self.assertRegex(output, f'192.168.5.1 proto dhcp scope link src {address1} metric 24')
self.assertRegex(output, f'198.51.100.0/24 via 192.168.5.1 proto dhcp src {address1}')
print('## link state file')
output = read_link_state_file('veth99')
@ -7221,7 +7228,14 @@ class NetworkdDHCPClientTests(unittest.TestCase, Utilities):
self.assertNotIn('192.168.5.6', output)
self.assertRegex(output, f'192.168.5.7 proto dhcp scope link src {address2} metric 24')
self.assertRegex(output, f'192.168.5.8 proto dhcp scope link src {address2} metric 24')
self.assertIn('10.0.0.0/8 via 192.168.5.1 proto dhcp', output)
self.assertRegex(output, f'192.0.2.0/24 via 192.168.5.1 proto dhcp src {address2}')
print('## ip route show table 212 dev veth99')
output = check_output('ip route show table 212 dev veth99')
print(output)
self.assertRegex(output, f'192.168.5.0/24 proto dhcp scope link src {address2} metric 24')
self.assertRegex(output, f'192.168.5.1 proto dhcp scope link src {address2} metric 24')
self.assertRegex(output, f'198.51.100.0/24 via 192.168.5.1 proto dhcp src {address2}')
print('## link state file')
output = read_link_state_file('veth99')
@ -7292,6 +7306,11 @@ class NetworkdDHCPClientTests(unittest.TestCase, Utilities):
print(output)
self.assertNotIn(f'{address2}', output)
print('## ip route show table 212 dev veth99')
output = check_output('ip route show table 212 dev veth99')
print(output)
self.assertNotIn(f'{address2}', output)
self.teardown_nftset('addr4', 'network4', 'ifindex')
def test_dhcp_client_ipv4_dbus_status(self):