[next] telepathy-glib: logger tests: fix some leaks

Simon McVittie smcv at kemper.freedesktop.org
Tue Mar 18 07:03:27 PDT 2014


Module: telepathy-glib
Branch: next
Commit: 623ac2c0b4112c6a5873d9be23f93e64a163e3dd
URL:    http://cgit.freedesktop.org/telepathy/telepathy-glib/commit/?id=623ac2c0b4112c6a5873d9be23f93e64a163e3dd

Author: Simon McVittie <simon.mcvittie at collabora.co.uk>
Date:   Tue Mar 18 13:13:17 2014 +0000

logger tests: fix some leaks

Reviewed-by: Guillaume Desmottes

---

 tests/lib/logger-test-helper.c                |    2 +-
 tests/logger/dbus/test-log-manager.c          |    6 +++++-
 tests/logger/dbus/test-tpl-log-iter-xml.c     |    1 +
 tests/logger/dbus/test-tpl-log-store-pidgin.c |   24 +++++++++++++++---------
 tests/logger/dbus/test-tpl-log-store-xml.c    |    2 ++
 tests/logger/dbus/test-tpl-log-walker.c       |    6 ++++++
 6 files changed, 30 insertions(+), 11 deletions(-)

diff --git a/tests/lib/logger-test-helper.c b/tests/lib/logger-test-helper.c
index fd20baf..0468a90 100644
--- a/tests/lib/logger-test-helper.c
+++ b/tests/lib/logger-test-helper.c
@@ -52,7 +52,7 @@ tpl_test_create_and_prepare_account (TpDBusDaemon *dbus,
   g_array_append_val (features, zero);
 
   tp_tests_proxy_run_until_prepared (*account, (GQuark *) features->data);
-  g_array_free (features, FALSE);
+  g_array_unref (features);
 }
 
 void
diff --git a/tests/logger/dbus/test-log-manager.c b/tests/logger/dbus/test-log-manager.c
index 76455e5..ae14a53 100644
--- a/tests/logger/dbus/test-log-manager.c
+++ b/tests/logger/dbus/test-log-manager.c
@@ -137,6 +137,7 @@ teardown (TestCaseFixture* fixture,
                   fixture->tmp_basedir);
 
       g_free (fixture->tmp_basedir);
+      g_free (command);
     }
 
   g_object_unref (fixture->manager);
