check/: wait on thread to die so we can check refcount correctly

Original commit message from CVS:

* check/gst/gstbin.c: (GST_START_TEST):
* check/gst/gstghostpad.c: (GST_START_TEST):
* check/pipelines/cleanup.c: (GST_START_TEST):
wait on thread to die so we can check refcount correctly
This commit is contained in:
Thomas Vander Stichele 2005-10-19 11:43:42 +00:00
parent 6404c696a8
commit 842007120e
7 changed files with 91 additions and 76 deletions

View file

@ -1,3 +1,10 @@
2005-10-19 Thomas Vander Stichele <thomas at apestaart dot org>
* check/gst/gstbin.c: (GST_START_TEST):
* check/gst/gstghostpad.c: (GST_START_TEST):
* check/pipelines/cleanup.c: (GST_START_TEST):
wait on thread to die so we can check refcount correctly
2005-10-18 Wim Taymans <wim@fluendo.com>
* check/pipelines/stress.c: (GST_START_TEST):

View file

@ -270,6 +270,10 @@ GST_START_TEST (test_message_state_changed_children)
fail_unless (current == GST_STATE_PAUSED);
fail_unless (pending == GST_STATE_VOID_PENDING);
/* wait for async thread to settle down */
while (GST_OBJECT_REFCOUNT_VALUE (pipeline) > 2)
THREAD_SWITCH ();
/* each object is referenced by a message;
* base_sink_chain has taken a refcount on the sink, and is blocked on
* preroll */
@ -654,6 +658,9 @@ GST_START_TEST (test_children_state_change_order_semi_sink)
pop_messages (bus, 4); /* pop playing => paused messages off the bus */
pop_messages (bus, 4); /* pop paused => ready messages off the bus */
while (GST_OBJECT_REFCOUNT_VALUE (pipeline) > 1)
THREAD_SWITCH ();
ASSERT_OBJECT_REFCOUNT (src, "src", 1);
ASSERT_OBJECT_REFCOUNT (sink, "sink", 1);
ASSERT_OBJECT_REFCOUNT (pipeline, "pipeline", 1);

View file

