qubes.tests asyncio, part 2

QubesOS/qubes-issues#2622
This commit is contained in:
Wojtek Porczyk 2017-05-29 19:08:38 +02:00
parent df03800278
commit 42cbd9ff68
2 changed files with 12 additions and 2 deletions

View File

@ -245,7 +245,12 @@ class _QrexecPolicyContext(object):
'allow' if allow else 'deny')
def _change(self, add=True):
with self._filename.open('r+') as policy:
try:
policy = self._filename.open('r+')
except FileNotFoundError:
policy = self._filename.open('w+')
try:
policy_rules = policy.readlines()
if add:
policy_rules.insert(0, self._rule)
@ -254,6 +259,8 @@ class _QrexecPolicyContext(object):
policy.truncate(0)
policy.seek(0)
policy.write(''.join(policy_rules))
finally:
policy.close()
def __enter__(self):
self._change(add=True)

View File

@ -234,7 +234,10 @@ class TC_00_AppVMMixin(qubes.tests.SystemTestsMixin):
@asyncio.coroutine
def run(self):
p = yield from self.testvm1.run(
'echo test; exec >&-; cat > /dev/null')
'echo test; exec >&-; cat > /dev/null',
stdin=subprocess.PIPE,
stdout=subprocess.PIPE,
stderr=subprocess.PIPE)
# this will hang on test failure
stdout = yield from p.stdout.read()