mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-12-23 08:46:40 +00:00
tests/check/: enable queue test again, add tests for the leaky behaviour
Original commit message from CVS: * tests/check/Makefile.am: * tests/check/elements/queue.c: (queue_overrun), (queue_underrun), (GST_START_TEST), (queue_suite): enable queue test again, add tests for the leaky behaviour
This commit is contained in:
parent
40f4221ac5
commit
6fe3fda99e
3 changed files with 157 additions and 4 deletions
|
@ -1,3 +1,10 @@
|
|||
2007-01-04 Stefan Kost <ensonic@users.sf.net>
|
||||
|
||||
* tests/check/Makefile.am:
|
||||
* tests/check/elements/queue.c: (queue_overrun), (queue_underrun),
|
||||
(GST_START_TEST), (queue_suite):
|
||||
enable queue test again, add tests for the leaky behaviour
|
||||
|
||||
2007-01-02 Tim-Philipp Müller <tim at centricular dot net>
|
||||
|
||||
* configure.ac:
|
||||
|
|
|
@ -57,6 +57,7 @@ REGISTRY_CHECKS = \
|
|||
elements/fdsrc \
|
||||
elements/filesrc \
|
||||
elements/identity \
|
||||
elements/queue \
|
||||
libs/basesrc \
|
||||
libs/controller \
|
||||
libs/typefindhelper \
|
||||
|
@ -91,11 +92,9 @@ check_PROGRAMS = \
|
|||
libs/gstnettimeprovider
|
||||
|
||||
# failing tests
|
||||
# queue : seems to work with installed gstcheck
|
||||
noinst_PROGRAMS = \
|
||||
gst/gstpipeline \
|
||||
libs/collectpads \
|
||||
elements/queue
|
||||
libs/collectpads
|
||||
|
||||
TESTS = $(check_PROGRAMS)
|
||||
|
||||
|
|
|
@ -104,7 +104,6 @@ GST_START_TEST (test_non_leaky_underrun)
|
|||
GST_STATE_PLAYING) == GST_STATE_CHANGE_SUCCESS,
|
||||
"could not set to playing");
|
||||
|
||||
/* FIXME: there seems to be a race here */
|
||||
g_mutex_lock (check_mutex);
|
||||
g_cond_wait (check_cond, check_mutex);
|
||||
g_mutex_unlock (check_mutex);
|
||||
|
@ -184,6 +183,152 @@ GST_START_TEST (test_non_leaky_overrun)
|
|||
|
||||
GST_END_TEST;
|
||||
|
||||
/* set queue size to 2 buffers
|
||||
* push 2 buffers
|
||||
* check over/underuns
|
||||
* push 1 more buffer
|
||||
* check over/underuns again
|
||||
* check which buffer was leaked
|
||||
*/
|
||||
GST_START_TEST (test_leaky_upstream)
|
||||
{
|
||||
GstElement *queue;
|
||||
GstBuffer *buffer1, *buffer2, *buffer3;
|
||||
GstBuffer *buffer;
|
||||
|
||||
queue = setup_queue ();
|
||||
mysrcpad = gst_check_setup_src_pad (queue, &srctemplate, NULL);
|
||||
mysinkpad = gst_check_setup_sink_pad (queue, &sinktemplate, NULL);
|
||||
g_object_set (G_OBJECT (queue), "max-size-buffers", 2, "leaky", 1, NULL);
|
||||
gst_pad_set_active (mysrcpad, TRUE);
|
||||
|
||||
GST_DEBUG ("starting");
|
||||
|
||||
fail_unless (gst_element_set_state (queue,
|
||||
GST_STATE_PLAYING) == GST_STATE_CHANGE_SUCCESS,
|
||||
"could not set to playing");
|
||||
|
||||
buffer1 = gst_buffer_new_and_alloc (4);
|
||||
ASSERT_BUFFER_REFCOUNT (buffer1, "buffer", 1);
|
||||
/* pushing gives away my reference ... */
|
||||
gst_pad_push (mysrcpad, buffer1);
|
||||
|
||||
GST_DEBUG ("added 1st");
|
||||
fail_unless (overrun_count == 0);
|
||||
fail_unless (underrun_count == 0);
|
||||
|
||||
buffer2 = gst_buffer_new_and_alloc (4);
|
||||
ASSERT_BUFFER_REFCOUNT (buffer2, "buffer", 1);
|
||||
/* pushing gives away my reference ... */
|
||||
gst_pad_push (mysrcpad, buffer2);
|
||||
|
||||
GST_DEBUG ("added 2nd");
|
||||
fail_unless (overrun_count == 0);
|
||||
fail_unless (underrun_count == 0);
|
||||
|
||||
buffer3 = gst_buffer_new_and_alloc (4);
|
||||
ASSERT_BUFFER_REFCOUNT (buffer3, "buffer", 1);
|
||||
/* pushing gives away my reference ... */
|
||||
gst_pad_push (mysrcpad, gst_buffer_ref (buffer3));
|
||||
|
||||
/* start the src-task briefly leak buffer3 */
|
||||
gst_pad_set_active (mysinkpad, TRUE);
|
||||
|
||||
g_mutex_lock (check_mutex);
|
||||
g_cond_wait (check_cond, check_mutex);
|
||||
g_mutex_unlock (check_mutex);
|
||||
|
||||
gst_pad_set_active (mysinkpad, FALSE);
|
||||
|
||||
GST_DEBUG ("stopping");
|
||||
|
||||
fail_unless (g_list_length (buffers) > 0);
|
||||
buffer = g_list_first (buffers)->data;
|
||||
fail_unless (buffer == buffer1);
|
||||
ASSERT_BUFFER_REFCOUNT (buffer3, "buffer", 1);
|
||||
|
||||
/* it still triggers overrun when leaking */
|
||||
fail_unless (overrun_count == 1);
|
||||
|
||||
/* cleanup */
|
||||
gst_pad_set_active (mysrcpad, FALSE);
|
||||
gst_buffer_unref (buffer3);
|
||||
gst_check_teardown_src_pad (queue);
|
||||
gst_check_teardown_sink_pad (queue);
|
||||
cleanup_queue (queue);
|
||||
}
|
||||
|
||||
GST_END_TEST;
|
||||
|
||||
GST_START_TEST (test_leaky_downstream)
|
||||
{
|
||||
GstElement *queue;
|
||||
GstBuffer *buffer1, *buffer2, *buffer3;
|
||||
GstBuffer *buffer;
|
||||
|
||||
queue = setup_queue ();
|
||||
mysrcpad = gst_check_setup_src_pad (queue, &srctemplate, NULL);
|
||||
mysinkpad = gst_check_setup_sink_pad (queue, &sinktemplate, NULL);
|
||||
g_object_set (G_OBJECT (queue), "max-size-buffers", 2, "leaky", 2, NULL);
|
||||
gst_pad_set_active (mysrcpad, TRUE);
|
||||
|
||||
GST_DEBUG ("starting");
|
||||
|
||||
fail_unless (gst_element_set_state (queue,
|
||||
GST_STATE_PLAYING) == GST_STATE_CHANGE_SUCCESS,
|
||||
"could not set to playing");
|
||||
|
||||
buffer1 = gst_buffer_new_and_alloc (4);
|
||||
ASSERT_BUFFER_REFCOUNT (buffer1, "buffer", 1);
|
||||
/* pushing gives away my reference ... */
|
||||
gst_pad_push (mysrcpad, gst_buffer_ref (buffer1));
|
||||
|
||||
GST_DEBUG ("added 1st");
|
||||
fail_unless (overrun_count == 0);
|
||||
fail_unless (underrun_count == 0);
|
||||
|
||||
buffer2 = gst_buffer_new_and_alloc (4);
|
||||
ASSERT_BUFFER_REFCOUNT (buffer2, "buffer", 1);
|
||||
/* pushing gives away my reference ... */
|
||||
gst_pad_push (mysrcpad, buffer2);
|
||||
|
||||
GST_DEBUG ("added 2nd");
|
||||
fail_unless (overrun_count == 0);
|
||||
fail_unless (underrun_count == 0);
|
||||
|
||||
buffer3 = gst_buffer_new_and_alloc (4);
|
||||
ASSERT_BUFFER_REFCOUNT (buffer3, "buffer", 1);
|
||||
/* pushing gives away my reference ... */
|
||||
gst_pad_push (mysrcpad, buffer3);
|
||||
|
||||
/* start the src-task briefly and leak buffer1 */
|
||||
gst_pad_set_active (mysinkpad, TRUE);
|
||||
|
||||
g_mutex_lock (check_mutex);
|
||||
g_cond_wait (check_cond, check_mutex);
|
||||
g_mutex_unlock (check_mutex);
|
||||
|
||||
gst_pad_set_active (mysinkpad, FALSE);
|
||||
|
||||
GST_DEBUG ("stopping");
|
||||
|
||||
fail_unless (g_list_length (buffers) > 0);
|
||||
buffer = g_list_first (buffers)->data;
|
||||
fail_unless (buffer == buffer2);
|
||||
ASSERT_BUFFER_REFCOUNT (buffer1, "buffer", 1);
|
||||
|
||||
/* it still triggers overrun when leaking */
|
||||
fail_unless (overrun_count == 1);
|
||||
|
||||
/* cleanup */
|
||||
gst_pad_set_active (mysrcpad, FALSE);
|
||||
gst_buffer_unref (buffer1);
|
||||
gst_check_teardown_src_pad (queue);
|
||||
gst_check_teardown_sink_pad (queue);
|
||||
cleanup_queue (queue);
|
||||
}
|
||||
|
||||
GST_END_TEST;
|
||||
|
||||
Suite *
|
||||
queue_suite (void)
|
||||
|
@ -194,6 +339,8 @@ queue_suite (void)
|
|||
suite_add_tcase (s, tc_chain);
|
||||
tcase_add_test (tc_chain, test_non_leaky_underrun);
|
||||
tcase_add_test (tc_chain, test_non_leaky_overrun);
|
||||
tcase_add_test (tc_chain, test_leaky_upstream);
|
||||
tcase_add_test (tc_chain, test_leaky_downstream);
|
||||
|
||||
return s;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue