tests: various fixes

- Use proper features/services names (updates proxy test).
- Fix logic error in wait_for_window.
- Fix test for qvm-sync-clock (first sync clockvm, then dom0), also fix
  cleanup (unset clockvm before removing it)
- More fixes for asyncio usage
This commit is contained in:
Marek Marczykowski-Górecki 2017-10-02 18:26:18 +02:00
parent 64c5b2c00f
commit cbc5dbb9b1
No known key found for this signature in database
GPG Key ID: 063938BA42CFA724
3 changed files with 17 additions and 14 deletions

View File

@ -939,7 +939,7 @@ class SystemTestCase(QubesTestCase):
wait_count = 0
while subprocess.call(['xdotool', 'search', '--name', title],
stdout=subprocess.DEVNULL, stderr=subprocess.STDOUT) \
== int(show):
== int(not show):
wait_count += 1
if wait_count > timeout*10:
self.fail("Timeout while waiting for {} window to {}".format(

View File

@ -899,10 +899,9 @@ SHA256:
self.netvm_repo.provides_network = True
self.loop.run_until_complete(self.netvm_repo.create_on_disk())
self.testvm1.netvm = self.netvm_repo
# NetVM should have qubes-updates-proxy enabled by default
#self.netvm_repo.features['qubes-updates-proxy'] = True
self.netvm_repo.features['service.qubes-updates-proxy'] = True
# TODO: consider also adding a test for the template itself
self.testvm1.features['updates-proxy-setup'] = True
self.testvm1.features['service.updates-proxy-setup'] = True
self.app.save()
# Setup test repo
@ -915,7 +914,8 @@ SHA256:
# update repository metadata
p = self.loop.run_until_complete(self.testvm1.run(
self.update_cmd, user='root'))
self.update_cmd, user='root', stdout=subprocess.PIPE,
stderr=subprocess.PIPE))
(stdout, stderr) = self.loop.run_until_complete(p.communicate())
self.assertIn(self.loop.run_until_complete(p.wait()), self.exit_code_ok,
'{}: {}\n{}'.format(self.update_cmd, stdout, stderr))

View File

@ -751,15 +751,15 @@ class TC_00_AppVMMixin(object):
self.testvm1.run_for_stdio('date -s 2001-01-01T12:34:56',
user='root'))
self.loop.run_until_complete(
self.testvm1.run_for_stdio('qvm-sync-clock',
user='root'))
p = self.loop.run_until_complete(
asyncio.create_subprocess_exec('sudo', 'qvm-sync-clock',
stdout=asyncio.subprocess.DEVNULL))
self.loop.run_until_complete(p.wait())
self.assertEqual(p.returncode, 0)
self.loop.run_until_complete(
self.testvm1.run_for_stdio('qvm-sync-clock',
user='root'))
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)
@ -772,6 +772,8 @@ class TC_00_AppVMMixin(object):
subprocess.Popen(
["sudo", "date", "-u", "-s", "@" + start_time.decode()])
raise
finally:
self.app.clockvm = None
@unittest.expectedFailure
def test_250_resize_private_img(self):
@ -894,12 +896,13 @@ int main(int argc, char **argv) {
'ulimit -l unlimited; exec /home/user/allocator {}'.format(
memory_pages),
user="root",
stdin=subprocess.PIPE, stdout=subprocess.PIPE)
stdin=subprocess.PIPE, stdout=subprocess.PIPE,
stderr=subprocess.PIPE)
# wait for memory being allocated; can't use just .read(), because EOF
# passing is unreliable while the process is still running
yield from alloc1.stdin.write(b'\n')
yield from alloc1.stdin.flush()
alloc1.stdin.write(b'\n')
yield from alloc1.stdin.drain()
alloc_out = yield from alloc1.stdout.read(
len('Stage1\nStage2\nStage3\n'))
@ -931,8 +934,8 @@ int main(int argc, char **argv) {
vm_winid = xprop.decode().strip().split(' ')[4]
# now free the fragmented memory and trigger compaction
yield from alloc1.stdin.write(b'\n')
yield from alloc1.stdin.flush()
alloc1.stdin.write(b'\n')
yield from alloc1.stdin.drain()
yield from alloc1.wait()
yield from self.testvm1.run_for_stdio(
'echo 1 > /proc/sys/vm/compact_memory', user='root')