@ -21,14 +21,6 @@
#include <gst/check/gstcheck.h>
static void
assert_gstrefcount (gpointer p, gint i)
{
if (GST_OBJECT_REFCOUNT_VALUE (p) != i)
g_critical ("Expected refcount %d for %s, got %d", i, GST_OBJECT_NAME (p),
GST_OBJECT_REFCOUNT_VALUE (p));
}
/* test if removing a bin also cleans up the ghostpads
*/
GST_START_TEST (test_remove1)
@ -237,15 +229,15 @@ GST_START_TEST (test_ghost_pads)
/* all objects above have one refcount owned by us as well */
assert_gstrefcount (fsrc, 3); /* parent and gisrc */
assert_gstrefcount (gsink, 2); /* parent */
assert_gstrefcount (gsrc, 2); /* parent */
assert_gstrefcount (fsink, 3); /* parent and gisink */
ASSERT_OBJECT_REFCOUNT (fsrc, "fsrc", 3); /* parent and gisrc */
ASSERT_OBJECT_REFCOUNT (gsink, "gsink", 2); /* parent */
ASSERT_OBJECT_REFCOUNT (gsrc, "gsrc", 2); /* parent */
ASSERT_OBJECT_REFCOUNT (fsink, "fsink", 3); /* parent and gisink */
assert_gstrefcount (gisrc, 2); /* parent */
assert_gstrefcount (isink, 3); /* parent and gsink */
assert_gstrefcount (gisink, 2); /* parent */
assert_gstrefcount (isrc, 3); /* parent and gsrc */
ASSERT_OBJECT_REFCOUNT (gisrc, "gisrc", 2); /* parent */
ASSERT_OBJECT_REFCOUNT (isink, "isink", 3); /* parent and gsink */
ASSERT_OBJECT_REFCOUNT (gisink, "gisink", 2); /* parent */
ASSERT_OBJECT_REFCOUNT (isrc, "isrc", 3); /* parent and gsrc */
ret = gst_element_set_state (b1, GST_STATE_PLAYING);
ret = gst_element_get_state (b1, NULL, NULL, GST_CLOCK_TIME_NONE);
@ -259,29 +251,33 @@ GST_START_TEST (test_ghost_pads)
/* unreffing the bin will unref all elements, which will unlink and unparent
* all pads */
assert_gstrefcount (fsrc, 2); /* gisrc */
assert_gstrefcount (gsink, 1);
assert_gstrefcount (gsrc, 1);
assert_gstrefcount (fsink, 2); /* gisink */
/* wait for thread to settle down */
while (GST_OBJECT_REFCOUNT_VALUE (fsrc) > 2)
THREAD_SWITCH ();
assert_gstrefcount (gisrc, 1); /* gsink */
assert_gstrefcount (isink, 2); /* gsink */
assert_gstrefcount (gisink, 1); /* gsrc */
assert_gstrefcount (isrc, 2); /* gsrc */
ASSERT_OBJECT_REFCOUNT (fsrc, "fsrc", 2); /* gisrc */
ASSERT_OBJECT_REFCOUNT (gsink, "gsink", 1);
ASSERT_OBJECT_REFCOUNT (gsrc, "gsink", 1);
ASSERT_OBJECT_REFCOUNT (fsink, "fsink", 2); /* gisink */
ASSERT_OBJECT_REFCOUNT (gisrc, "gisrc", 1); /* gsink */
ASSERT_OBJECT_REFCOUNT (isink, "isink", 2); /* gsink */
ASSERT_OBJECT_REFCOUNT (gisink, "gisink", 1); /* gsrc */
ASSERT_OBJECT_REFCOUNT (isrc, "isrc", 2); /* gsrc */
gst_object_unref (gsink);
assert_gstrefcount (isink, 1);
assert_gstrefcount (gisrc, 1);
assert_gstrefcount (fsrc, 2); /* gisrc */
ASSERT_OBJECT_REFCOUNT (isink, "isink", 1);
ASSERT_OBJECT_REFCOUNT (gisrc, "gisrc", 1);
ASSERT_OBJECT_REFCOUNT (fsrc, "fsrc", 2); /* gisrc */
gst_object_unref (gisrc);
assert_gstrefcount (fsrc, 1);
ASSERT_OBJECT_REFCOUNT (fsrc, "fsrc", 1);
gst_object_unref (gsrc);
assert_gstrefcount (isrc, 1);
assert_gstrefcount (gisink, 1);
assert_gstrefcount (fsink, 2); /* gisrc */
ASSERT_OBJECT_REFCOUNT (isrc, "isrc", 1);
ASSERT_OBJECT_REFCOUNT (gisink, "gisink", 1);
ASSERT_OBJECT_REFCOUNT (fsink, "fsink", 2); /* gisrc */
gst_object_unref (gisink);
assert_gstrefcount (fsink, 1);
ASSERT_OBJECT_REFCOUNT (fsink, "fsink", 1);
gst_object_unref (fsrc);
gst_object_unref (isrc);

View file

