Skip to content

Commit

Permalink
tests: fix vm.run_for_stdio in some more places
Browse files Browse the repository at this point in the history
When test expect to wait for remote process, use vm.run_for_stdio.
Additionally, when the call fail, (stdout, stderr) is not assigned - use
the one attached to exception object instead.
  • Loading branch information
marmarek committed Jun 21, 2017
1 parent a0f616f commit 376ac4b
Showing 1 changed file with 15 additions and 13 deletions.
28 changes: 15 additions & 13 deletions qubes/tests/integ/vm_qrexec_gui.py
Original file line number Diff line number Diff line change
Expand Up @@ -497,8 +497,9 @@ def test_081_qrexec_service_argument_allow_specific(self):
with self.qrexec_policy('test.Argument', '$anyvm', '$anyvm', False):
with self.qrexec_policy('test.Argument+argument',
self.testvm1.name, self.testvm2.name):
stdout, stderr = self.loop.run_until_complete(self.testvm1.run(
'/usr/lib/qubes/qrexec-client-vm '
stdout, stderr = self.loop.run_until_complete(
self.testvm1.run_for_stdio(
'/usr/lib/qubes/qrexec-client-vm '
'{} test.Argument+argument'.format(self.testvm2.name)))
self.assertEqual(stdout, b'argument')

Expand All @@ -516,7 +517,8 @@ def test_082_qrexec_service_argument_deny_specific(self):
with self.assertRaises(subprocess.CalledProcessError,
msg='Service request should be denied'):
self.loop.run_until_complete(
self.testvm1.run('/usr/lib/qubes/qrexec-client-vm {} '
self.testvm1.run_for_stdio(
'/usr/lib/qubes/qrexec-client-vm {} '
'test.Argument+argument'.format(self.testvm2.name)))

def test_083_qrexec_service_argument_specific_implementation(self):
Expand Down Expand Up @@ -564,12 +566,12 @@ def test_100_qrexec_filecopy(self):

with self.qrexec_policy('qubes.Filecopy', self.testvm1, self.testvm2):
try:
stdout, stderr = self.loop.run_until_complete(
self.loop.run_until_complete(
self.testvm1.run_for_stdio(
'qvm-copy-to-vm {} /etc/passwd'.format(
self.testvm2.name)))
except subprocess.CalledProcessError:
self.fail('qvm-copy-to-vm failed: {}'.format(stderr))
except subprocess.CalledProcessError as e:
self.fail('qvm-copy-to-vm failed: {}'.format(e.stderr))

try:
self.loop.run_until_complete(self.testvm2.run_for_stdio(
Expand All @@ -593,11 +595,11 @@ def test_105_qrexec_filemove(self):
'cp /etc/passwd passwd'))
with self.qrexec_policy('qubes.Filecopy', self.testvm1, self.testvm2):
try:
stdout, stderr = self.loop.run_until_complete(
self.loop.run_until_complete(
self.testvm1.run_for_stdio(
'qvm-move-to-vm {} passwd'.format(self.testvm2.name)))
except subprocess.CalledProcessError:
self.fail('qvm-move-to-vm failed: {}'.format(stderr))
except subprocess.CalledProcessError as e:
self.fail('qvm-move-to-vm failed: {}'.format(e.stderr))

try:
self.loop.run_until_complete(self.testvm2.run_for_stdio(
Expand All @@ -615,12 +617,12 @@ def test_101_qrexec_filecopy_with_autostart(self):

with self.qrexec_policy('qubes.Filecopy', self.testvm1, self.testvm2):
try:
stdout, stderr = self.loop.run_until_complete(
self.loop.run_until_complete(
self.testvm1.run_for_stdio(
'qvm-copy-to-vm {} /etc/passwd'.format(
self.testvm2.name)))
except subprocess.CalledProcessError:
self.fail('qvm-copy-to-vm failed: {}'.format(stderr))
except subprocess.CalledProcessError as e:
self.fail('qvm-copy-to-vm failed: {}'.format(e.stderr))

# workaround for libvirt bug (domain ID isn't updated when is started
# from other application) - details in
Expand Down Expand Up @@ -650,7 +652,7 @@ def test_110_qrexec_filecopy_deny(self):
with self.qrexec_policy('qubes.Filecopy', self.testvm1, self.testvm2,
allow=False):
with self.assertRaises(subprocess.CalledProcessError):
stdout, stderr = self.loop.run_until_complete(
self.loop.run_until_complete(
self.testvm1.run_for_stdio(
'qvm-copy-to-vm {} /etc/passwd'.format(
self.testvm2.name)))
Expand Down

0 comments on commit 376ac4b

Please sign in to comment.