1
0
mirror of https://github.com/systemd/systemd.git synced 2024-10-27 18:55:40 +03:00

test-network: add tests for duplicated address setting

Also, add more tests for PreferredLifetime=0

C.f. #20891.
This commit is contained in:
Yu Watanabe 2021-09-30 19:22:22 +09:00
parent 9202b567bc
commit 40971657ce
2 changed files with 28 additions and 0 deletions

View File

@ -52,11 +52,19 @@ Peer=2001:db8:0:f103::10/128
[Address]
Address=::/64
[Network]
# this will later deduped by the following section
Address=10.7.8.9/16
[Address]
Address=10.7.8.9/16
PreferredLifetime=0
Scope=link
[Address]
# this will also deduped
Address=2001:0db8:1:f101::1/64
[Address]
Address=2001:0db8:1:f101::1/64
PreferredLifetime=0

View File

@ -1993,9 +1993,29 @@ class NetworkdNetworkTests(unittest.TestCase, Utilities):
self.assertIn('inet6 2001:db8:1:f101::1/64 scope global deprecated', output)
self.assertRegex(output, r'inet6 fd[0-9a-f:]*1/64 scope global')
# Tests for #20891.
# 1. set preferred lifetime forever to drop the deprecated flag for testing #20891.
self.assertEqual(call('ip address change 10.7.8.9/16 dev dummy98 preferred_lft forever'), 0)
self.assertEqual(call('ip address change 2001:db8:1:f101::1/64 dev dummy98 preferred_lft forever'), 0)
output = check_output('ip -4 address show dev dummy98')
print(output)
self.assertNotIn('deprecated', output)
output = check_output('ip -6 address show dev dummy98')
print(output)
self.assertNotIn('deprecated', output)
# 2. restart networkd to reconfigure the interface.
restart_networkd()
self.wait_online(['dummy98:routable'])
# 3. check the deprecated flag is set for the address configured with PreferredLifetime=0
output = check_output('ip -4 address show dev dummy98')
print(output)
self.assertIn('inet 10.7.8.9/16 brd 10.7.255.255 scope link deprecated dummy98', output)
output = check_output('ip -6 address show dev dummy98')
print(output)
self.assertIn('inet6 2001:db8:1:f101::1/64 scope global deprecated', output)
# test for ENOBUFS issue #17012
output = check_output('ip -4 address show dev dummy98')
for i in range(1,254):