From 55569ac40f1756b879a5ee676925be7bbd985588 Mon Sep 17 00:00:00 2001 From: Martin Pitt Date: Thu, 14 Jun 2012 13:07:30 +0200 Subject: [PATCH] integration-test: fail on CRITICALs Crash the daemon on any CRITICAL message, and also set WARNING and CRITICAL messages to be fatal on the client side. On the server side we might have some legitimate warnings, such as failing to load the config file from /usr/local/etc (if you build a tree without passing correct --sysconfdir options, etc.). This exposes the current CRITICAL the daemon raises at startup. As with that the daemon never starts up, fix the "wait for the daemon" loop to time out after 10 seconds. --- src/linux/integration-test | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/linux/integration-test b/src/linux/integration-test index df61495..986d98d 100755 --- a/src/linux/integration-test +++ b/src/linux/integration-test @@ -58,6 +58,11 @@ class Tests(unittest.TestCase): break assert daemon_path, 'could not determine daemon path from D-BUS .service file' + # fail on CRITICALs on client side + GLib.log_set_always_fatal(GLib.LogLevelFlags.LEVEL_WARNING| + GLib.LogLevelFlags.LEVEL_ERROR| + GLib.LogLevelFlags.LEVEL_CRITICAL) + # if we are root, test the real thing on the system bus, otherwise # start on the session bus if os.geteuid() == 0: @@ -163,19 +168,24 @@ class Tests(unittest.TestCase): When done, this sets self.proxy a the Gio.DBusProxy for upowerd. ''' env = os.environ.copy() + env['G_DEBUG'] = 'fatal-criticals' env['SYSFS_PATH'] = self.sysfs self.log = tempfile.NamedTemporaryFile() self.daemon = subprocess.Popen(self.daemon_argv, env=env, stdout=self.log, stderr=subprocess.STDOUT) # wait until the daemon gets online - while True: + timeout = 100 + while timeout > 0: time.sleep(0.1) + timeout -= 1 try: self.get_dbus_property('DaemonVersion') break except GLib.GError: pass + else: + self.fail('daemon did not start in 10 seconds') self.proxy = Gio.DBusProxy.new_sync(self.dbus, Gio.DBusProxyFlags.DO_NOT_AUTO_START, None,