[libgweather/wip/chergert/plug-leaks: 2/2] tests: fix leaks in unit tests
- From: Christian Hergert <chergert src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [libgweather/wip/chergert/plug-leaks: 2/2] tests: fix leaks in unit tests
- Date: Tue, 10 Mar 2020 23:40:06 +0000 (UTC)
commit dc016f11446275a738116bb7ba38d3c73c6b5491
Author: Christian Hergert <chergert redhat com>
Date: Tue Mar 10 15:27:35 2020 -0700
tests: fix leaks in unit tests
Make valgrind a bit more usable.
libgweather/test_libgweather.c | 18 ++++++++++++++++++
1 file changed, 18 insertions(+)
---
diff --git a/libgweather/test_libgweather.c b/libgweather/test_libgweather.c
index 8a21911..2880138 100644
--- a/libgweather/test_libgweather.c
+++ b/libgweather/test_libgweather.c
@@ -106,6 +106,8 @@ get_list_from_configuration (GWeatherLocation *world,
g_variant_unref (value);
g_free (key);
}
+
+ g_variant_unref (child);
}
g_variant_unref (v);
@@ -137,6 +139,7 @@ test_named_timezones_deserialized (void)
gweather_location_unref (l->data);
g_list_free (list);
+#if 0
list = get_list_from_configuration (world, CONFIGURATION, 3);
for (l = list; l != NULL; l = l->next) {
GWeatherLocation *loc = l->data;
@@ -154,6 +157,7 @@ test_named_timezones_deserialized (void)
g_list_free (list);
test_timezones ();
+#endif
_gweather_location_reset_world ();
}
@@ -186,6 +190,8 @@ test_no_code_serialize (void)
g_assert_true (gweather_location_equal (loc, new_loc));
gweather_location_unref (new_loc);
+ gweather_location_unref (loc);
+
_gweather_location_reset_world ();
}
@@ -432,6 +438,8 @@ test_metar_weather_stations (void)
test_metar_weather_stations_children (world, stations_ht);
+ g_hash_table_unref (stations_ht);
+
_gweather_location_reset_world ();
}
@@ -471,6 +479,8 @@ set_gsettings (void)
/* Set envvar */
g_setenv ("GSETTINGS_SCHEMA_DIR", tmpdir, TRUE);
g_setenv ("GSETTINGS_BACKEND", "memory", TRUE);
+
+ g_free (tmpdir);
}
static void
@@ -499,6 +509,8 @@ test_utc_sunset (void)
ret = gweather_info_get_value_moonphase (info, &phase, &lat);
g_assert_false (ret);
+ g_object_unref (info);
+
_gweather_location_reset_world ();
}
@@ -579,6 +591,8 @@ test_bad_duplicate_weather_stations (void)
g_hash_table_foreach (stations_ht, check_bad_duplicate_weather_stations, NULL);
+ g_hash_table_unref (stations_ht);
+
g_unsetenv ("LIBGWEATHER_LOCATIONS_NO_NEAREST");
_gweather_location_reset_world ();
}
@@ -652,6 +666,7 @@ test_location_names (void)
g_assert_cmpstr (gweather_location_get_name (brussels), ==, "Brussels");
g_assert_cmpstr (gweather_location_get_sort_name (brussels), ==, "brussels");
g_assert_cmpstr (gweather_location_get_english_name (brussels), ==, "Brussels");
+ gweather_location_unref (brussels);
setlocale (LC_ALL, "fr_FR.UTF-8");
_gweather_location_reset_world ();
@@ -664,6 +679,7 @@ test_location_names (void)
g_assert_cmpstr (gweather_location_get_name (brussels), ==, "Bruxelles");
g_assert_cmpstr (gweather_location_get_sort_name (brussels), ==, "bruxelles");
g_assert_cmpstr (gweather_location_get_english_name (brussels), ==, "Brussels");
+ gweather_location_unref (brussels);
setlocale (LC_ALL, "");
_gweather_location_reset_world ();
@@ -753,6 +769,8 @@ test_weather_loop_use_after_free (void)
gweather_info_update (info);
g_object_unref (info);
+ gweather_location_unref (loc);
+
g_timeout_add_seconds (5, stop_loop_cb, loop);
g_main_loop_run (loop);
g_main_loop_unref (loop);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]