summaryrefslogtreecommitdiffstats
path: root/test/test-network
diff options
context:
space:
mode:
authorYu Watanabe <watanabe.yu+github@gmail.com>2024-06-03 11:04:55 +0200
committerLuca Boccassi <bluca@debian.org>2024-06-03 19:41:26 +0200
commitdadf2bd4f464eee18cdba27280a777a926678b39 (patch)
treee45b6f419aca65a78b21bfec1906b14634dddeee /test/test-network
parenttest-network: show PID and Invocation ID of networkd (diff)
downloadsystemd-dadf2bd4f464eee18cdba27280a777a926678b39.tar.xz
systemd-dadf2bd4f464eee18cdba27280a777a926678b39.zip
test-network: introduce a .network file to protect existing interfaces
Diffstat (limited to 'test/test-network')
-rwxr-xr-xtest/test-network/systemd-networkd-tests.py13
1 files changed, 13 insertions, 0 deletions
diff --git a/test/test-network/systemd-networkd-tests.py b/test/test-network/systemd-networkd-tests.py
index a0ca54c790..c12c28f676 100755
--- a/test/test-network/systemd-networkd-tests.py
+++ b/test/test-network/systemd-networkd-tests.py
@@ -580,6 +580,15 @@ def save_existing_links():
print('### The following links will be protected:')
print(', '.join(sorted(list(protected_links))))
+def unmanage_existing_links():
+ mkdir_p(network_unit_dir)
+
+ with open(os.path.join(network_unit_dir, '00-unmanaged.network'), mode='w', encoding='utf-8') as f:
+ f.write('[Match]\n')
+ for link in protected_links:
+ f.write(f'Name={link}\n')
+ f.write('\n[Link]\nUnmanaged=yes\n')
+
def flush_links():
links = os.listdir('/sys/class/net')
remove_link(*links, protect=True)
@@ -933,6 +942,9 @@ def udevadm_trigger(*args, action='add'):
udevadm('trigger', '--settle', f'--action={action}', *args)
def setup_common():
+ # Protect existing links
+ unmanage_existing_links()
+
# We usually show something in each test. So, let's break line to make the title of a test and output
# from the test mixed. Then, flush stream buffer and journals.
print()
@@ -1874,6 +1886,7 @@ class NetworkdNetDevTests(unittest.TestCase, Utilities):
self.check_tuntap(True)
clear_network_units()
+ unmanage_existing_links()
restart_networkd()
self.wait_online('testtun99:off', 'testtap99:off', setup_state='unmanaged')