@@ -620,6 +621,8 @@ check_ignored_messages (TestCaseFixture *fixture,
       g_object_get (G_OBJECT (found_event), "message-token", &result_token, NULL);
       g_object_get (G_OBJECT (event), "message-token", &ref_token, NULL);
       exists = (g_strcmp0 (result_token, ref_token) == 0);
+      g_free (ref_token);
+      g_free (result_token);
 
       if (should_exist != exists) {
         g_list_free_full (fixture->ret, g_object_unref);
@@ -628,6 +631,7 @@ check_ignored_messages (TestCaseFixture *fixture,
   }
 
   g_list_free_full (fixture->ret, g_object_unref);
+  g_date_free (date);
 
   return TRUE;
 }
@@ -802,7 +806,7 @@ main (int argc, char **argv)
 
   retval = tp_tests_run_with_bus ();
 
-  g_list_foreach (l, (GFunc) g_hash_table_unref, NULL);
+  g_list_free_full (l, (GDestroyNotify) g_hash_table_unref);
 
   g_test_dbus_down (test_dbus);
   g_clear_object (&test_dbus);
diff --git a/tests/logger/dbus/test-tpl-log-iter-xml.c b/tests/logger/dbus/test-tpl-log-iter-xml.c
index 4ffd3fe..1204fc1 100644
--- a/tests/logger/dbus/test-tpl-log-iter-xml.c
+++ b/tests/logger/dbus/test-tpl-log-iter-xml.c
@@ -78,6 +78,7 @@ teardown (XmlTestCaseFixture *fixture,
   g_clear_object (&fixture->factory);
   g_clear_object (&fixture->bus);
   g_clear_object (&fixture->store);
+  g_main_loop_unref (fixture->main_loop);
 }
 
 
diff --git a/tests/logger/dbus/test-tpl-log-store-pidgin.c b/tests/logger/dbus/test-tpl-log-store-pidgin.c
index c4bb7fd..5727f01 100644
--- a/tests/logger/dbus/test-tpl-log-store-pidgin.c
+++ b/tests/logger/dbus/test-tpl-log-store-pidgin.c
@@ -272,6 +272,7 @@ test_get_dates_jabber (PidginTestCaseFixture *fixture,
 {
   GList *dates = NULL;
   GDate *date = NULL;
+  GDate *ref_date;
 
   /* Chatroom messages */
   dates = log_store_pidgin_get_dates (TPL_LOG_STORE (fixture->store),
@@ -280,14 +281,16 @@ test_get_dates_jabber (PidginTestCaseFixture *fixture,
   g_assert_cmpint (g_list_length (dates), ==, 2);
 
   date = g_list_nth_data (dates, 0);
-  g_assert_cmpint (0, ==,
-      g_date_compare (date, g_date_new_dmy (12, G_DATE_APRIL, 2010)));
+  ref_date = g_date_new_dmy (12, G_DATE_APRIL, 2010);
+  g_assert_cmpint (0, ==, g_date_compare (date, ref_date));
+  g_date_free (ref_date);
 
   g_date_free (date);
 
   date = g_list_nth_data (dates, 1);
-  g_assert_cmpint (0, ==,
-      g_date_compare (date, g_date_new_dmy (29, G_DATE_APRIL, 2010)));
+  ref_date = g_date_new_dmy (29, G_DATE_APRIL, 2010);
+  g_assert_cmpint (0, ==, g_date_compare (date, ref_date));
+  g_date_free (ref_date);
 
   g_date_free (date);
   g_list_free (dates);
@@ -299,8 +302,9 @@ test_get_dates_jabber (PidginTestCaseFixture *fixture,
   g_assert_cmpint (g_list_length (dates), ==, 1);
 
   date = g_list_nth_data (dates, 0);
-  g_assert_cmpint (0, ==,
-      g_date_compare (date, g_date_new_dmy (10, G_DATE_DECEMBER, 2010)));
+  ref_date = g_date_new_dmy (10, G_DATE_DECEMBER, 2010);
+  g_assert_cmpint (0, ==, g_date_compare (date, ref_date));
+  g_date_free (ref_date);
 
   g_date_free (date);
   g_list_free (dates);
@@ -312,6 +316,7 @@ test_get_dates_irc (PidginTestCaseFixture *fixture,
 {
   GList *dates = NULL;
   GDate *date = NULL;
+  GDate *ref_date;
 
   dates = log_store_pidgin_get_dates (TPL_LOG_STORE (fixture->store),
       fixture->account,
@@ -321,8 +326,9 @@ test_get_dates_irc (PidginTestCaseFixture *fixture,
   g_assert_cmpint (g_list_length (dates), ==, 1);
 
   date = g_list_nth_data (dates, 0);
-  g_assert_cmpint (0, ==,
-      g_date_compare (date, g_date_new_dmy (30, G_DATE_NOVEMBER, 2010)));
+  ref_date = g_date_new_dmy (30, G_DATE_NOVEMBER, 2010);
+  g_assert_cmpint (0, ==, g_date_compare (date, ref_date));
+  g_date_free (ref_date);
 
   g_list_foreach (dates, (GFunc) g_date_free, NULL);
   g_list_free (dates);
@@ -617,7 +623,7 @@ main (int argc, char **argv)
 
   retval = g_test_run ();
 
-  g_list_foreach (l, (GFunc) g_hash_table_unref, NULL);
+  g_list_free_full (l, (GDestroyNotify) g_hash_table_unref);
 
   g_test_dbus_down (test_dbus);
   g_clear_object (&test_dbus);
diff --git a/tests/logger/dbus/test-tpl-log-store-xml.c b/tests/logger/dbus/test-tpl-log-store-xml.c
index ed5f845..4906f00 100644
--- a/tests/logger/dbus/test-tpl-log-store-xml.c
+++ b/tests/logger/dbus/test-tpl-log-store-xml.c
@@ -101,12 +101,14 @@ teardown (XmlTestCaseFixture *fixture,
                   fixture->tmp_basedir);
 
       g_free (fixture->tmp_basedir);
+      g_free (command);
     }
 
   if (fixture->store == NULL)
     g_object_unref (fixture->store);
 
   g_clear_object (&fixture->factory);
+  g_main_loop_unref (fixture->main_loop);
 }
 
 
diff --git a/tests/logger/dbus/test-tpl-log-walker.c b/tests/logger/dbus/test-tpl-log-walker.c
index 496539d..6035ff7 100644
--- a/tests/logger/dbus/test-tpl-log-walker.c
+++ b/tests/logger/dbus/test-tpl-log-walker.c
@@ -269,6 +269,8 @@ test_get_events (WalkerTestCaseFixture *fixture,
       NULL);
 
   get_events (fixture, walker, 0);
+  g_list_free_full (fixture->events, g_object_unref);
+  fixture->events = NULL;
   test_get_events_text (fixture, walker, 2, 1263427264, "L''");
   test_get_events_text (fixture, walker, 5, 1263427262, "J");
   test_get_events_text (fixture, walker, 1, 1263427261, "I'''");
@@ -278,12 +280,16 @@ test_get_events (WalkerTestCaseFixture *fixture,
   test_get_events_text (fixture, walker, 4, 1263254401, "5''");
   test_get_events_text (fixture, walker, 2, 1263254401, "5");
   get_events (fixture, walker, 0);
+  g_list_free_full (fixture->events, g_object_unref);
+  fixture->events = NULL;
   test_get_events_text (fixture, walker, 3, 1263168066, "H'");
   test_get_events_text (fixture, walker, 3, 1263168065, "G''");
   test_get_events_text (fixture, walker, 6, 1263168063, "E");
   test_get_events_text (fixture, walker, 1, 1263168062, "D''");
   test_get_events_text (fixture, walker, 2, 1263168062, "D");
   get_events (fixture, walker, 0);
+  g_list_free_full (fixture->events, g_object_unref);
+  fixture->events = NULL;
   test_get_events_text (fixture, walker, 4, 1263168005, "4");
   test_get_events_text (fixture, walker, 2, 1263168003, "2");
   test_get_events_text (fixture, walker, 4, 1263081661, "A");



More information about the telepathy-commits mailing list