summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSam Thursfield <sam.thursfield@codethink.co.uk>2013-11-25 14:42:13 +0000
committerSam Thursfield <sam.thursfield@codethink.co.uk>2013-11-25 18:20:24 +0000
commitfbbf5a41b1606fed73d1e7a14b51474aa0efe695 (patch)
tree1c4e90f4f0288e3f4ea573fee2edf609e7e1581e
parent7896ad6f6ed4c559509dd27eb7e62aa330a70a2c (diff)
downloadtracker-fbbf5a41b1606fed73d1e7a14b51474aa0efe695.tar.gz
tests: Avoid invalid calls to g_source_remove().
GLib now warns if removing a source that no longer exists. This was causing intermittent failure of tracker-file-notifier-test If the test timeout executed before the test's main loop exited, the following error would occur: GLib-CRITICAL **: Source ID 130 was not found when attempting to remove it The functional tests have also been fixed.
-rw-r--r--tests/functional-tests/common/utils/helpers.py9
-rw-r--r--tests/libtracker-miner/tracker-file-notifier-test.c5
2 files changed, 10 insertions, 4 deletions
diff --git a/tests/functional-tests/common/utils/helpers.py b/tests/functional-tests/common/utils/helpers.py
index d0b1a8177..2f3f0a414 100644
--- a/tests/functional-tests/common/utils/helpers.py
+++ b/tests/functional-tests/common/utils/helpers.py
@@ -124,6 +124,7 @@ class Helper:
def _timeout_on_idle_cb (self):
log ("[%s] Timeout waiting... asumming idle." % self.PROCESS_NAME)
self.loop.quit ()
+ self.timeout_id = None
return False
@@ -157,6 +158,8 @@ class Helper:
glib.idle_add (self._stop_process)
self.timeout_id = glib.timeout_add_seconds (REASONABLE_TIMEOUT, self._timeout_on_idle_cb)
self.loop.run ()
+ if self.timeout_id is not None:
+ glib.source_remove(self.timeout_id)
log ("[%s] stop." % self.PROCESS_NAME)
# Disconnect the signals of the next start we get duplicated messages
@@ -342,7 +345,8 @@ class MinerFsHelper (Helper):
# It should step out of this loop after progress changes to "Idle"
self.timeout_id = glib.timeout_add_seconds (REASONABLE_TIMEOUT, self._timeout_on_idle_cb)
self.loop.run ()
- glib.source_remove (self.timeout_id)
+ if self.timeout_id is not None:
+ glib.source_remove (self.timeout_id)
bus_object = self.bus.get_object (cfg.MINERFS_BUSNAME,
cfg.MINERFS_OBJ_PATH)
@@ -370,7 +374,8 @@ class MinerFsHelper (Helper):
self.loop.run ()
- glib.source_remove (self.timeout_id)
+ if self.timeout_id is not None:
+ glib.source_remove (self.timeout_id)
self.bus._clean_up_signal_match (self.status_match)
diff --git a/tests/libtracker-miner/tracker-file-notifier-test.c b/tests/libtracker-miner/tracker-file-notifier-test.c
index 5c65febdf..88922e497 100644
--- a/tests/libtracker-miner/tracker-file-notifier-test.c
+++ b/tests/libtracker-miner/tracker-file-notifier-test.c
@@ -349,12 +349,13 @@ test_common_context_expect_results (TestCommonContext *fixture,
id = g_timeout_add_seconds (max_timeout,
(GSourceFunc) timeout_expired_cb,
fixture);
+ fixture->expire_timeout_id = id;
}
g_main_loop_run (fixture->main_loop);
- if (max_timeout != 0) {
- g_source_remove (id);
+ if (max_timeout != 0 && fixture->expire_timeout_id != 0) {
+ g_source_remove (fixture->expire_timeout_id);
}
}