Skip to content

Commit

Permalink
tests: wait for session in tests requiring running GUI
Browse files Browse the repository at this point in the history
Since tests expose qubesd socket, qvm-start-gui should handle starting
GUI daemons (so, GUI session inside VM). Add synchronization with it
using qubes.WaitForSession service.
  • Loading branch information
marmarek committed Jun 21, 2017
1 parent 376ac4b commit a73dcf6
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
7 changes: 7 additions & 0 deletions qubes/tests/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -938,6 +938,13 @@ def create_remote_file(self, vm, filename, content):
'cat > {}'.format(shlex.quote(filename)),
user='root', input=content.encode('utf-8')))

@asyncio.coroutine
def wait_for_session(self, vm):
yield from asyncio.wait_for(
vm.run_service_for_stdio(
'qubes.WaitForSession', input=vm.default_user.encode()),
timeout=30)


def load_tests(loader, tests, pattern): # pylint: disable=unused-argument
# discard any tests from this module, because it hosts base classes
Expand Down
6 changes: 6 additions & 0 deletions qubes/tests/integ/vm_qrexec_gui.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ def test_010_run_xterm(self):
self.loop.run_until_complete(self.testvm1.start())
self.assertEqual(self.testvm1.get_power_state(), "Running")

self.loop.run_until_complete(self.wait_for_session(self.testvm1))
p = self.loop.run_until_complete(self.testvm1.run('xterm'))
try:
wait_count = 0
Expand Down Expand Up @@ -110,6 +111,7 @@ def test_011_run_gnome_terminal(self):
self.skipTest("Minimal template doesn't have 'gnome-terminal'")
self.loop.run_until_complete(self.testvm1.start())
self.assertEqual(self.testvm1.get_power_state(), "Running")
self.loop.run_until_complete(self.wait_for_session(self.testvm1))
p = self.loop.run_until_complete(self.testvm1.run('gnome-terminal'))
try:
title = 'user@{}'.format(self.testvm1.name)
Expand Down Expand Up @@ -163,6 +165,7 @@ def test_012_qubes_desktop_run(self):
pass
else:
xterm_desktop_path = xterm_desktop_path_debian
self.loop.run_until_complete(self.wait_for_session(self.testvm1))
self.loop.run_until_complete(
self.testvm1.run('qubes-desktop-run {}'.format(xterm_desktop_path)))
title = 'user@{}'.format(self.testvm1.name)
Expand Down Expand Up @@ -687,6 +690,8 @@ def test_130_qrexec_filemove_disk_full(self):
self.testvm1.start(),
self.testvm2.start()]))

self.loop.run_until_complete(self.wait_for_session(self.testvm1))

# Prepare test file
self.loop.run_until_complete(self.testvm1.run_for_stdio(
'yes teststring | dd of=testfile bs=1M count=50 iflag=fullblock'))
Expand Down Expand Up @@ -818,6 +823,7 @@ def _test_300_bug_1028_gui_memory_pinning(self):
# exclude from memory balancing
self.testvm1.features['services/meminfo-writer'] = False
yield from self.testvm1.start()
yield from self.wait_for_session(self.testvm1)

# and allow large map count
yield from self.testvm1.run('echo 256000 > /proc/sys/vm/max_map_count',
Expand Down

0 comments on commit a73dcf6

Please sign in to comment.