[tracker] tests: Avoid invalid calls to g_source_remove().



commit fbbf5a41b1606fed73d1e7a14b51474aa0efe695
Author: Sam Thursfield <sam thursfield codethink co uk>
Date:   Mon Nov 25 14:42:13 2013 +0000

    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.

 tests/functional-tests/common/utils/helpers.py     |    9 +++++++--
 .../libtracker-miner/tracker-file-notifier-test.c  |    5 +++--
 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 d0b1a81..2f3f0a4 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 5c65feb..88922e4 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);
                }
        }
 


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]