summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorYu Watanabe <watanabe.yu+github@gmail.com>2020-03-16 19:08:36 +0900
committerYu Watanabe <watanabe.yu+github@gmail.com>2020-03-16 19:34:47 +0900
commit0d7bd445d26590aad7b05040c9d8423fcd6e5d4f (patch)
tree56e7400069814d0d749b944c8baa0ed4f3810817 /test
parentb453122789ec4c6f39e6ceb9900e0e80a6abeb99 (diff)
downloadsystemd-0d7bd445d26590aad7b05040c9d8423fcd6e5d4f.tar.gz
test-network: add a test case for DHCPv4.UseGateway=no
Diffstat (limited to 'test')
-rw-r--r--test/test-network/conf/dhcp-client-ipv4-use-gateway-no.network9
-rwxr-xr-xtest/test-network/systemd-networkd-tests.py14
2 files changed, 23 insertions, 0 deletions
diff --git a/test/test-network/conf/dhcp-client-ipv4-use-gateway-no.network b/test/test-network/conf/dhcp-client-ipv4-use-gateway-no.network
new file mode 100644
index 0000000000..fb31772201
--- /dev/null
+++ b/test/test-network/conf/dhcp-client-ipv4-use-gateway-no.network
@@ -0,0 +1,9 @@
+[Match]
+Name=veth99
+
+[Network]
+DHCP=ipv4
+IPv6AcceptRA=false
+
+[DHCPv4]
+UseGateway=no
diff --git a/test/test-network/systemd-networkd-tests.py b/test/test-network/systemd-networkd-tests.py
index 5df1fed985..388e615602 100755
--- a/test/test-network/systemd-networkd-tests.py
+++ b/test/test-network/systemd-networkd-tests.py
@@ -2921,6 +2921,7 @@ class NetworkdDHCPClientTests(unittest.TestCase, Utilities):
'dhcp-client-ipv4-dhcp-settings.network',
'dhcp-client-ipv4-only-ipv6-disabled.network',
'dhcp-client-ipv4-only.network',
+ 'dhcp-client-ipv4-use-gateway-no.network',
'dhcp-client-ipv4-use-routes-no.network',
'dhcp-client-ipv6-only.network',
'dhcp-client-ipv6-rapid-commit.network',
@@ -3040,6 +3041,19 @@ class NetworkdDHCPClientTests(unittest.TestCase, Utilities):
self.assertRegex(output, r'default via 192.168.5.1 proto dhcp src 192.168.5.181 metric 1024')
self.assertRegex(output, r'192.168.5.1 proto dhcp scope link src 192.168.5.181 metric 1024')
+ def test_dhcp_client_ipv4_use_gateway_no(self):
+ copy_unit_to_networkd_unit_path('25-veth.netdev', 'dhcp-server-veth-peer.network', 'dhcp-client-ipv4-use-gateway-no.network')
+
+ start_networkd()
+ self.wait_online(['veth-peer:carrier'])
+ start_dnsmasq(additional_options='--dhcp-option=option:dns-server,192.168.5.6,192.168.5.7', lease_time='2m')
+ self.wait_online(['veth99:routable', 'veth-peer:routable'])
+
+ output = check_output('ip route show dev veth99')
+ print(output)
+ self.assertRegex(output, r'192.168.5.0/24 via 192.168.5.5 proto dhcp src 192.168.5.181 metric 1024')
+ self.assertNotRegex(output, r'default via 192.168.5.1')
+
def test_dhcp_client_ipv4_ipv6(self):
copy_unit_to_networkd_unit_path('25-veth.netdev', 'dhcp-server-veth-peer.network', 'dhcp-client-ipv6-only.network',
'dhcp-client-ipv4-only.network')