test-network: add tests for null addresses

For issue #26113.
This commit is contained in:
Yu Watanabe
2023-07-07 10:23:48 +09:00
parent d0009d9290
commit fc25920c94
2 changed files with 42 additions and 0 deletions

View File

@@ -0,0 +1,14 @@
# SPDX-License-Identifier: LGPL-2.1-or-later
[Match]
Name=dummy98
[Network]
IPv6AcceptRA=no
Address=0.0.0.0/16
Address=0.0.0.0/30
Address=::/64
[Address]
Address=0.0.0.0/24
# The broadcast address will be ignored.
Broadcast=192.168.0.255

View File

@@ -2342,6 +2342,34 @@ class NetworkdNetworkTests(unittest.TestCase, Utilities):
# TODO: check json string
check_output(*networkctl_cmd, '--json=short', 'status', env=env)
def test_address_null(self):
copy_network_unit('25-address-null.network', '12-dummy.netdev')
start_networkd()
self.wait_online(['dummy98:routable'])
output = check_output('ip address show dev dummy98 scope global')
print(output)
ipv4_address_16 = re.findall(r'inet 172.[0-9]*.0.1/16 brd 172.[0-9]*.255.255', output)
self.assertEqual(len(ipv4_address_16), 1)
ipv4_address_24 = re.findall(r'inet 192.168.[0-9]*.1/24 brd 192.168.[0-9]*.255', output)
self.assertEqual(len(ipv4_address_24), 1)
ipv4_address_30 = re.findall(r'inet 192.168.[0-9]*.[0-9]*/30 brd 192.168.[0-9]*.[0-9]*', output)
self.assertEqual(len(ipv4_address_30), 1)
ipv6_address = re.findall(r'inet6 fd[0-9a-f:]*/64', output)
self.assertEqual(len(ipv6_address), 1)
networkctl_reconfigure('dummy98')
self.wait_online(['dummy98:routable'])
output = check_output('ip address show dev dummy98 scope global')
print(output)
self.assertIn(ipv4_address_16[0], output)
self.assertIn(ipv4_address_24[0], output)
self.assertIn(ipv4_address_30[0], output)
self.assertIn(ipv6_address[0], output)
def test_address_ipv4acd(self):
check_output('ip netns add ns99')
check_output('ip link add veth99 type veth peer veth-peer')