tests/network: improve error reporting

Include stdout/stderr of failed command during netvm setup.
This commit is contained in:
Marek Marczykowski-Górecki 2019-12-03 13:24:58 +01:00
parent 10f99e5c4a
commit ffa1a40e6e
No known key found for this signature in database
GPG Key ID: 063938BA42CFA724

View File

@ -93,8 +93,12 @@ class VmNetworkingMixin(object):
:type self: qubes.tests.SystemTestCase | VMNetworkingMixin
'''
def run_netvm_cmd(cmd):
if self.run_cmd(self.testnetvm, cmd) != 0:
self.fail("Command '%s' failed" % cmd)
try:
self.loop.run_until_complete(
self.testnetvm.run_for_stdio(cmd, user='root'))
except subprocess.CalledProcessError as e:
self.fail("Command '%s' failed: %s%s" %
(cmd, e.stdout.decode(), e.stderr.decode()))
if not self.testnetvm.is_running():
self.loop.run_until_complete(self.testnetvm.start())
@ -783,8 +787,12 @@ class VmIPv6NetworkingMixin(VmNetworkingMixin):
super(VmIPv6NetworkingMixin, self).configure_netvm()
def run_netvm_cmd(cmd):
if self.run_cmd(self.testnetvm, cmd) != 0:
self.fail("Command '%s' failed" % cmd)
try:
self.loop.run_until_complete(
self.testnetvm.run_for_stdio(cmd, user='root'))
except subprocess.CalledProcessError as e:
self.fail("Command '%s' failed: %s%s" %
(cmd, e.stdout.decode(), e.stderr.decode()))
run_netvm_cmd("ip addr add {}/128 dev test0".format(self.test_ip6))
run_netvm_cmd(