qubes/tests/run: refuse to run tests if qubesd is running

Test suite creates some VMs and needs to pass the knowledge about them
to qrexec policy checker. This is done using Admin API, so we need to
substitute qubesd with our own API server.
This commit is contained in:
Wojtek Porczyk 2017-06-05 16:14:30 +02:00 committed by Marek Marczykowski-Górecki
parent 858e547525
commit 4b8e5c3704
No known key found for this signature in database
GPG Key ID: 063938BA42CFA724

View File

@ -32,6 +32,7 @@ import unittest
import unittest.signals import unittest.signals
import qubes.tests import qubes.tests
import qubes.api.admin
class CursesColor(dict): class CursesColor(dict):
colors = ( colors = (
@ -331,6 +332,11 @@ parser.add_argument('--no-kmsg', '--i-am-smarter-than-kay-sievers',
action='store_false', dest='kmsg', action='store_false', dest='kmsg',
help='do not abuse kernel ring-buffer') help='do not abuse kernel ring-buffer')
parser.add_argument('--allow-running-along-qubesd',
action='store_true', default=False,
help='allow running in parallel with qubesd;'
' this is DANGEROUS and WILL RESULT IN INCONSISTENT SYSTEM STATE')
parser.add_argument('names', metavar='TESTNAME', parser.add_argument('names', metavar='TESTNAME',
action='store', nargs='*', action='store', nargs='*',
help='list of tests to run named like in description ' help='list of tests to run named like in description '
@ -406,6 +412,10 @@ def main():
ha_kmsg.setLevel(logging.CRITICAL) ha_kmsg.setLevel(logging.CRITICAL)
logging.root.addHandler(ha_kmsg) logging.root.addHandler(ha_kmsg)
if not args.allow_running_along_qubesd \
and os.path.exists(qubes.api.admin.QUBESD_ADMIN_SOCK):
parser.error('refusing to run until qubesd is disabled')
runner = unittest.TextTestRunner(stream=sys.stdout, runner = unittest.TextTestRunner(stream=sys.stdout,
verbosity=(args.verbose-args.quiet), verbosity=(args.verbose-args.quiet),
failfast=args.failfast) failfast=args.failfast)