From ec18a1d7ae474fdfd70a51f1c6f607607eac4a2c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jonas=20=C3=85dahl?= Date: Fri, 28 Oct 2022 15:49:32 +0200 Subject: [PATCH] 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: --- src/tests/mutter_dbusrunner.py | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/src/tests/mutter_dbusrunner.py b/src/tests/mutter_dbusrunner.py index 5f21bd2c5..7de4653bb 100644 --- a/src/tests/mutter_dbusrunner.py +++ b/src/tests/mutter_dbusrunner.py @@ -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