Skip to content

Commit

Permalink
tests: try to collect qvm-open-in-dvm output if no editor window is s…
Browse files Browse the repository at this point in the history
…hown

Try to collect more details about why the test failed. This will help
only if qvm-open-in-dvm exist early. On the other hand, if it hang, or
remote side fails to find the right editor (which results in GUI error
message), this change will not provide any more details.
  • Loading branch information
marmarek committed Oct 29, 2018
1 parent 84c321b commit 42061cb
Showing 1 changed file with 15 additions and 3 deletions.
18 changes: 15 additions & 3 deletions qubes/tests/integ/dispvm.py
Original file line number Diff line number Diff line change
Expand Up @@ -253,12 +253,24 @@ def test_030_edit_file(self):
self.testvm1.run_for_stdio("echo test1 > /home/user/test.txt"))

p = self.loop.run_until_complete(
self.testvm1.run("qvm-open-in-dvm /home/user/test.txt"))
self.testvm1.run("qvm-open-in-dvm /home/user/test.txt",
stdout=subprocess.PIPE, stderr=subprocess.STDOUT))

# if first 5 windows isn't expected editor, there is no hope
winid = None
for _ in range(5):
winid = self.wait_for_window('disp[0-9]*', search_class=True)
try:
winid = self.wait_for_window('disp[0-9]*', search_class=True)
except Exception as e:
try:
self.loop.run_until_complete(asyncio.wait_for(p.wait(), 1))
except asyncio.TimeoutError:
raise e
else:
stdout = self.loop.run_until_complete(p.stdout.read())
self.fail(
'qvm-open-in-dvm exited prematurely with {}: {}'.format(
p.returncode, stdout))
# get window title
(window_title, _) = subprocess.Popen(
['xdotool', 'getwindowname', winid], stdout=subprocess.PIPE). \
Expand All @@ -278,7 +290,7 @@ def test_030_edit_file(self):

time.sleep(0.5)
self._handle_editor(winid)
self.loop.run_until_complete(p.wait())
self.loop.run_until_complete(p.communicate())
(test_txt_content, _) = self.loop.run_until_complete(
self.testvm1.run_for_stdio("cat /home/user/test.txt"))
# Drop BOM if added by editor
Expand Down

0 comments on commit 42061cb

Please sign in to comment.