]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
test-network: add a testcase for semi-static route with Gateway=_dhcp4 when UseGateway=no 20209/head
authorYu Watanabe <watanabe.yu+github@gmail.com>
Mon, 12 Jul 2021 16:20:53 +0000 (01:20 +0900)
committerYu Watanabe <watanabe.yu+github@gmail.com>
Wed, 14 Jul 2021 19:17:14 +0000 (04:17 +0900)
test/test-network/systemd-networkd-tests.py

index cffc79a981a78ffe1d02a5d0cb18b36ded03c0a9..dc31d133c4e99c1489118df1b40de5ee73c58282 100755 (executable)
@@ -4426,9 +4426,24 @@ class NetworkdDHCPClientTests(unittest.TestCase, Utilities):
         start_dnsmasq()
         self.wait_online(['veth99:routable', 'veth-peer:routable'])
 
-        output = check_output('ip route list dev veth99 10.0.0.0/8')
+        output = check_output('ip route list dev veth99')
+        print(output)
+        self.assertRegex(output, 'default via 192.168.5.1 proto dhcp src 192.168.5.[0-9]*')
+        self.assertIn('10.0.0.0/8 via 192.168.5.1 proto dhcp', output)
+
+        with open(os.path.join(network_unit_file_path, 'dhcp-client-gateway-ipv4.network'), mode='a') as f:
+            f.write('[DHCPv4]\nUseGateway=no\n')
+
+        rc = call(*networkctl_cmd, 'reload', env=env)
+        self.assertEqual(rc, 0)
+
+        time.sleep(2)
+        self.wait_online(['veth99:routable', 'veth-peer:routable'])
+
+        output = check_output('ip route list dev veth99')
         print(output)
-        self.assertRegex(output, '10.0.0.0/8 via 192.168.5.1 proto dhcp')
+        self.assertNotRegex(output, 'default via 192.168.5.1 proto dhcp src 192.168.5.[0-9]*')
+        self.assertIn('10.0.0.0/8 via 192.168.5.1 proto dhcp', output)
 
     def test_dhcp_client_gateway_ipv6(self):
         copy_unit_to_networkd_unit_path('25-veth.netdev', 'dhcp-server-veth-peer.network',