From: Yu Watanabe Date: Wed, 20 Dec 2023 19:09:47 +0000 (+0900) Subject: test-network: add test case of an empty string assignment for Address= X-Git-Tag: v256-rc1~1424^2 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=refs%2Fpull%2F30541%2Fhead;p=thirdparty%2Fsystemd.git test-network: add test case of an empty string assignment for Address= --- diff --git a/test/test-network/conf/25-address-static.network.d/20-clear-addresses.conf b/test/test-network/conf/25-address-static.network.d/20-clear-addresses.conf new file mode 100644 index 00000000000..a38b07c1fb0 --- /dev/null +++ b/test/test-network/conf/25-address-static.network.d/20-clear-addresses.conf @@ -0,0 +1,6 @@ +# SPDX-License-Identifier: LGPL-2.1-or-later + +[Network] +# An empty string clears previously configured addresses. +Address= +Address=10.4.0.1/16 diff --git a/test/test-network/systemd-networkd-tests.py b/test/test-network/systemd-networkd-tests.py index a3f3c6085cb..6af6e6dc10f 100755 --- a/test/test-network/systemd-networkd-tests.py +++ b/test/test-network/systemd-networkd-tests.py @@ -2756,6 +2756,15 @@ class NetworkdNetworkTests(unittest.TestCase, Utilities): for i in range(1, 254): self.assertIn(f'inet 10.3.3.{i}/16 brd 10.3.255.255', output) + # test for an empty string assignment for Address= in [Network] + copy_network_unit('25-address-static.network.d/20-clear-addresses.conf') + networkctl_reload() + self.wait_online(['dummy98:routable']) + output = check_output('ip -4 address show dev dummy98') + for i in range(1, 254): + self.assertNotIn(f'inet 10.3.3.{i}/16 brd 10.3.255.255', output) + self.assertIn('inet 10.4.0.1/16 brd 10.4.255.255', output) + def test_address_ipv4acd(self): check_output('ip netns add ns99') check_output('ip link add veth99 type veth peer veth-peer')