]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
test-network: add more tests for [Address] section 21157/head
authorYu Watanabe <watanabe.yu+github@gmail.com>
Wed, 27 Oct 2021 17:00:34 +0000 (02:00 +0900)
committerYu Watanabe <watanabe.yu+github@gmail.com>
Wed, 27 Oct 2021 17:12:34 +0000 (02:12 +0900)
test/test-network/conf/25-address-static.network
test/test-network/systemd-networkd-tests.py

index 209a8553b9a4c1866fb7e2f1e92dbe847b026200..2a4c1a60393716ab0ca4712089556e33e7d1a910 100644 (file)
@@ -43,6 +43,11 @@ Label=30
 Peer=hoge
 Address=10.10.0.2/16
 
+[Address]
+# address and peer must be in the same family
+Address=10.10.0.3/16
+Peer=2001:db8:0:f103::10/128
+
 [Address]
 Address=2001:db8:0:f102::16/64
 
@@ -65,6 +70,7 @@ Scope=link
 [Address]
 # this will also deduped
 Address=2001:0db8:1:f101::1/64
+PreferredLifetime=infinity
 
 [Address]
 Address=2001:0db8:1:f101::1/64
@@ -72,8 +78,33 @@ PreferredLifetime=0
 
 [Address]
 Address=10.8.8.1/16
+Broadcast=yes
+Broadcast=
 Broadcast=no
 
+[Address]
+Address=10.8.8.2/16
+Broadcast=10.8.8.128
+
+[Address]
+# Invalid broadcast
+Address=10.8.8.2/16
+Broadcast=::1
+
+[Address]
+# broadcast cannot set for IPv6 address
+Address=2001:0db8:1:f101::2/64
+Broadcast=::1
+
+[Address]
+Address=10.9.0.1/16
+RouteMetric=128
+
+[Address]
+# invalid metric
+Address=10.9.0.1/16
+RouteMetric=hoge
+
 # test for ENOBUFS issue #17012
 [Network]
 Address=10.3.3.1/16
index fc46c31c5dae9c349135f45dce38e2c845254b98..7eb94a32d3547c0a5b0fba8a88dd3d0f92dc0348 100755 (executable)
@@ -2002,6 +2002,8 @@ class NetworkdNetworkTests(unittest.TestCase, Utilities):
         self.assertIn('inet 10.2.2.4/16 brd 10.2.255.255 scope global dummy98', output)
         self.assertIn('inet 10.7.8.9/16 brd 10.7.255.255 scope link deprecated dummy98', output)
         self.assertIn('inet 10.8.8.1/16 scope global dummy98', output)
+        self.assertIn('inet 10.8.8.2/16 brd 10.8.8.128 scope global secondary dummy98', output)
+        self.assertRegex(output, 'inet 10.9.0.1/16 (metric 128 |)brd 10.9.255.255 scope global dummy98')
 
         # test for ENOBUFS issue #17012
         for i in range(1,254):
@@ -2023,6 +2025,10 @@ class NetworkdNetworkTests(unittest.TestCase, Utilities):
         output = check_output('ip -4 address show dev dummy98 label 35')
         self.assertRegex(output, r'inet 172.[0-9]*.0.1/16 brd 172.[0-9]*.255.255 scope global 35')
 
+        output = check_output('ip -4 route show dev dummy98')
+        print(output)
+        self.assertIn('10.9.0.0/16 proto kernel scope link src 10.9.0.1 metric 128', output)
+
         output = check_output('ip -6 address show dev dummy98')
         print(output)
         self.assertIn('inet6 2001:db8:0:f101::15/64 scope global', output)