From 2de705cd1c7089e106be75ea094b996dd9e1f856 Mon Sep 17 00:00:00 2001 From: Frantisek Sumsal Date: Tue, 30 Jul 2019 14:27:44 +0200 Subject: [PATCH 1/2] test: use `useradd` instead of `adduser` `adduser` is in certain cases a standalone package which provides a better user experience. In other cases it's just a symlink to `useradd`. And some distributions don't have `adduser` at all, like Arch Linux. Let's use the `useradd` binary instead, which should provide the same functionality everywhere. --- test/networkd-test.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/test/networkd-test.py b/test/networkd-test.py index 8b1aeeda35..c971570346 100755 --- a/test/networkd-test.py +++ b/test/networkd-test.py @@ -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']: From 345997f393a5bb7dd5b8fe0327b28d7af21f07ae Mon Sep 17 00:00:00 2001 From: Frantisek Sumsal Date: Tue, 30 Jul 2019 20:27:34 +0200 Subject: [PATCH 2/2] test: print an error when networkctl returns an unexpected EC If networkctl crashes, like recently with SIGABRT, it returns absolutely no output, which may be confusing during debugging. Help it a little with a short informative message. --- test/networkd-test.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/test/networkd-test.py b/test/networkd-test.py index c971570346..beb3bd9e1d 100755 --- a/test/networkd-test.py +++ b/test/networkd-test.py @@ -420,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', '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