[glib/wip/gcleanup] tests/gobject: Run cleanup correctly during tests



commit 9f31c790f476d64e810a48db190b4ff8f307102c
Author: Stef Walter <stefw gnome org>
Date:   Fri Nov 8 22:45:49 2013 +0100

    tests/gobject: Run cleanup correctly during tests

 tests/gobject/Makefile.am    |    2 +-
 tests/gobject/accumulator.c  |    2 ++
 tests/gobject/defaultiface.c |    5 ++++-
 tests/gobject/dynamictype.c  |    5 ++++-
 tests/gobject/override.c     |    4 +++-
 tests/gobject/signals.c      |    2 ++
 tests/gobject/testcommon.h   |    2 ++
 tests/gobject/testmodule.c   |    2 ++
 8 files changed, 20 insertions(+), 4 deletions(-)
---
diff --git a/tests/gobject/Makefile.am b/tests/gobject/Makefile.am
index 84f7410..1cfce4b 100644
--- a/tests/gobject/Makefile.am
+++ b/tests/gobject/Makefile.am
@@ -2,7 +2,7 @@ include $(top_srcdir)/glib.mk
 
 LDADD = $(top_builddir)/glib/libglib-2.0.la $(top_builddir)/gobject/libgobject-2.0.la
 AM_CPPFLAGS = $(gmodule_INCLUDES) $(GLIB_DEBUG_FLAGS)
-DEFS = -DGLIB_DISABLE_DEPRECATION_WARNINGS -DG_LOG_DOMAIN=\"GLib\"
+DEFS = -DGLIB_DISABLE_DEPRECATION_WARNINGS -DG_LOG_DOMAIN=\"GLib\" -DG_CLEANUP_MODULE=test
 AM_CFLAGS = -g
 
 # So far, only two gtester-ified cases
diff --git a/tests/gobject/accumulator.c b/tests/gobject/accumulator.c
index f994a76..0f1b1d2 100644
--- a/tests/gobject/accumulator.c
+++ b/tests/gobject/accumulator.c
@@ -249,6 +249,8 @@ static DEFINE_TYPE(TestObject, test_object,
                   test_object_class_init, NULL, NULL,
                   G_TYPE_OBJECT)
 
+G_CLEANUP_DEFINE
+
 int
 main (int   argc,
       char *argv[])
diff --git a/tests/gobject/defaultiface.c b/tests/gobject/defaultiface.c
index c44c18a..12944b0 100644
--- a/tests/gobject/defaultiface.c
+++ b/tests/gobject/defaultiface.c
@@ -141,8 +141,9 @@ static void
 test_dynamic_iface (void)
 {
   TestDynamicIfaceClass *dynamic_iface;
+  GTypeModule *module;
 
-  test_module_new (module_register);
+  module = test_module_new (module_register);
 
   /* Not loaded until we call ref for the first time */
   dynamic_iface = g_type_default_interface_peek (TEST_TYPE_DYNAMIC_IFACE);
@@ -179,6 +180,8 @@ test_dynamic_iface (void)
 #if 0
   g_assert (!dynamic_iface_init);
 #endif
+
+  g_object_unref (module);
 }
 
 int
diff --git a/tests/gobject/dynamictype.c b/tests/gobject/dynamictype.c
index b527608..38dd271 100644
--- a/tests/gobject/dynamictype.c
+++ b/tests/gobject/dynamictype.c
@@ -113,8 +113,9 @@ static void
 test_dynamic_type (void)
 {
   DynamicObjectClass *class;
+  GTypeModule *module;
 
-  test_module_new (module_register);
+  module = test_module_new (module_register);
 
   /* Not loaded until we call ref for the first time */
   class = g_type_class_peek (DYNAMIC_OBJECT_TYPE);
@@ -161,6 +162,8 @@ test_dynamic_type (void)
   g_assert (!class);
   g_assert (!loaded);
 #endif
+
+  g_object_unref (module);
 }
 
 int
diff --git a/tests/gobject/override.c b/tests/gobject/override.c
index 47702d7..340c473 100644
--- a/tests/gobject/override.c
+++ b/tests/gobject/override.c
@@ -396,7 +396,9 @@ test (GType        type,
   g_string_free (test_string, TRUE);
   g_object_unref (self);
 }
-     
+
+G_CLEANUP_DEFINE
+
 int
 main (int argc, char **argv)
 {
diff --git a/tests/gobject/signals.c b/tests/gobject/signals.c
index ad1f876..9dc4d56 100644
--- a/tests/gobject/signals.c
+++ b/tests/gobject/signals.c
@@ -108,6 +108,8 @@ static DEFINE_TYPE(TestObject, test_object,
                    test_object_class_init, NULL, NULL,
                    G_TYPE_OBJECT)
 
+G_CLEANUP_DEFINE
+
 int
 main (int   argc,
       char *argv[])
diff --git a/tests/gobject/testcommon.h b/tests/gobject/testcommon.h
index 6c377e4..aa645fc 100644
--- a/tests/gobject/testcommon.h
+++ b/tests/gobject/testcommon.h
@@ -48,6 +48,7 @@ prefix ## _get_type (void)                                    \
       object_type = g_type_register_static (parent_type,       \
                                            # name,             \
                                            &object_info, 0);   \
+      g_type_cleanup_push (G_CLEANUP_LOCAL, object_type);       \
       interface_decl                                           \
     }                                                          \
                                                                \
@@ -79,6 +80,7 @@ prefix ## _get_type (void)                                    \
       iface_type = g_type_register_static (G_TYPE_INTERFACE,   \
                                            # name,             \
                                            &iface_info, 0);    \
+      g_type_cleanup_push (G_CLEANUP_LOCAL, iface_type);        \
     }                                                          \
   return iface_type;                                           \
 }
diff --git a/tests/gobject/testmodule.c b/tests/gobject/testmodule.c
index a6159f1..21df603 100644
--- a/tests/gobject/testmodule.c
+++ b/tests/gobject/testmodule.c
@@ -21,6 +21,8 @@
 #include "testmodule.h"
 #include "testcommon.h"
 
+G_CLEANUP_DEFINE
+
 static gboolean test_module_load   (GTypeModule *module);
 static void     test_module_unload (GTypeModule *module);
 


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