tests/check/gst/gstghostpad.c: add more asserts on refcounts do more cleanup at end...
authorThomas Vander Stichele <thomas@apestaart.org>
Sat, 29 Apr 2006 00:33:44 +0000 (00:33 +0000)
committerThomas Vander Stichele <thomas@apestaart.org>
Sat, 29 Apr 2006 00:33:44 +0000 (00:33 +0000)
Original commit message from CVS:
2006-04-29  Thomas Vander Stichele  <thomas at apestaart dot org>

* tests/check/gst/gstghostpad.c: (GST_START_TEST):
add more asserts on refcounts
do more cleanup at end of tests
fix test leaks showing in FC5

ChangeLog
tests/check/gst/gstghostpad.c

index 14534a6..215604e 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+2006-04-29  Thomas Vander Stichele  <thomas at apestaart dot org>
+
+       * tests/check/gst/gstghostpad.c: (GST_START_TEST):
+         add more asserts on refcounts
+         do more cleanup at end of tests
+         fix test leaks showing in FC5
+
 2006-04-29  Stefan Kost  <ensonic@users.sf.net>
 
        * plugins/elements/gsttypefindelement.c:
@@ -8,8 +15,8 @@
 2006-04-28  Stefan Kost  <ensonic@users.sf.net>
 
        * libs/gst/base/gstcollectpads.c: (gst_collect_pads_event):
-        fix changelog entry about last collectpads change,
-        add notes about proper fix
+         fix changelog entry about last collectpads change,
+         add notes about proper fix
 
 2006-04-28  Stefan Kost  <ensonic@users.sf.net>
 
@@ -17,7 +24,7 @@
        * gst/gstregistry.c: (gst_registry_scan_path_level),
        (gst_registry_scan_path):
        * gst/gstregistry.h:
-        only write out registry if it has changed, fixes #338339
+         only write out registry if it has changed, fixes #338339
 
 2006-04-28  Stefan Kost  <ensonic@users.sf.net>
 
        * plugins/elements/gsttee.c:
        * plugins/elements/gsttypefindelement.c:
        (gst_type_find_element_handle_event):
-         make GstElementDetails const
+         make GstElementDetails const
 
 2006-04-28  Stefan Kost  <ensonic@users.sf.net>
 
        * libs/gst/base/gstbasesink.c: (gst_base_sink_event):
        * libs/gst/base/gstcollectpads.c: (gst_collect_pads_base_init),
        (gst_collect_pads_is_collected), (gst_collect_pads_event):
-        more detailed debug and formatting cleanup,
-        forward newsegments to src-pad (so that e.g. adder not eats them)
+         more detailed debug and formatting cleanup,
+         forward newsegments to src-pad (so that e.g. adder not eats them)
 
 2006-04-28  Stefan Kost  <ensonic@users.sf.net>
 
        * gst/gstutils.c: (gst_element_link_pads):
-        cleanup double code
+         cleanup double code
 
 2006-04-28  Stefan Kost  <ensonic@users.sf.net>
 
        * libs/gst/controller/gstcontroller.c:
        (gst_controller_sync_values):
-          some little tuning
+         some little tuning
        * tests/check/libs/controller.c: (GST_START_TEST),
        (gst_controller_suite):
-          a new test for live value handling
+         a new test for live value handling
 
 2006-04-28  Wim Taymans  <wim@fluendo.com>
 
index e13fa41..e5a1e65 100644 (file)
@@ -33,10 +33,17 @@ GST_START_TEST (test_remove1)
   b2 = gst_element_factory_make ("bin", NULL);
   src = gst_element_factory_make ("fakesrc", NULL);
   sink = gst_element_factory_make ("fakesink", NULL);
+  ASSERT_OBJECT_REFCOUNT (b1, "pipeline", 1);
+  ASSERT_OBJECT_REFCOUNT (b2, "bin", 1);
 
   fail_unless (gst_bin_add (GST_BIN (b2), sink));
   fail_unless (gst_bin_add (GST_BIN (b1), src));
+  ASSERT_OBJECT_REFCOUNT (b1, "pipeline", 1);
+  ASSERT_OBJECT_REFCOUNT (b2, "bin", 1);
   fail_unless (gst_bin_add (GST_BIN (b1), b2));
+  /* adding the bin creates a clock provide message with a ref to pipeline */
+  ASSERT_OBJECT_REFCOUNT (b1, "pipeline", 2);
+  ASSERT_OBJECT_REFCOUNT (b2, "bin", 1);
 
   sinkpad = gst_element_get_pad (sink, "sink");
   gst_element_add_pad (b2, gst_ghost_pad_new ("sink", sinkpad));
@@ -51,8 +58,9 @@ GST_START_TEST (test_remove1)
   gst_object_unref (srcpad);
   gst_object_unref (sinkpad);
 
-  /* now remove the bin with the ghostpad, b2 is disposed
-   * now. */
+  /* now remove the bin with the ghostpad, b2 is disposed now. */
+  ASSERT_OBJECT_REFCOUNT (b1, "pipeline", 2);
+  ASSERT_OBJECT_REFCOUNT (b2, "bin", 1);
   gst_bin_remove (GST_BIN (b1), b2);
 
   srcpad = gst_element_get_pad (src, "src");
@@ -60,6 +68,10 @@ GST_START_TEST (test_remove1)
   fail_if (gst_pad_is_linked (srcpad));
   gst_object_unref (srcpad);
 
+  /* flush the message, dropping the b1 refcount to 1 */
+  gst_element_set_state (b1, GST_STATE_READY);
+  gst_element_set_state (b1, GST_STATE_NULL);
+  ASSERT_OBJECT_REFCOUNT (b1, "pipeline", 1);
   gst_object_unref (b1);
 }
 
