tests/vm_qrexec_gui: do not swallow stderr on failure
QubesVM.run_for_stdio() by default captures stderr. In case of call fail (non-zero return code), captured stderr is included in the exception object, but isn't printed by default CalledProcessError message. Make it visible by: - handling CalledProcessError and including in the test failure message (when exception is captured already) - not capturing stderr (if no exception handling is present in the test)
This commit is contained in:
parent
d033457f3d
commit
5423ead27a
@ -251,6 +251,9 @@ class TC_00_AppVMMixin(object):
|
|||||||
/bin/sh -c 'echo test; exec >&-; cat >&$SAVED_FD_1'
|
/bin/sh -c 'echo test; exec >&-; cat >&$SAVED_FD_1'
|
||||||
'''.format(self.testvm2.name)),
|
'''.format(self.testvm2.name)),
|
||||||
timeout=10))
|
timeout=10))
|
||||||
|
except subprocess.CalledProcessError as e:
|
||||||
|
self.fail('{} exited with non-zero code {}; stderr: {}'.format(
|
||||||
|
e.cmd, e.returncode, e.stderr))
|
||||||
except asyncio.TimeoutError:
|
except asyncio.TimeoutError:
|
||||||
self.fail("Timeout, probably EOF wasn't transferred")
|
self.fail("Timeout, probably EOF wasn't transferred")
|
||||||
|
|
||||||
@ -275,6 +278,9 @@ class TC_00_AppVMMixin(object):
|
|||||||
/bin/sh -c 'cat >&$SAVED_FD_1'
|
/bin/sh -c 'cat >&$SAVED_FD_1'
|
||||||
'''.format(self.testvm2.name)),
|
'''.format(self.testvm2.name)),
|
||||||
timeout=10))
|
timeout=10))
|
||||||
|
except subprocess.CalledProcessError as e:
|
||||||
|
self.fail('{} exited with non-zero code {}; stderr: {}'.format(
|
||||||
|
e.cmd, e.returncode, e.stderr))
|
||||||
except asyncio.TimeoutError:
|
except asyncio.TimeoutError:
|
||||||
self.fail("Timeout, probably EOF wasn't transferred")
|
self.fail("Timeout, probably EOF wasn't transferred")
|
||||||
|
|
||||||
@ -308,6 +314,9 @@ class TC_00_AppVMMixin(object):
|
|||||||
e=$(cat /tmp/exit-code);
|
e=$(cat /tmp/exit-code);
|
||||||
test $e -eq 141 -o $e -eq 1'''),
|
test $e -eq 141 -o $e -eq 1'''),
|
||||||
timeout=10))
|
timeout=10))
|
||||||
|
except subprocess.CalledProcessError as e:
|
||||||
|
self.fail('{} exited with non-zero code {}; stderr: {}'.format(
|
||||||
|
e.cmd, e.returncode, e.stderr))
|
||||||
except asyncio.TimeoutError:
|
except asyncio.TimeoutError:
|
||||||
self.fail("Timeout, probably stdout wasn't closed")
|
self.fail("Timeout, probably stdout wasn't closed")
|
||||||
|
|
||||||
@ -329,7 +338,8 @@ class TC_00_AppVMMixin(object):
|
|||||||
(stdout, stderr) = self.loop.run_until_complete(
|
(stdout, stderr) = self.loop.run_until_complete(
|
||||||
self.testvm1.run_for_stdio('''\
|
self.testvm1.run_for_stdio('''\
|
||||||
/usr/lib/qubes/qrexec-client-vm {} test.Retcode;
|
/usr/lib/qubes/qrexec-client-vm {} test.Retcode;
|
||||||
echo $?'''.format(self.testvm2.name)))
|
echo $?'''.format(self.testvm2.name),
|
||||||
|
stderr=None))
|
||||||
self.assertEqual(stdout, b'0\n')
|
self.assertEqual(stdout, b'0\n')
|
||||||
|
|
||||||
self.create_remote_file(self.testvm2, '/etc/qubes-rpc/test.Retcode',
|
self.create_remote_file(self.testvm2, '/etc/qubes-rpc/test.Retcode',
|
||||||
@ -337,7 +347,8 @@ class TC_00_AppVMMixin(object):
|
|||||||
(stdout, stderr) = self.loop.run_until_complete(
|
(stdout, stderr) = self.loop.run_until_complete(
|
||||||
self.testvm1.run_for_stdio('''\
|
self.testvm1.run_for_stdio('''\
|
||||||
/usr/lib/qubes/qrexec-client-vm {} test.Retcode;
|
/usr/lib/qubes/qrexec-client-vm {} test.Retcode;
|
||||||
echo $?'''.format(self.testvm2.name)))
|
echo $?'''.format(self.testvm2.name),
|
||||||
|
stderr=None))
|
||||||
self.assertEqual(stdout, b'3\n')
|
self.assertEqual(stdout, b'3\n')
|
||||||
|
|
||||||
def test_070_qrexec_vm_simultaneous_write(self):
|
def test_070_qrexec_vm_simultaneous_write(self):
|
||||||
@ -376,8 +387,9 @@ class TC_00_AppVMMixin(object):
|
|||||||
dd of=/dev/null bs=993 count=10000 iflag=fullblock;
|
dd of=/dev/null bs=993 count=10000 iflag=fullblock;
|
||||||
wait'
|
wait'
|
||||||
'''.format(self.testvm2.name)), timeout=10))
|
'''.format(self.testvm2.name)), timeout=10))
|
||||||
except subprocess.CalledProcessError:
|
except subprocess.CalledProcessError as e:
|
||||||
self.fail('Service call failed')
|
self.fail('{} exited with non-zero code {}; stderr: {}'.format(
|
||||||
|
e.cmd, e.returncode, e.stderr))
|
||||||
except asyncio.TimeoutError:
|
except asyncio.TimeoutError:
|
||||||
self.fail('Timeout, probably deadlock')
|
self.fail('Timeout, probably deadlock')
|
||||||
|
|
||||||
@ -496,7 +508,8 @@ class TC_00_AppVMMixin(object):
|
|||||||
with self.qrexec_policy('test.Argument', self.testvm1, self.testvm2):
|
with self.qrexec_policy('test.Argument', self.testvm1, self.testvm2):
|
||||||
stdout, stderr = self.loop.run_until_complete(
|
stdout, stderr = self.loop.run_until_complete(
|
||||||
self.testvm1.run_for_stdio('/usr/lib/qubes/qrexec-client-vm '
|
self.testvm1.run_for_stdio('/usr/lib/qubes/qrexec-client-vm '
|
||||||
'{} test.Argument+argument'.format(self.testvm2.name)))
|
'{} test.Argument+argument'.format(self.testvm2.name),
|
||||||
|
stderr=None))
|
||||||
self.assertEqual(stdout, b'argument')
|
self.assertEqual(stdout, b'argument')
|
||||||
|
|
||||||
def test_081_qrexec_service_argument_allow_specific(self):
|
def test_081_qrexec_service_argument_allow_specific(self):
|
||||||
@ -515,7 +528,8 @@ class TC_00_AppVMMixin(object):
|
|||||||
stdout, stderr = self.loop.run_until_complete(
|
stdout, stderr = self.loop.run_until_complete(
|
||||||
self.testvm1.run_for_stdio(
|
self.testvm1.run_for_stdio(
|
||||||
'/usr/lib/qubes/qrexec-client-vm '
|
'/usr/lib/qubes/qrexec-client-vm '
|
||||||
'{} test.Argument+argument'.format(self.testvm2.name)))
|
'{} test.Argument+argument'.format(self.testvm2.name),
|
||||||
|
stderr=None))
|
||||||
self.assertEqual(stdout, b'argument')
|
self.assertEqual(stdout, b'argument')
|
||||||
|
|
||||||
def test_082_qrexec_service_argument_deny_specific(self):
|
def test_082_qrexec_service_argument_deny_specific(self):
|
||||||
@ -534,7 +548,8 @@ class TC_00_AppVMMixin(object):
|
|||||||
self.loop.run_until_complete(
|
self.loop.run_until_complete(
|
||||||
self.testvm1.run_for_stdio(
|
self.testvm1.run_for_stdio(
|
||||||
'/usr/lib/qubes/qrexec-client-vm {} '
|
'/usr/lib/qubes/qrexec-client-vm {} '
|
||||||
'test.Argument+argument'.format(self.testvm2.name)))
|
'test.Argument+argument'.format(self.testvm2.name),
|
||||||
|
stderr=None))
|
||||||
|
|
||||||
def test_083_qrexec_service_argument_specific_implementation(self):
|
def test_083_qrexec_service_argument_specific_implementation(self):
|
||||||
"""Qrexec service call with argument - argument specific
|
"""Qrexec service call with argument - argument specific
|
||||||
@ -553,7 +568,8 @@ class TC_00_AppVMMixin(object):
|
|||||||
with self.qrexec_policy('test.Argument', self.testvm1, self.testvm2):
|
with self.qrexec_policy('test.Argument', self.testvm1, self.testvm2):
|
||||||
stdout, stderr = self.loop.run_until_complete(
|
stdout, stderr = self.loop.run_until_complete(
|
||||||
self.testvm1.run_for_stdio('/usr/lib/qubes/qrexec-client-vm '
|
self.testvm1.run_for_stdio('/usr/lib/qubes/qrexec-client-vm '
|
||||||
'{} test.Argument+argument'.format(self.testvm2.name)))
|
'{} test.Argument+argument'.format(self.testvm2.name),
|
||||||
|
stderr=None))
|
||||||
|
|
||||||
self.assertEqual(stdout, b'specific: argument')
|
self.assertEqual(stdout, b'specific: argument')
|
||||||
|
|
||||||
@ -570,7 +586,8 @@ class TC_00_AppVMMixin(object):
|
|||||||
with self.qrexec_policy('test.Argument', self.testvm1, self.testvm2):
|
with self.qrexec_policy('test.Argument', self.testvm1, self.testvm2):
|
||||||
stdout, stderr = self.loop.run_until_complete(
|
stdout, stderr = self.loop.run_until_complete(
|
||||||
self.testvm1.run_for_stdio('/usr/lib/qubes/qrexec-client-vm '
|
self.testvm1.run_for_stdio('/usr/lib/qubes/qrexec-client-vm '
|
||||||
'{} test.Argument+argument'.format(self.testvm2.name)))
|
'{} test.Argument+argument'.format(self.testvm2.name),
|
||||||
|
stderr=None))
|
||||||
|
|
||||||
self.assertEqual(stdout, b'test.Argument+argument argument')
|
self.assertEqual(stdout, b'test.Argument+argument argument')
|
||||||
|
|
||||||
@ -589,6 +606,9 @@ class TC_00_AppVMMixin(object):
|
|||||||
self.testvm1.run_for_stdio(
|
self.testvm1.run_for_stdio(
|
||||||
'qrexec-client-vm @adminvm test.Socket', input=TEST_DATA),
|
'qrexec-client-vm @adminvm test.Socket', input=TEST_DATA),
|
||||||
timeout=10))
|
timeout=10))
|
||||||
|
except subprocess.CalledProcessError as e:
|
||||||
|
self.fail('{} exited with non-zero code {}; stderr: {}'.format(
|
||||||
|
e.cmd, e.returncode, e.stderr))
|
||||||
except asyncio.TimeoutError:
|
except asyncio.TimeoutError:
|
||||||
self.fail(
|
self.fail(
|
||||||
"service timeout, probably EOF wasn't transferred to the VM process")
|
"service timeout, probably EOF wasn't transferred to the VM process")
|
||||||
@ -625,6 +645,9 @@ class TC_00_AppVMMixin(object):
|
|||||||
self.testvm1.run_for_stdio(
|
self.testvm1.run_for_stdio(
|
||||||
'qrexec-client-vm @adminvm test.Socket'),
|
'qrexec-client-vm @adminvm test.Socket'),
|
||||||
timeout=10))
|
timeout=10))
|
||||||
|
except subprocess.CalledProcessError as e:
|
||||||
|
self.fail('{} exited with non-zero code {}; stderr: {}'.format(
|
||||||
|
e.cmd, e.returncode, e.stderr))
|
||||||
except asyncio.TimeoutError:
|
except asyncio.TimeoutError:
|
||||||
self.fail(
|
self.fail(
|
||||||
"service timeout, probably EOF wasn't transferred to the VM process")
|
"service timeout, probably EOF wasn't transferred to the VM process")
|
||||||
@ -759,6 +782,9 @@ class TC_00_AppVMMixin(object):
|
|||||||
(stdout, stderr) = self.loop.run_until_complete(asyncio.wait_for(
|
(stdout, stderr) = self.loop.run_until_complete(asyncio.wait_for(
|
||||||
self.testvm1.run_service_for_stdio('test.Socket+', input=TEST_DATA),
|
self.testvm1.run_service_for_stdio('test.Socket+', input=TEST_DATA),
|
||||||
timeout=10))
|
timeout=10))
|
||||||
|
except subprocess.CalledProcessError as e:
|
||||||
|
self.fail('{} exited with non-zero code {}; stderr: {}'.format(
|
||||||
|
e.cmd, e.returncode, e.stderr))
|
||||||
except asyncio.TimeoutError:
|
except asyncio.TimeoutError:
|
||||||
self.fail(
|
self.fail(
|
||||||
"service timeout, probably EOF wasn't transferred to the VM process")
|
"service timeout, probably EOF wasn't transferred to the VM process")
|
||||||
@ -798,6 +824,9 @@ class TC_00_AppVMMixin(object):
|
|||||||
(stdout, stderr) = self.loop.run_until_complete(asyncio.wait_for(
|
(stdout, stderr) = self.loop.run_until_complete(asyncio.wait_for(
|
||||||
self.testvm1.run_service_for_stdio('test.Socket+'),
|
self.testvm1.run_service_for_stdio('test.Socket+'),
|
||||||
timeout=10))
|
timeout=10))
|
||||||
|
except subprocess.CalledProcessError as e:
|
||||||
|
self.fail('{} exited with non-zero code {}; stderr: {}'.format(
|
||||||
|
e.cmd, e.returncode, e.stderr))
|
||||||
except asyncio.TimeoutError:
|
except asyncio.TimeoutError:
|
||||||
self.fail(
|
self.fail(
|
||||||
"service timeout, probably EOF wasn't transferred to the VM process")
|
"service timeout, probably EOF wasn't transferred to the VM process")
|
||||||
|
Loading…
Reference in New Issue
Block a user