diff options
author | Martin Pitt <martin@piware.de> | 2019-02-26 23:03:35 +0100 |
---|---|---|
committer | Martin Pitt <martin@piware.de> | 2019-02-27 22:53:57 +0100 |
commit | 74c13b7659e6802aa05319a6e215f5ebf96fecee (patch) | |
tree | 0f24635a15f80c006b8e096115c11f3687f02c30 /test/networkd-test.py | |
parent | Merge pull request #11795 from yuwata/fix-network-routing-policy-11280 (diff) | |
download | systemd-74c13b7659e6802aa05319a6e215f5ebf96fecee.tar.xz systemd-74c13b7659e6802aa05319a6e215f5ebf96fecee.zip |
networkd-test: show service journal on startup failure
This provides easier evaluation of failed tests.
Diffstat (limited to '')
-rwxr-xr-x | test/networkd-test.py | 26 |
1 files changed, 15 insertions, 11 deletions
diff --git a/test/networkd-test.py b/test/networkd-test.py index 9487910b71..7c921c205b 100755 --- a/test/networkd-test.py +++ b/test/networkd-test.py @@ -335,13 +335,16 @@ class ClientTestBase(NetworkdTestingUtilities): raise NotImplementedError('must be implemented by a subclass') - def do_test(self, coldplug=True, ipv6=False, extra_opts='', - online_timeout=10, dhcp_mode='yes'): + def start_unit(self, unit): try: - subprocess.check_call(['systemctl', 'start', 'systemd-resolved']) + subprocess.check_call(['systemctl', 'start', unit]) except subprocess.CalledProcessError: - self.show_journal('systemd-resolved.service') + self.show_journal(unit) raise + + def do_test(self, coldplug=True, ipv6=False, extra_opts='', + online_timeout=10, dhcp_mode='yes'): + self.start_unit('systemd-resolved') self.write_network(self.config, '''\ [Match] Name={} @@ -352,14 +355,14 @@ DHCP={} if coldplug: # create interface first, then start networkd self.create_iface(ipv6=ipv6) - subprocess.check_call(['systemctl', 'start', 'systemd-networkd']) + self.start_unit('systemd-networkd') elif coldplug is not None: # start networkd first, then create interface - subprocess.check_call(['systemctl', 'start', 'systemd-networkd']) + self.start_unit('systemd-networkd') self.create_iface(ipv6=ipv6) else: # "None" means test sets up interface by itself - subprocess.check_call(['systemctl', 'start', 'systemd-networkd']) + self.start_unit('systemd-networkd') try: subprocess.check_call([NETWORKD_WAIT_ONLINE, '--interface', @@ -618,7 +621,7 @@ Address=10.241.3.2/24 DNS=10.241.3.1 Domains= ~company ~lab''') - subprocess.check_call(['systemctl', 'start', 'systemd-networkd']) + self.start_unit('systemd-networkd') subprocess.check_call([NETWORKD_WAIT_ONLINE, '--interface', self.iface, '--interface=testvpnclient', '--timeout=20']) @@ -888,7 +891,7 @@ Address=192.168.42.100 DNS=192.168.42.1 Domains= one two three four five six seven eight nine ten''') - subprocess.check_call(['systemctl', 'start', 'systemd-networkd']) + self.start_unit('systemd-networkd') for timeout in range(50): with open(RESOLV_CONF) as f: @@ -920,7 +923,7 @@ Address=192.168.42.100 DNS=192.168.42.1 Domains={p}0 {p}1 {p}2 {p}3 {p}4'''.format(p=name_prefix)) - subprocess.check_call(['systemctl', 'start', 'systemd-networkd']) + self.start_unit('systemd-networkd') for timeout in range(50): with open(RESOLV_CONF) as f: @@ -950,7 +953,8 @@ DNS=192.168.42.1''') [Network] DNS=127.0.0.1''') - subprocess.check_call(['systemctl', 'start', 'systemd-resolved', 'systemd-networkd']) + self.start_unit('systemd-resolved') + self.start_unit('systemd-networkd') for timeout in range(50): with open(RESOLV_CONF) as f: |