]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
test-network: add test case for KeepConfiguration=yes with RTPROT_BOOT
authorYu Watanabe <watanabe.yu+github@gmail.com>
Mon, 17 Feb 2025 17:05:07 +0000 (02:05 +0900)
committerDaan De Meyer <daan.j.demeyer@gmail.com>
Sat, 22 Feb 2025 11:15:12 +0000 (12:15 +0100)
For issue #36411.

(cherry picked from commit 1cac0676dafb45c64940c36d7d75ce1e04eb831c)

test/test-network/conf/24-keep-configuration-yes.network [new file with mode: 0644]
test/test-network/systemd-networkd-tests.py

diff --git a/test/test-network/conf/24-keep-configuration-yes.network b/test/test-network/conf/24-keep-configuration-yes.network
new file mode 100644 (file)
index 0000000..e0cffae
--- /dev/null
@@ -0,0 +1,7 @@
+# SPDX-License-Identifier: LGPL-2.1-or-later
+[Match]
+Name=dummy98
+
+[Network]
+IPv6AcceptRA=no
+KeepConfiguration=yes
index 4153cf12e8c52fd43a523ecbd6c1b716fe6addc4..4756d14f52572b8092aa893615e37beeec1c06f7 100755 (executable)
@@ -4811,6 +4811,24 @@ class NetworkdNetworkTests(unittest.TestCase, Utilities):
         self.assertRegex(output, 'DNS: 192.168.42.1')
         self.assertRegex(output, 'Search Domains: one')
 
+    def test_keep_configuration_yes(self):
+        check_output('ip link add dummy98 type dummy')
+        check_output('ip link set dev dummy98 up')
+        check_output('ip address add 198.51.100.1/24 brd 198.51.100.255 dev dummy98')
+        check_output('ip route add 203.0.113.0/24 via 198.51.100.10 dev dummy98 proto boot')
+
+        copy_network_unit('24-keep-configuration-yes.network')
+        start_networkd()
+        self.wait_online('dummy98:routable')
+
+        output = check_output('ip address show dummy98')
+        print(output)
+        self.assertIn('inet 198.51.100.1/24 brd 198.51.100.255 scope global dummy98', output)
+
+        output = check_output('ip -d -4 route show dev dummy98')
+        print(output)
+        self.assertIn('203.0.113.0/24 via 198.51.100.10 proto boot', output)
+
     def test_keep_configuration_static(self):
         check_output('ip link add name dummy98 type dummy')
         check_output('ip address add 10.1.2.3/16 dev dummy98')