@@ -77,21 +89,31 @@ GST_START_TEST (test_remove2)
   b2 = gst_element_factory_make ("bin", NULL);
   src = gst_element_factory_make ("fakesrc", NULL);
   sink = gst_element_factory_make ("fakesink", NULL);
+  ASSERT_OBJECT_REFCOUNT (src, "src", 1);
 
   fail_unless (gst_bin_add (GST_BIN (b2), sink));
   fail_unless (gst_bin_add (GST_BIN (b1), src));
   fail_unless (gst_bin_add (GST_BIN (b1), b2));
+  ASSERT_OBJECT_REFCOUNT (src, "src", 1);
 
   sinkpad = gst_element_get_pad (sink, "sink");
   gst_element_add_pad (b2, gst_ghost_pad_new ("sink", sinkpad));
   gst_object_unref (sinkpad);
 
   srcpad = gst_element_get_pad (src, "src");
+  ASSERT_OBJECT_REFCOUNT (srcpad, "srcpad", 2); /* since we got one */
   /* get the ghostpad */
   sinkpad = gst_element_get_pad (b2, "sink");
+  ASSERT_OBJECT_REFCOUNT (sinkpad, "sinkpad", 2);       /* since we got one */
 
+  GST_DEBUG ("linking srcpad and sinkpad");
   ret = gst_pad_link (srcpad, sinkpad);
+  GST_DEBUG ("linked srcpad and sinkpad");
   fail_unless (ret == GST_PAD_LINK_OK);
+  /* the linking causes a proxypad to be created for srcpad,
+   * to which sinkpad gets linked.  This proxypad has a ref to srcpad */
+  ASSERT_OBJECT_REFCOUNT (srcpad, "srcpad", 3);
+  ASSERT_OBJECT_REFCOUNT (sinkpad, "sinkpad", 2);
   gst_object_unref (srcpad);
   gst_object_unref (sinkpad);
 
@@ -101,6 +123,27 @@ GST_START_TEST (test_remove2)
   srcpad = gst_element_get_pad (src, "src");
   /* pad is still linked to ghostpad */
   fail_if (!gst_pad_is_linked (srcpad));
+  ASSERT_OBJECT_REFCOUNT (src, "src", 1);
+  ASSERT_OBJECT_REFCOUNT (srcpad, "srcpad", 3);
+  gst_object_unref (srcpad);
+  ASSERT_OBJECT_REFCOUNT (sinkpad, "sinkpad", 1);
+
+  /* cleanup */
+  /* now unlink the pads */
+  gst_pad_unlink (srcpad, sinkpad);
+  ASSERT_OBJECT_REFCOUNT (srcpad, "srcpad", 1); /* proxy has dropped ref */
+  ASSERT_OBJECT_REFCOUNT (sinkpad, "sinkpad", 1);
+
+  ASSERT_OBJECT_REFCOUNT (src, "src", 1);
+  ASSERT_OBJECT_REFCOUNT (b2, "bin", 1);
+  /* remove b2 from b1 */
+  gst_bin_remove (GST_BIN (b1), b2);
+
+  /* flush the message, dropping the b1 refcount to 1 */
+  gst_element_set_state (b1, GST_STATE_READY);
+  gst_element_set_state (b1, GST_STATE_NULL);
+  ASSERT_OBJECT_REFCOUNT (b1, "pipeline", 1);
+  gst_object_unref (b1);
 }
 
 GST_END_TEST;
@@ -177,6 +220,11 @@ GST_START_TEST (test_link)
   /* and linking should work now */
   ret = gst_pad_link (srcpad, sinkpad);
   fail_unless (ret == GST_PAD_LINK_OK);
+
+  /* flush the message, dropping the b1 refcount to 1 */
+  gst_element_set_state (b1, GST_STATE_READY);
+  gst_element_set_state (b1, GST_STATE_NULL);
+  ASSERT_OBJECT_REFCOUNT (b1, "pipeline", 1);
 }
 
 GST_END_TEST;
@@ -301,12 +349,15 @@ GST_START_TEST (test_ghost_pads_bin)
   GstPad *sinkghost;
 
   pipeline = GST_BIN (gst_pipeline_new ("pipe"));
+  ASSERT_OBJECT_REFCOUNT (pipeline, "pipeline", 1);
 
   srcbin = GST_BIN (gst_bin_new ("srcbin"));
   gst_bin_add (pipeline, GST_ELEMENT (srcbin));
+  ASSERT_OBJECT_REFCOUNT (pipeline, "pipeline", 2);     /* provide-clock msg */
 
   sinkbin = GST_BIN (gst_bin_new ("sinkbin"));
   gst_bin_add (pipeline, GST_ELEMENT (sinkbin));
+  ASSERT_OBJECT_REFCOUNT (pipeline, "pipeline", 3);     /* provide-clock msg */
 
   src = gst_element_factory_make ("fakesrc", "src");
   gst_bin_add (srcbin, src);
@@ -326,6 +377,11 @@ GST_START_TEST (test_ghost_pads_bin)
               (srcghost))) != NULL);
   fail_unless (GST_PAD_PEER (gst_ghost_pad_get_target (GST_GHOST_PAD
               (sinkghost))) != NULL);
+
+  /* flush the message, dropping the b1 refcount to 1 */
+  gst_element_set_state (GST_ELEMENT (pipeline), GST_STATE_READY);
+  gst_element_set_state (GST_ELEMENT (pipeline), GST_STATE_NULL);
+  ASSERT_OBJECT_REFCOUNT (pipeline, "pipeline", 1);
 }
 
 GST_END_TEST;