@ -78,7 +78,6 @@ run_pipeline (GstElement * pipeline, gchar * descr,
GST_START_TEST (test_pipeline_unref)
{
gchar *s;
gint count;
GstElement *pipeline, *src, *sink;
s = "fakesrc name=src num-buffers=20 ! fakesink name=sink";
@ -91,15 +90,17 @@ GST_START_TEST (test_pipeline_unref)
run_pipeline (pipeline, s, GST_MESSAGE_NEW_CLOCK | GST_MESSAGE_STATE_CHANGED,
GST_MESSAGE_EOS);
count = GST_OBJECT_REFCOUNT_VALUE (src);
fail_unless (count == 1, "src has a refcount of %d instead of 1", count);
count = GST_OBJECT_REFCOUNT_VALUE (sink);
fail_unless (count == 1, "sink has a refcount of %d instead of 1", count);
while (GST_OBJECT_REFCOUNT_VALUE (src) > 1)
THREAD_SWITCH ();
ASSERT_OBJECT_REFCOUNT (src, "src", 1);
ASSERT_OBJECT_REFCOUNT (sink, "sink", 1);
gst_object_unref (src);
gst_object_unref (sink);
}
GST_END_TEST Suite *
GST_END_TEST;
Suite *
cleanup_suite (void)
{
Suite *s = suite_create ("Pipeline cleanup");

View file

@ -270,6 +270,10 @@ GST_START_TEST (test_message_state_changed_children)
fail_unless (current == GST_STATE_PAUSED);
fail_unless (pending == GST_STATE_VOID_PENDING);
/* wait for async thread to settle down */
while (GST_OBJECT_REFCOUNT_VALUE (pipeline) > 2)
THREAD_SWITCH ();
/* each object is referenced by a message;
* base_sink_chain has taken a refcount on the sink, and is blocked on
* preroll */
@ -654,6 +658,9 @@ GST_START_TEST (test_children_state_change_order_semi_sink)
pop_messages (bus, 4); /* pop playing => paused messages off the bus */
pop_messages (bus, 4); /* pop paused => ready messages off the bus */
while (GST_OBJECT_REFCOUNT_VALUE (pipeline) > 1)
THREAD_SWITCH ();
ASSERT_OBJECT_REFCOUNT (src, "src", 1);
ASSERT_OBJECT_REFCOUNT (sink, "sink", 1);
ASSERT_OBJECT_REFCOUNT (pipeline, "pipeline", 1);

View file

@ -21,14 +21,6 @@
#include <gst/check/gstcheck.h>
static void
assert_gstrefcount (gpointer p, gint i)
{
if (GST_OBJECT_REFCOUNT_VALUE (p) != i)
g_critical ("Expected refcount %d for %s, got %d", i, GST_OBJECT_NAME (p),
GST_OBJECT_REFCOUNT_VALUE (p));
}
/* test if removing a bin also cleans up the ghostpads
*/
GST_START_TEST (test_remove1)
@ -237,15 +229,15 @@ GST_START_TEST (test_ghost_pads)
/* all objects above have one refcount owned by us as well */
assert_gstrefcount (fsrc, 3); /* parent and gisrc */
assert_gstrefcount (gsink, 2); /* parent */
assert_gstrefcount (gsrc, 2); /* parent */
assert_gstrefcount (fsink, 3); /* parent and gisink */
ASSERT_OBJECT_REFCOUNT (fsrc, "fsrc", 3); /* parent and gisrc */
ASSERT_OBJECT_REFCOUNT (gsink, "gsink", 2); /* parent */
ASSERT_OBJECT_REFCOUNT (gsrc, "gsrc", 2); /* parent */
ASSERT_OBJECT_REFCOUNT (fsink, "fsink", 3); /* parent and gisink */
assert_gstrefcount (gisrc, 2); /* parent */
assert_gstrefcount (isink, 3); /* parent and gsink */
assert_gstrefcount (gisink, 2); /* parent */
assert_gstrefcount (isrc, 3); /* parent and gsrc */
ASSERT_OBJECT_REFCOUNT (gisrc, "gisrc", 2); /* parent */
ASSERT_OBJECT_REFCOUNT (isink, "isink", 3); /* parent and gsink */
ASSERT_OBJECT_REFCOUNT (gisink, "gisink", 2); /* parent */
ASSERT_OBJECT_REFCOUNT (isrc, "isrc", 3); /* parent and gsrc */
ret = gst_element_set_state (b1, GST_STATE_PLAYING);
ret = gst_element_get_state (b1, NULL, NULL, GST_CLOCK_TIME_NONE);
@ -259,29 +251,33 @@ GST_START_TEST (test_ghost_pads)
/* unreffing the bin will unref all elements, which will unlink and unparent
* all pads */
assert_gstrefcount (fsrc, 2); /* gisrc */
assert_gstrefcount (gsink, 1);
assert_gstrefcount (gsrc, 1);
assert_gstrefcount (fsink, 2); /* gisink */
/* wait for thread to settle down */
while (GST_OBJECT_REFCOUNT_VALUE (fsrc) > 2)
THREAD_SWITCH ();
assert_gstrefcount (gisrc, 1); /* gsink */
assert_gstrefcount (isink, 2); /* gsink */
assert_gstrefcount (gisink, 1); /* gsrc */
assert_gstrefcount (isrc, 2); /* gsrc */
ASSERT_OBJECT_REFCOUNT (fsrc, "fsrc", 2); /* gisrc */
ASSERT_OBJECT_REFCOUNT (gsink, "gsink", 1);
ASSERT_OBJECT_REFCOUNT (gsrc, "gsink", 1);
ASSERT_OBJECT_REFCOUNT (fsink, "fsink", 2); /* gisink */
ASSERT_OBJECT_REFCOUNT (gisrc, "gisrc", 1); /* gsink */
ASSERT_OBJECT_REFCOUNT (isink, "isink", 2); /* gsink */
ASSERT_OBJECT_REFCOUNT (gisink, "gisink", 1); /* gsrc */
ASSERT_OBJECT_REFCOUNT (isrc, "isrc", 2); /* gsrc */
gst_object_unref (gsink);
assert_gstrefcount (isink, 1);
assert_gstrefcount (gisrc, 1);
assert_gstrefcount (fsrc, 2); /* gisrc */
ASSERT_OBJECT_REFCOUNT (isink, "isink", 1);
ASSERT_OBJECT_REFCOUNT (gisrc, "gisrc", 1);
ASSERT_OBJECT_REFCOUNT (fsrc, "fsrc", 2); /* gisrc */
gst_object_unref (gisrc);
assert_gstrefcount (fsrc, 1);
ASSERT_OBJECT_REFCOUNT (fsrc, "fsrc", 1);
gst_object_unref (gsrc);
assert_gstrefcount (isrc, 1);
assert_gstrefcount (gisink, 1);
assert_gstrefcount (fsink, 2); /* gisrc */
ASSERT_OBJECT_REFCOUNT (isrc, "isrc", 1);
ASSERT_OBJECT_REFCOUNT (gisink, "gisink", 1);
ASSERT_OBJECT_REFCOUNT (fsink, "fsink", 2); /* gisrc */
gst_object_unref (gisink);
assert_gstrefcount (fsink, 1);
ASSERT_OBJECT_REFCOUNT (fsink, "fsink", 1);
gst_object_unref (fsrc);
gst_object_unref (isrc);

View file

@ -78,7 +78,6 @@ run_pipeline (GstElement * pipeline, gchar * descr,
GST_START_TEST (test_pipeline_unref)
{
gchar *s;
gint count;
GstElement *pipeline, *src, *sink;
s = "fakesrc name=src num-buffers=20 ! fakesink name=sink";
@ -91,15 +90,17 @@ GST_START_TEST (test_pipeline_unref)
run_pipeline (pipeline, s, GST_MESSAGE_NEW_CLOCK | GST_MESSAGE_STATE_CHANGED,
GST_MESSAGE_EOS);
count = GST_OBJECT_REFCOUNT_VALUE (src);
fail_unless (count == 1, "src has a refcount of %d instead of 1", count);
count = GST_OBJECT_REFCOUNT_VALUE (sink);
fail_unless (count == 1, "sink has a refcount of %d instead of 1", count);
while (GST_OBJECT_REFCOUNT_VALUE (src) > 1)
THREAD_SWITCH ();
ASSERT_OBJECT_REFCOUNT (src, "src", 1);
ASSERT_OBJECT_REFCOUNT (sink, "sink", 1);
gst_object_unref (src);
gst_object_unref (sink);
}
GST_END_TEST Suite *
GST_END_TEST;
Suite *
cleanup_suite (void)
{
Suite *s = suite_create ("Pipeline cleanup");