Skip to content

Commit

Permalink
qubes/tests/integ/vm_qrexec_gui: change time.sleep to asyncio.sleep
Browse files Browse the repository at this point in the history
  • Loading branch information
woju authored and marmarek committed Jun 20, 2017
1 parent 96a66ac commit 0c0b0ea
Showing 1 changed file with 12 additions and 19 deletions.
31 changes: 12 additions & 19 deletions qubes/tests/integ/vm_qrexec_gui.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,17 +70,10 @@ def create_remote_file(self, vm, filename, content):
user='root', input=content.encode('utf-8')))

def test_000_start_shutdown(self):
# TODO: wait_for, timeout
self.loop.run_until_complete(self.testvm1.start())
self.assertEqual(self.testvm1.get_power_state(), "Running")
self.loop.run_until_complete(self.testvm1.shutdown())

shutdown_counter = 0
while self.testvm1.is_running():
if shutdown_counter > qubes.config.defaults["shutdown_counter_max"]:
self.fail("VM hanged during shutdown")
shutdown_counter += 1
time.sleep(1)
time.sleep(1)
self.loop.run_until_complete(self.testvm1.shutdown(wait=True))
self.assertEqual(self.testvm1.get_power_state(), "Halted")

@unittest.skipUnless(spawn.find_executable('xdotool'),
Expand All @@ -101,9 +94,9 @@ def test_010_run_xterm(self):
wait_count += 1
if wait_count > 100:
self.fail("Timeout while waiting for xterm window")
time.sleep(0.1)
self.loop.run_until_complete(asyncio.sleep(0.1))

time.sleep(0.5)
self.loop.run_until_complete(asyncio.sleep(0.5))
subprocess.check_call(
['xdotool', 'search', '--name', title,
'windowactivate', 'type', 'exit\n'])
Expand All @@ -116,7 +109,7 @@ def test_010_run_xterm(self):
if wait_count > 100:
self.fail("Timeout while waiting for xterm "
"termination")
time.sleep(0.1)
self.loop.run_until_complete(asyncio.sleep(0.1))
finally:
p.terminate()
self.loop.run_until_complete(p.wait())
Expand All @@ -141,9 +134,9 @@ def test_011_run_gnome_terminal(self):
wait_count += 1
if wait_count > 100:
self.fail("Timeout while waiting for gnome-terminal window")
time.sleep(0.1)
self.loop.run_until_complete(asyncio.sleep(0.1))

time.sleep(0.5)
self.loop.run_until_complete(asyncio.sleep(0.5))
subprocess.check_call(
['xdotool', 'search', '--name', title,
'windowactivate', '--sync', 'type', 'exit\n'])
Expand All @@ -156,7 +149,7 @@ def test_011_run_gnome_terminal(self):
if wait_count > 100:
self.fail("Timeout while waiting for gnome-terminal "
"termination")
time.sleep(0.1)
self.loop.run_until_complete(asyncio.sleep(0.1))
finally:
p.terminate()
self.loop.run_until_complete(p.wait())
Expand Down Expand Up @@ -191,9 +184,9 @@ def test_012_qubes_desktop_run(self):
wait_count += 1
if wait_count > 100:
self.fail("Timeout while waiting for xterm window")
time.sleep(0.1)
self.loop.run_until_complete(asyncio.sleep(0.1))

time.sleep(0.5)
self.loop.run_until_complete(asyncio.sleep(0.5))
subprocess.check_call(
['xdotool', 'search', '--name', title,
'windowactivate', '--sync', 'type', 'exit\n'])
Expand All @@ -206,7 +199,7 @@ def test_012_qubes_desktop_run(self):
if wait_count > 100:
self.fail("Timeout while waiting for xterm "
"termination")
time.sleep(0.1)
self.loop.run_until_complete(asyncio.sleep(0.1))

def test_050_qrexec_simple_eof(self):
"""Test for data and EOF transmission dom0->VM"""
Expand Down Expand Up @@ -765,7 +758,7 @@ def test_210_time_sync(self):
# service, send it timestamp value and exists without waiting for
# actual time set

time.sleep(1)
self.loop.run_until_complete(asyncio.sleep(1))
vm_time, _ = self.loop.run_until_complete(
self.testvm1.run_for_stdio('date -u +%s'))
self.assertAlmostEquals(int(vm_time), int(start_time), delta=30)
Expand Down

0 comments on commit 0c0b0ea

Please sign in to comment.