tests/dbus-runner: Add way to launch custom services

This will be used by CI to launch wireplumber inside the D-Bus session
started by meta-dbus-runner.py.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2678>
This commit is contained in:
Jonas Ådahl 2022-10-28 15:49:32 +02:00 committed by Marge Bot
parent 562024f746
commit ec18a1d7ae

View File

@ -26,7 +26,7 @@ class MutterDBusRunner(DBusTestCase):
return os.path.join(os.path.dirname(__file__), 'dbusmock-templates')
@classmethod
def setUpClass(klass, enable_kvm):
def setUpClass(klass, enable_kvm, launch):
klass.templates_dirs = [klass.__get_templates_dir()]
klass.mocks = OrderedDict()
@ -36,6 +36,11 @@ class MutterDBusRunner(DBusTestCase):
klass.start_session_bus()
klass.start_system_bus()
print('Launching required services...', file=sys.stderr)
klass.service_processes = []
for service in launch:
klass.service_processes += [subprocess.Popen(service)]
print('Starting mocked services...', file=sys.stderr)
(klass.mocks_manager, klass.mock_obj) = klass.start_from_local_template(
'meta-mocks-manager', {'templates-dir': klass.__get_templates_dir()})
@ -61,6 +66,10 @@ class MutterDBusRunner(DBusTestCase):
mock_server.terminate()
mock_server.wait()
for process in klass.service_processes:
process.terminate()
process.wait()
DBusTestCase.tearDownClass()
@classmethod
@ -189,13 +198,14 @@ def meta_run(klass):
parser = argparse.ArgumentParser()
parser.add_argument('--kvm', action='store_true', default=False)
parser.add_argument('--launch', action='append', default=[])
(args, rest) = parser.parse_known_args(sys.argv)
rest.pop(0)
if rest[0] == '--':
rest.pop(0)
klass.setUpClass(args.kvm)
klass.setUpClass(args.kvm, args.launch)
runner = klass()
runner.assertGreater(len(rest), 0)
result = 1