[glib/wip/gsubprocess-ostreams: 3/9] tests: add check for leaking signal return value



commit 3d0113e52fa02d37170a8760349aa9f7f12c8ea3
Author: Mark Nauwelaerts <mark nauwelaerts collabora co uk>
Date:   Thu Jul 19 16:38:59 2012 +0200

    tests: add check for leaking signal return value
    
    https://bugzilla.gnome.org/show_bug.cgi?id=674800

 tests/refcount/Makefile.am |    5 ++++-
 tests/refcount/signals.c   |   26 ++++++++++++++++++++++++++
 2 files changed, 30 insertions(+), 1 deletions(-)
---
diff --git a/tests/refcount/Makefile.am b/tests/refcount/Makefile.am
index 49a5dc2..3a7f8f5 100644
--- a/tests/refcount/Makefile.am
+++ b/tests/refcount/Makefile.am
@@ -21,7 +21,8 @@ test_programs = 				\
 	properties4				\
 	signal1					\
 	signal2					\
-	signal3
+	signal3					\
+	signal4
 
 
 
@@ -31,6 +32,8 @@ signal2_SOURCES = signals.c
 signal2_CFLAGS = -DTESTNUM=2 $(AM_CFLAGS)
 signal3_SOURCES = signals.c
 signal3_CFLAGS = -DTESTNUM=3 $(AM_CFLAGS)
+signal4_SOURCES = signals.c
+signal4_CFLAGS = -DTESTNUM=4 $(AM_CFLAGS)
 
 check_PROGRAMS = $(test_programs)
 
diff --git a/tests/refcount/signals.c b/tests/refcount/signals.c
index 1bf2128..066d065 100644
--- a/tests/refcount/signals.c
+++ b/tests/refcount/signals.c
@@ -27,6 +27,7 @@ struct _GTestClass
 
   void (*test_signal1) (GTest * test, gint an_int);
   void (*test_signal2) (GTest * test, gint an_int);
+  gchar * (*test_signal3) (GTest * test, gint an_int);
 };
 
 static GType my_test_get_type (void);
@@ -37,6 +38,7 @@ enum
 {
   TEST_SIGNAL1,
   TEST_SIGNAL2,
+  TEST_SIGNAL3,
   /* add more above */
   LAST_SIGNAL
 };
@@ -52,6 +54,7 @@ static void my_test_init (GTest * test);
 static void my_test_dispose (GObject * object);
 
 static void signal2_handler (GTest * test, gint anint);
+static gchar * signal3_handler (GTest * test, gint anint);
 
 static void my_test_set_property (GObject * object, guint prop_id,
     const GValue * value, GParamSpec * pspec);
@@ -110,12 +113,17 @@ my_test_class_init (GTestClass * klass)
       g_signal_new ("test-signal2", G_TYPE_FROM_CLASS (klass),
       G_SIGNAL_RUN_LAST, G_STRUCT_OFFSET (GTestClass, test_signal2), NULL,
       NULL, g_cclosure_marshal_VOID__INT, G_TYPE_NONE, 1, G_TYPE_INT);
+  my_test_signals[TEST_SIGNAL3] =
+      g_signal_new ("test-signal3", G_TYPE_FROM_CLASS (klass),
+      G_SIGNAL_RUN_LAST, G_STRUCT_OFFSET (GTestClass, test_signal3), NULL,
+      NULL, g_cclosure_marshal_generic, G_TYPE_STRING, 1, G_TYPE_INT);
 
   g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_TEST_PROP,
       g_param_spec_int ("test-prop", "Test Prop", "Test property",
           0, 1, 0, G_PARAM_READWRITE));
 
   klass->test_signal2 = signal2_handler;
+  klass->test_signal3 = signal3_handler;
 }
 
 static void
@@ -191,6 +199,22 @@ my_test_do_signal2 (GTest * test)
   g_signal_emit (G_OBJECT (test), my_test_signals[TEST_SIGNAL2], 0, 0);
 }
 
+static gchar *
+signal3_handler (GTest * test, gint anint)
+{
+  return g_strdup ("test");
+}
+
+static void
+my_test_do_signal3 (GTest * test)
+{
+  gchar *res;
+
+  g_signal_emit (G_OBJECT (test), my_test_signals[TEST_SIGNAL3], 0, 0, &res);
+  g_assert (res);
+  g_free (res);
+}
+
 static void
 my_test_do_prop (GTest * test)
 {
@@ -210,6 +234,8 @@ run_thread (GTest * test)
       my_test_do_signal2 (test);
     if (TESTNUM == 3)
       my_test_do_prop (test);
+    if (TESTNUM == 4)
+      my_test_do_signal3 (test);
     if ((i++ % 10000) == 0) {
       g_print (".");
       g_thread_yield(); /* force context switch */



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