From c361b8500f447daf7aed8b577742d495f498cd90 Mon Sep 17 00:00:00 2001 From: Benjamin Tissoires Date: Sat, 29 Jul 2017 08:56:23 +0100 Subject: [PATCH] test: make sure the dbus daemon is available before starting the test suite On CircleCI, the builds fail one over four times because we are launching the testsuite while ratbagd.devel is still not ready. Do a basic polling after we launch the daemon so that we are aware when the ratbagd daemon is ready. A proper solution would be to use "new" for querying the proxy, not "new_sync". However, this would require us to have a GTK mainloop running, so it's a PITA. Signed-off-by: Benjamin Tissoires --- tools/ratbagctl.test.in | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/tools/ratbagctl.test.in b/tools/ratbagctl.test.in index aff7e672..90ce7ea6 100755 --- a/tools/ratbagctl.test.in +++ b/tools/ratbagctl.test.in @@ -547,6 +547,9 @@ class TestRatbgagCtlLED(TestRatbagCtl): def setUpModule(): + from gi.repository import Gio + import time + global ratbagd_process, ratbagd, parser # first copy the policy for the ratbagd daemon to be allowed to run shutil.copy(os.path.join('@MESON_BUILD_ROOT@', DBUS_CONF_NAME), DBUS_CONF_PATH) @@ -555,6 +558,22 @@ def setUpModule(): ratbagd_process = subprocess.Popen([os.path.join('@MESON_BUILD_ROOT@', "ratbagd.devel")], shell=False) + dbus = Gio.bus_get_sync(Gio.BusType.SYSTEM, None) + + name_owner = None + start_time = time.clock() + while name_owner is None and time.clock() - start_time < 30: + proxy = Gio.DBusProxy.new_sync(dbus, + Gio.DBusProxyFlags.NONE, + None, + "org.freedesktop.ratbag_devel1_@ratbagd_sha@", + "/org/freedesktop/ratbag_devel1_@ratbagd_sha@", + "org.freedesktop.ratbag_devel1_@ratbagd_sha@.Manager", + None) + name_owner = proxy.get_name_owner() + if name_owner is None: + time.sleep(0.2) + os.environ['RATBAGCTL_DEVEL'] = "org.freedesktop.ratbag_devel1_@ratbagd_sha@" ratbagd = ratbagctl.open_ratbagd()