]> git.ipfire.org Git - thirdparty/systemd.git/blobdiff - test/networkd-test.py
network: rename ipv4ll_address -> ipv4ll_address_configured
[thirdparty/systemd.git] / test / networkd-test.py
index 9af141fa654c461c1c4a8fe871ba2d9a2b1bf76e..b225694819447cc06023d7ba7422275ab98a04f1 100755 (executable)
@@ -66,7 +66,8 @@ def setUpModule():
     # create static systemd-network user for networkd-test-router.service (it
     # needs to do some stuff as root and can't start as user; but networkd
     # still insists on the user)
-    subprocess.call(['adduser', '--system', '--no-create-home', 'systemd-network'])
+    if subprocess.call(['getent', 'passwd', 'systemd-network']) != 0:
+        subprocess.call(['useradd', '--system', '--no-create-home', 'systemd-network'])
 
     for d in ['/etc/systemd/network', '/run/systemd/network',
               '/run/systemd/netif', '/run/systemd/resolve']:
@@ -283,11 +284,11 @@ class ClientTestBase(NetworkdTestingUtilities):
         klass.orig_log_level = subprocess.check_output(
             ['systemctl', 'show', '--value', '--property', 'LogLevel'],
             universal_newlines=True).strip()
-        subprocess.check_call(['systemd-analyze', 'set-log-level', 'debug'])
+        subprocess.check_call(['systemd-analyze', 'log-level', 'debug'])
 
     @classmethod
     def tearDownClass(klass):
-        subprocess.check_call(['systemd-analyze', 'set-log-level', klass.orig_log_level])
+        subprocess.check_call(['systemd-analyze', 'log-level', klass.orig_log_level])
 
     def setUp(self):
         self.iface = 'test_eth42'
@@ -375,7 +376,7 @@ DHCP={}
                 # IPv6, but we want to wait for both
                 for _ in range(10):
                     out = subprocess.check_output(['ip', 'a', 'show', 'dev', self.iface])
-                    if b'state UP' in out and b'inet6 2600' in out and b'inet 192.168' in out:
+                    if b'state UP' in out and b'inet6 2600' in out and b'inet 192.168' in out and b'tentative' not in out:
                         break
                     time.sleep(1)
                 else:
@@ -399,7 +400,7 @@ DHCP={}
             self.assertRegex(out, (r'{}\s+ether\s+[a-z-]+\s+unmanaged'.format(self.if_router)).encode())
             self.assertRegex(out, (r'{}\s+ether\s+routable\s+configured'.format(self.iface)).encode())
 
-            out = subprocess.check_output(['networkctl', 'status', self.iface])
+            out = subprocess.check_output(['networkctl', '-n', '0', 'status', self.iface])
             self.assertRegex(out, br'Type:\s+ether')
             self.assertRegex(out, br'State:\s+routable.*configured')
             self.assertRegex(out, br'Address:\s+192.168.5.\d+')
@@ -419,7 +420,9 @@ DHCP={}
             subprocess.call(['ip', 'a', 'show', 'dev', self.iface])
             print('---- networkctl status {} ----'.format(self.iface))
             sys.stdout.flush()
-            subprocess.call(['networkctl', 'status', self.iface])
+            rc = subprocess.call(['networkctl', '-n', '0', 'status', self.iface])
+            if rc != 0:
+                print("'networkctl status' exited with an unexpected code {}".format(rc))
             self.show_journal('systemd-networkd.service')
             self.print_server_log()
             raise