diff options
author | Patrick Ohly <patrick.ohly@intel.com> | 2020-03-02 04:49:11 -0800 |
---|---|---|
committer | Patrick Ohly <patrick.ohly@intel.com> | 2020-08-09 16:26:42 +0200 |
commit | 83782724122c34ae45b57b8bc803b23f039475e7 (patch) | |
tree | 1114fad98b21c55368615b5bb4264eec66bcc336 | |
parent | 77a9a450d2fee38e23f4e0a289298b3d313cfca1 (diff) |
test: fix D-Bus testing result gathering
Successful tests were not picked up by the result checker if there was
extra output between printing the test name and the " ... ok".
One source of that extra output was the D-Bus server and daemons
started by it (now redirected to a file), the other a glib warning
about an event ID not being found (caused by double-removal of a
timer, which is mostly avoided now).
Signed-off-by: Patrick Ohly <patrick.ohly@intel.com>
-rwxr-xr-x | test/dbus-session.sh | 2 | ||||
-rwxr-xr-x | test/test-dbus.py | 13 |
2 files changed, 11 insertions, 4 deletions
diff --git a/test/dbus-session.sh b/test/dbus-session.sh index 23d6c133..f6c3571f 100755 --- a/test/dbus-session.sh +++ b/test/dbus-session.sh @@ -65,7 +65,7 @@ createxdg "$XDG_DATA_HOME" # See https://launchpad.net/bugs/525642 and # https://bugzilla.redhat.com/show_bug.cgi?id=572137 if [ -x /usr/bin/gnome-keyring-daemon ]; then - /usr/bin/gnome-keyring-daemon --start --foreground --components=secrets 1>&2 & + /usr/bin/gnome-keyring-daemon --start --foreground --components=secrets 2>gnome-keyring-daemon.txt 1>&2 & KEYRING_PID=$! fi diff --git a/test/test-dbus.py b/test/test-dbus.py index d73e5032..3672eb17 100755 --- a/test/test-dbus.py +++ b/test/test-dbus.py @@ -24,6 +24,7 @@ import unittest import subprocess import time import os +import os.path import errno import signal import shutil @@ -333,7 +334,9 @@ class Timeout: @classmethod def removeTimeout(cls, timeout): """Remove a timeout returned by a previous addTimeout call. - None and timeouts which have already fired are acceptable.""" + None and timeouts which have already fired are acceptable, + but the latter may trigger a glib warning and thus should better be + avoided.""" if timeout == None: pass elif isinstance(timeout, tuple): @@ -2301,7 +2304,8 @@ class TestDBusSession(DBusUtil, unittest.TestCase): status, error, sources = session.GetStatus(utf8_strings=True) self.assertEqual(status, "idle") finally: - self.removeTimeout(t1) + if callback_called.get(1, "") != "callback()": + self.removeTimeout(t1) class TestSessionAPIsEmptyName(DBusUtil, unittest.TestCase): """Test session APIs that work with an empty server name. Thus, all of session APIs which @@ -3167,7 +3171,10 @@ class TestSessionAPIsDummy(DBusUtil, unittest.TestCase): timeout = glib.timeout_add(15 * 1000, testDone) loop.run() finally: - glib.source_remove(timeout) + # If the timeout has fired, then don't remove the timeout again to + # avoid the "Warning: Source ID 4274 was not found when attempting to remove it" + if not "test done" in DBusUtil.quit_events: + glib.source_remove(timeout) self.assertEqual(DBusUtil.quit_events, ["session " + self.auto_sync_session_path + " ready", "session " + self.auto_sync_session_path + " done", "test done"]) |