From: Yu Watanabe Date: Wed, 27 Oct 2021 17:00:34 +0000 (+0900) Subject: test-network: add more tests for [Address] section X-Git-Tag: v250-rc1~398^2 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=refs%2Fpull%2F21157%2Fhead;p=thirdparty%2Fsystemd.git test-network: add more tests for [Address] section --- diff --git a/test/test-network/conf/25-address-static.network b/test/test-network/conf/25-address-static.network index 209a8553b9a..2a4c1a60393 100644 --- a/test/test-network/conf/25-address-static.network +++ b/test/test-network/conf/25-address-static.network @@ -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 diff --git a/test/test-network/systemd-networkd-tests.py b/test/test-network/systemd-networkd-tests.py index fc46c31c5da..7eb94a32d35 100755 --- a/test/test-network/systemd-networkd-tests.py +++ b/test/test-network/systemd-networkd-tests.py @@ -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)