test-network: add test for Gateway=DHCP

This commit is contained in:
Yu Watanabe 2020-01-07 14:55:58 +09:00
parent 1985c54ff3
commit 214c5bae09
3 changed files with 45 additions and 0 deletions

View File

@ -0,0 +1,10 @@
[Match]
Name=veth99
[Network]
DHCP=ipv4
IPv6AcceptRA=no
[Route]
Gateway=dhcp
Destination=10.0.0.0/8

View File

@ -0,0 +1,9 @@
[Match]
Name=veth99
[Network]
DHCP=ipv6
[Route]
Gateway=dhcp
Destination=2001:1234:5:9fff:ff:ff:ff:ff/128

View File

@ -2659,6 +2659,8 @@ class NetworkdDHCPClientTests(unittest.TestCase, Utilities):
'25-vrf.network',
'dhcp-client-anonymize.network',
'dhcp-client-decline.network',
'dhcp-client-gateway-ipv4.network',
'dhcp-client-gateway-ipv6.network',
'dhcp-client-gateway-onlink-implicit.network',
'dhcp-client-ipv4-dhcp-settings.network',
'dhcp-client-ipv4-only-ipv6-disabled.network',
@ -3145,6 +3147,30 @@ class NetworkdDHCPClientTests(unittest.TestCase, Utilities):
print(output)
self.assertEqual(output, '')
def test_dhcp_client_gateway_ipv4(self):
copy_unit_to_networkd_unit_path('25-veth.netdev', 'dhcp-server-veth-peer.network',
'dhcp-client-gateway-ipv4.network')
start_networkd()
self.wait_online(['veth-peer:carrier'])
start_dnsmasq()
self.wait_online(['veth99:routable', 'veth-peer:routable'])
output = check_output('ip route list dev veth99 10.0.0.0/8')
print(output)
self.assertRegex(output, '10.0.0.0/8 via 192.168.5.1 proto static')
def test_dhcp_client_gateway_ipv6(self):
copy_unit_to_networkd_unit_path('25-veth.netdev', 'dhcp-server-veth-peer.network',
'dhcp-client-gateway-ipv6.network')
start_networkd()
self.wait_online(['veth-peer:carrier'])
start_dnsmasq()
self.wait_online(['veth99:routable', 'veth-peer:routable'])
output = check_output('ip -6 route list dev veth99 2001:1234:5:9fff:ff:ff:ff:ff')
print(output)
self.assertRegex(output, 'via fe80::1034:56ff:fe78:9abd')
def test_dhcp_client_gateway_onlink_implicit(self):
copy_unit_to_networkd_unit_path('25-veth.netdev', 'dhcp-server-veth-peer.network',
'dhcp-client-gateway-onlink-implicit.network')