mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-12-23 16:50:47 +00:00
check/Makefile.am: don't valgrind the controller test - it's leaking - Stefan, HELP
Original commit message from CVS: * check/Makefile.am: don't valgrind the controller test - it's leaking - Stefan, HELP * gst/check/gstcheck.c: (gst_check_message_error), (gst_check_chain_func), (gst_check_setup_element), (gst_check_teardown_element), (gst_check_setup_src_pad), (gst_check_teardown_src_pad), (gst_check_setup_sink_pad), (gst_check_teardown_sink_pad): * gst/check/gstcheck.h: add a bunch of methods to set up elements, and src and sink pads * check/elements/fakesrc.c: (setup_fakesrc), (cleanup_fakesrc): * check/elements/identity.c: (setup_identity), (cleanup_identity), (GST_START_TEST): use them * gst/gstmessage.c: * gst/gsttag.h: whitespace/doc fixes
This commit is contained in:
parent
feb446c5d4
commit
744193f884
15 changed files with 373 additions and 268 deletions
19
ChangeLog
19
ChangeLog
|
@ -1,3 +1,22 @@
|
|||
2005-08-21 Thomas Vander Stichele <thomas at apestaart dot org>
|
||||
|
||||
* check/Makefile.am:
|
||||
don't valgrind the controller test - it's leaking - Stefan, HELP
|
||||
* gst/check/gstcheck.c: (gst_check_message_error),
|
||||
(gst_check_chain_func), (gst_check_setup_element),
|
||||
(gst_check_teardown_element), (gst_check_setup_src_pad),
|
||||
(gst_check_teardown_src_pad), (gst_check_setup_sink_pad),
|
||||
(gst_check_teardown_sink_pad):
|
||||
* gst/check/gstcheck.h:
|
||||
add a bunch of methods to set up elements, and src and sink pads
|
||||
* check/elements/fakesrc.c: (setup_fakesrc), (cleanup_fakesrc):
|
||||
* check/elements/identity.c: (setup_identity), (cleanup_identity),
|
||||
(GST_START_TEST):
|
||||
use them
|
||||
* gst/gstmessage.c:
|
||||
* gst/gsttag.h:
|
||||
whitespace/doc fixes
|
||||
|
||||
2005-08-20 Thomas Vander Stichele <thomas at apestaart dot org>
|
||||
|
||||
* gst/gstelement.h:
|
||||
|
|
|
@ -78,6 +78,7 @@ gst_libs_controller_LDADD = $(GST_OBJ_LIBS) \
|
|||
# valgrind testing
|
||||
# these just need valgrind fixing, period
|
||||
TESTS_TO_FIX = \
|
||||
gst-libs/controller \
|
||||
pipelines/cleanup \
|
||||
pipelines/simple_launch_lines
|
||||
|
||||
|
|
|
@ -24,22 +24,15 @@
|
|||
|
||||
#include <gst/check/gstcheck.h>
|
||||
|
||||
GList *buffers = NULL;
|
||||
gboolean have_eos = FALSE;
|
||||
|
||||
GstPad *mysinkpad;
|
||||
|
||||
static GstStaticPadTemplate sinktemplate = GST_STATIC_PAD_TEMPLATE ("sink",
|
||||
GST_PAD_SINK,
|
||||
GST_PAD_ALWAYS,
|
||||
GST_STATIC_CAPS_ANY);
|
||||
|
||||
GstFlowReturn
|
||||
chain_func (GstPad * pad, GstBuffer * buffer)
|
||||
{
|
||||
buffers = g_list_append (buffers, buffer);
|
||||
|
||||
return GST_FLOW_OK;
|
||||
}
|
||||
|
||||
gboolean
|
||||
event_func (GstPad * pad, GstEvent * event)
|
||||
{
|
||||
|
@ -60,52 +53,20 @@ event_func (GstPad * pad, GstEvent * event)
|
|||
GstElement *
|
||||
setup_fakesrc ()
|
||||
{
|
||||
GstElement *src;
|
||||
GstPad *srcpad, *sinkpad;
|
||||
GstElement *fakesrc;
|
||||
|
||||
src = gst_element_factory_make ("fakesrc", "src");
|
||||
fail_if (src == NULL, "Could not create a fakesrc");
|
||||
|
||||
sinkpad =
|
||||
gst_pad_new_from_template (gst_static_pad_template_get (&sinktemplate),
|
||||
"sink");
|
||||
fail_if (sinkpad == NULL, "Could not create a sinkpad");
|
||||
|
||||
srcpad = gst_element_get_pad (src, "src");
|
||||
fail_if (srcpad == NULL, "Could not get source pad from fakesrc");
|
||||
gst_pad_set_caps (sinkpad, NULL);
|
||||
gst_pad_set_chain_function (sinkpad, chain_func);
|
||||
gst_pad_set_event_function (sinkpad, event_func);
|
||||
|
||||
fail_unless (gst_pad_link (srcpad, sinkpad) == GST_PAD_LINK_OK,
|
||||
"Could not link source and sink pads");
|
||||
return src;
|
||||
GST_DEBUG ("setup_fakesrc");
|
||||
fakesrc = gst_check_setup_element ("fakesrc");
|
||||
mysinkpad = gst_check_setup_sink_pad (fakesrc, &sinktemplate, NULL);
|
||||
gst_pad_set_event_function (mysinkpad, event_func);
|
||||
return fakesrc;
|
||||
}
|
||||
|
||||
void
|
||||
cleanup_fakesrc (GstElement * src)
|
||||
cleanup_fakesrc (GstElement * fakesrc)
|
||||
{
|
||||
GstPad *srcpad, *sinkpad;
|
||||
|
||||
fail_unless (gst_element_set_state (src, GST_STATE_NULL) == GST_STATE_SUCCESS,
|
||||
"could not set to null");
|
||||
|
||||
srcpad = gst_element_get_pad (src, "src");
|
||||
sinkpad = gst_pad_get_peer (srcpad);
|
||||
|
||||
ASSERT_OBJECT_REFCOUNT (src, "src", 1);
|
||||
gst_object_unref (src);
|
||||
|
||||
gst_pad_unlink (srcpad, sinkpad);
|
||||
|
||||
/* pad refs held by both creator and this function (through _get) */
|
||||
ASSERT_OBJECT_REFCOUNT (srcpad, "srcpad", 2);
|
||||
gst_object_unref (srcpad);
|
||||
gst_object_unref (srcpad);
|
||||
|
||||
ASSERT_OBJECT_REFCOUNT (sinkpad, "sinkpad", 2);
|
||||
gst_object_unref (sinkpad);
|
||||
gst_object_unref (sinkpad);
|
||||
gst_check_teardown_sink_pad (fakesrc);
|
||||
gst_check_teardown_element (fakesrc);
|
||||
}
|
||||
|
||||
GST_START_TEST (test_num_buffers)
|
||||
|
|
|
@ -42,15 +42,6 @@ static GstStaticPadTemplate srctemplate = GST_STATIC_PAD_TEMPLATE ("src",
|
|||
GST_PAD_ALWAYS,
|
||||
GST_STATIC_CAPS_ANY);
|
||||
|
||||
GstFlowReturn
|
||||
chain_func (GstPad * pad, GstBuffer * buffer)
|
||||
{
|
||||
GST_DEBUG ("chain_func: received buffer %p", buffer);
|
||||
buffers = g_list_append (buffers, buffer);
|
||||
|
||||
return GST_FLOW_OK;
|
||||
}
|
||||
|
||||
gboolean
|
||||
event_func (GstPad * pad, GstEvent * event)
|
||||
{
|
||||
|
@ -72,90 +63,25 @@ GstElement *
|
|||
setup_identity ()
|
||||
{
|
||||
GstElement *identity;
|
||||
GstPad *srcpad, *sinkpad;
|
||||
|
||||
GST_DEBUG ("setup_identity");
|
||||
|
||||
identity = gst_element_factory_make ("identity", "identity");
|
||||
fail_if (identity == NULL, "Could not create a identity");
|
||||
|
||||
/* sending pad */
|
||||
mysrcpad =
|
||||
gst_pad_new_from_template (gst_static_pad_template_get (&srctemplate),
|
||||
"src");
|
||||
fail_if (mysrcpad == NULL, "Could not create a mysrcpad");
|
||||
ASSERT_OBJECT_REFCOUNT (mysrcpad, "mysrcpad", 1);
|
||||
|
||||
sinkpad = gst_element_get_pad (identity, "sink");
|
||||
fail_if (sinkpad == NULL, "Could not get source pad from identity");
|
||||
ASSERT_OBJECT_REFCOUNT (sinkpad, "sinkpad", 2);
|
||||
gst_pad_set_caps (mysrcpad, NULL);
|
||||
fail_unless (gst_pad_link (mysrcpad, sinkpad) == GST_PAD_LINK_OK,
|
||||
"Could not link source and identity sink pads");
|
||||
gst_object_unref (sinkpad); /* because we got it higher up */
|
||||
ASSERT_OBJECT_REFCOUNT (sinkpad, "sinkpad", 1);
|
||||
|
||||
/* receiving pad */
|
||||
mysinkpad =
|
||||
gst_pad_new_from_template (gst_static_pad_template_get (&sinktemplate),
|
||||
"sink");
|
||||
fail_if (mysinkpad == NULL, "Could not create a mysinkpad");
|
||||
|
||||
srcpad = gst_element_get_pad (identity, "src");
|
||||
fail_if (srcpad == NULL, "Could not get source pad from identity");
|
||||
gst_pad_set_caps (mysinkpad, NULL);
|
||||
gst_pad_set_chain_function (mysinkpad, chain_func);
|
||||
identity = gst_check_setup_element ("identity");
|
||||
mysrcpad = gst_check_setup_src_pad (identity, &srctemplate, NULL);
|
||||
mysinkpad = gst_check_setup_sink_pad (identity, &sinktemplate, NULL);
|
||||
gst_pad_set_event_function (mysinkpad, event_func);
|
||||
|
||||
fail_unless (gst_pad_link (srcpad, mysinkpad) == GST_PAD_LINK_OK,
|
||||
"Could not link identity source and mysink pads");
|
||||
gst_object_unref (srcpad); /* because we got it higher up */
|
||||
ASSERT_OBJECT_REFCOUNT (srcpad, "srcpad", 1);
|
||||
|
||||
return identity;
|
||||
}
|
||||
|
||||
void
|
||||
cleanup_identity (GstElement * identity)
|
||||
{
|
||||
GstPad *srcpad, *sinkpad;
|
||||
|
||||
GST_DEBUG ("cleanup_identity");
|
||||
|
||||
fail_unless (gst_element_set_state (identity, GST_STATE_NULL) ==
|
||||
GST_STATE_SUCCESS, "could not set to null");
|
||||
ASSERT_OBJECT_REFCOUNT (identity, "identity", 1);
|
||||
|
||||
/* clean up floating src pad */
|
||||
sinkpad = gst_element_get_pad (identity, "sink");
|
||||
ASSERT_OBJECT_REFCOUNT (sinkpad, "sinkpad", 2);
|
||||
|
||||
gst_pad_unlink (mysrcpad, sinkpad);
|
||||
|
||||
/* pad refs held by both creator and this function (through _get) */
|
||||
ASSERT_OBJECT_REFCOUNT (mysrcpad, "srcpad", 1);
|
||||
gst_object_unref (mysrcpad);
|
||||
mysrcpad = NULL;
|
||||
|
||||
ASSERT_OBJECT_REFCOUNT (sinkpad, "sinkpad", 2);
|
||||
gst_object_unref (sinkpad);
|
||||
/* one more ref is held by identity itself */
|
||||
|
||||
/* clean up floating sink pad */
|
||||
srcpad = gst_element_get_pad (identity, "src");
|
||||
gst_pad_unlink (srcpad, mysinkpad);
|
||||
|
||||
/* pad refs held by both creator and this function (through _get) */
|
||||
ASSERT_OBJECT_REFCOUNT (srcpad, "srcpad", 2);
|
||||
gst_object_unref (srcpad);
|
||||
/* one more ref is held by identity itself */
|
||||
|
||||
ASSERT_OBJECT_REFCOUNT (mysinkpad, "mysinkpad", 1);
|
||||
gst_object_unref (mysinkpad);
|
||||
mysinkpad = NULL;
|
||||
|
||||
ASSERT_OBJECT_REFCOUNT (identity, "identity", 1);
|
||||
gst_object_unref (identity);
|
||||
gst_check_teardown_src_pad (identity);
|
||||
gst_check_teardown_sink_pad (identity);
|
||||
gst_check_teardown_element (identity);
|
||||
}
|
||||
|
||||
GST_START_TEST (test_one_buffer)
|
||||
|
|
2
common
2
common
|
@ -1 +1 @@
|
|||
Subproject commit 4cc6f465857331531a09aff0a23dc0b133e7f669
|
||||
Subproject commit 2827052513b1aa41f4a2414c163cfd0f4790b43c
|
|
@ -102,3 +102,134 @@ gst_check_message_error (GstMessage * message, GstMessageType type,
|
|||
g_error_free (error);
|
||||
g_free (debug);
|
||||
}
|
||||
|
||||
/* helper functions */
|
||||
GstFlowReturn
|
||||
gst_check_chain_func (GstPad * pad, GstBuffer * buffer)
|
||||
{
|
||||
GST_DEBUG ("chain_func: received buffer %p", buffer);
|
||||
buffers = g_list_append (buffers, buffer);
|
||||
|
||||
return GST_FLOW_OK;
|
||||
}
|
||||
|
||||
/* setup an element for a filter test with mysrcpad and mysinkpad */
|
||||
GstElement *
|
||||
gst_check_setup_element (const gchar * factory)
|
||||
{
|
||||
GstElement *element;
|
||||
|
||||
GST_DEBUG ("setup_element");
|
||||
|
||||
element = gst_element_factory_make (factory, factory);
|
||||
fail_if (element == NULL, "Could not create a %s", factory);
|
||||
ASSERT_OBJECT_REFCOUNT (element, factory, 1);
|
||||
return element;
|
||||
}
|
||||
|
||||
void
|
||||
gst_check_teardown_element (GstElement * element)
|
||||
{
|
||||
GST_DEBUG ("teardown_element");
|
||||
|
||||
fail_unless (gst_element_set_state (element, GST_STATE_NULL) ==
|
||||
GST_STATE_SUCCESS, "could not set to null");
|
||||
ASSERT_OBJECT_REFCOUNT (element, "element", 1);
|
||||
gst_object_unref (element);
|
||||
}
|
||||
|
||||
GstPad *
|
||||
gst_check_setup_src_pad (GstElement * element,
|
||||
GstStaticPadTemplate * srctemplate, GstCaps * caps)
|
||||
{
|
||||
GstPad *srcpad, *sinkpad;
|
||||
|
||||
/* sending pad */
|
||||
srcpad =
|
||||
gst_pad_new_from_template (gst_static_pad_template_get (srctemplate),
|
||||
"src");
|
||||
fail_if (srcpad == NULL, "Could not create a srcpad");
|
||||
ASSERT_OBJECT_REFCOUNT (srcpad, "srcpad", 1);
|
||||
|
||||
sinkpad = gst_element_get_pad (element, "sink");
|
||||
fail_if (sinkpad == NULL, "Could not get sink pad from %s",
|
||||
GST_ELEMENT_NAME (element));
|
||||
ASSERT_OBJECT_REFCOUNT (sinkpad, "sinkpad", 2);
|
||||
gst_pad_set_caps (srcpad, caps);
|
||||
fail_unless (gst_pad_link (srcpad, sinkpad) == GST_PAD_LINK_OK,
|
||||
"Could not link source and %s sink pads", GST_ELEMENT_NAME (element));
|
||||
gst_object_unref (sinkpad); /* because we got it higher up */
|
||||
ASSERT_OBJECT_REFCOUNT (sinkpad, "sinkpad", 1);
|
||||
|
||||
return srcpad;
|
||||
}
|
||||
|
||||
void
|
||||
gst_check_teardown_src_pad (GstElement * element)
|
||||
{
|
||||
GstPad *srcpad, *sinkpad;
|
||||
|
||||
/* clean up floating src pad */
|
||||
sinkpad = gst_element_get_pad (element, "sink");
|
||||
ASSERT_OBJECT_REFCOUNT (sinkpad, "sinkpad", 2);
|
||||
srcpad = gst_pad_get_peer (sinkpad);
|
||||
|
||||
gst_pad_unlink (srcpad, sinkpad);
|
||||
|
||||
/* pad refs held by both creator and this function (through _get) */
|
||||
ASSERT_OBJECT_REFCOUNT (sinkpad, "sinkpad", 2);
|
||||
gst_object_unref (sinkpad);
|
||||
/* one more ref is held by element itself */
|
||||
|
||||
/* pad refs held by both creator and this function (through _get_peer) */
|
||||
ASSERT_OBJECT_REFCOUNT (srcpad, "srcpad", 2);
|
||||
gst_object_unref (srcpad);
|
||||
gst_object_unref (srcpad);
|
||||
}
|
||||
|
||||
GstPad *
|
||||
gst_check_setup_sink_pad (GstElement * element, GstStaticPadTemplate * template,
|
||||
GstCaps * caps)
|
||||
{
|
||||
GstPad *srcpad, *sinkpad;
|
||||
|
||||
/* receiving pad */
|
||||
sinkpad =
|
||||
gst_pad_new_from_template (gst_static_pad_template_get (template),
|
||||
"sink");
|
||||
fail_if (sinkpad == NULL, "Could not create a sinkpad");
|
||||
|
||||
srcpad = gst_element_get_pad (element, "src");
|
||||
fail_if (srcpad == NULL, "Could not get source pad from %s",
|
||||
GST_ELEMENT_NAME (element));
|
||||
gst_pad_set_caps (sinkpad, caps);
|
||||
gst_pad_set_chain_function (sinkpad, gst_check_chain_func);
|
||||
|
||||
fail_unless (gst_pad_link (srcpad, sinkpad) == GST_PAD_LINK_OK,
|
||||
"Could not link %s source and sink pads", GST_ELEMENT_NAME (element));
|
||||
gst_object_unref (srcpad); /* because we got it higher up */
|
||||
ASSERT_OBJECT_REFCOUNT (srcpad, "srcpad", 1);
|
||||
|
||||
return sinkpad;
|
||||
}
|
||||
|
||||
void
|
||||
gst_check_teardown_sink_pad (GstElement * element)
|
||||
{
|
||||
GstPad *srcpad, *sinkpad;
|
||||
|
||||
/* clean up floating sink pad */
|
||||
srcpad = gst_element_get_pad (element, "src");
|
||||
sinkpad = gst_pad_get_peer (srcpad);
|
||||
gst_pad_unlink (srcpad, sinkpad);
|
||||
|
||||
/* pad refs held by both creator and this function (through _get_pad) */
|
||||
ASSERT_OBJECT_REFCOUNT (srcpad, "srcpad", 2);
|
||||
gst_object_unref (srcpad);
|
||||
/* one more ref is held by element itself */
|
||||
|
||||
/* pad refs held by both creator and this function (through _get_peer) */
|
||||
ASSERT_OBJECT_REFCOUNT (sinkpad, "sinkpad", 2);
|
||||
gst_object_unref (sinkpad);
|
||||
gst_object_unref (sinkpad);
|
||||
}
|
||||
|
|
|
@ -43,10 +43,25 @@ extern gboolean _gst_check_threads_running;
|
|||
extern gboolean _gst_check_raised_critical;
|
||||
extern gboolean _gst_check_expecting_log;
|
||||
|
||||
/* global variables used in test methods */
|
||||
GList * buffers;
|
||||
|
||||
void gst_check_init (int *argc, char **argv[]);
|
||||
|
||||
GstFlowReturn gst_check_chain_func (GstPad *pad, GstBuffer *buffer);
|
||||
|
||||
void gst_check_message_error (GstMessage *message, GstMessageType type, GQuark domain, gint code);
|
||||
|
||||
GstElement * gst_check_setup_element (const gchar *factory);
|
||||
void gst_check_teardown_element (GstElement *element);
|
||||
GstPad * gst_check_setup_src_pad (GstElement *element,
|
||||
GstStaticPadTemplate *template, GstCaps *caps);
|
||||
void gst_check_teardown_src_pad (GstElement *element);
|
||||
GstPad * gst_check_setup_sink_pad (GstElement *element,
|
||||
GstStaticPadTemplate *template, GstCaps *caps);
|
||||
void gst_check_teardown_sink_pad (GstElement *element);
|
||||
|
||||
|
||||
#define fail_unless_message_error(msg, domain, code) \
|
||||
gst_check_message_error (msg, GST_MESSAGE_ERROR, \
|
||||
GST_ ## domain ## _ERROR, GST_ ## domain ## _ERROR_ ## code)
|
||||
|
@ -71,6 +86,15 @@ G_STMT_START { \
|
|||
"'" #a "' (%d) is not equal to '" #b"' (%d)", first, second); \
|
||||
} G_STMT_END;
|
||||
|
||||
#define fail_unless_equals_string(a, b) \
|
||||
G_STMT_START { \
|
||||
gchar * first = a; \
|
||||
gchar * second = b; \
|
||||
fail_unless(strcmp (first, second) == 0, \
|
||||
"'" #a "' (%s) is not equal to '" #b"' (%s)", first, second); \
|
||||
} G_STMT_END;
|
||||
|
||||
|
||||
/***
|
||||
* thread test macros and variables
|
||||
*/
|
||||
|
@ -179,7 +203,7 @@ G_STMT_START { \
|
|||
int rc; \
|
||||
rc = GST_OBJECT_REFCOUNT_VALUE (object); \
|
||||
fail_unless (rc == value, \
|
||||
name " refcount is %d instead of %d", rc, value);\
|
||||
"%s refcount is %d instead of %d", name, rc, value); \
|
||||
} G_STMT_END
|
||||
|
||||
#define ASSERT_CAPS_REFCOUNT(caps, name, value) \
|
||||
|
|
|
@ -438,7 +438,7 @@ gst_message_parse_tag (GstMessage * message, GstTagList ** tag_list)
|
|||
}
|
||||
|
||||
/**
|
||||
* gst_message_parse_tag:
|
||||
* gst_message_parse_state_changed:
|
||||
* @message: A valid #GstMessage of type GST_MESSAGE_STATE_CHANGED.
|
||||
*
|
||||
* Extracts the old and new states from the GstMessage.
|
||||
|
|
|
@ -122,7 +122,7 @@ G_CONST_RETURN GValue *
|
|||
gst_tag_list_get_value_index (const GstTagList * list,
|
||||
const gchar * tag,
|
||||
guint index);
|
||||
gboolean gst_tag_list_copy_value (GValue * dest,
|
||||
gboolean gst_tag_list_copy_value (GValue * dest,
|
||||
const GstTagList * list,
|
||||
const gchar * tag);
|
||||
|
||||
|
@ -211,7 +211,7 @@ gboolean gst_tag_list_get_string_index (const GstTagList * list,
|
|||
const gchar * tag,
|
||||
guint index,
|
||||
gchar ** value);
|
||||
gboolean gst_tag_list_get_pointer (const GstTagList * list,
|
||||
gboolean gst_tag_list_get_pointer (const GstTagList * list,
|
||||
const gchar * tag,
|
||||
gpointer * value);
|
||||
gboolean gst_tag_list_get_pointer_index (const GstTagList * list,
|
||||
|
|
|
@ -122,7 +122,7 @@ G_CONST_RETURN GValue *
|
|||
gst_tag_list_get_value_index (const GstTagList * list,
|
||||
const gchar * tag,
|
||||
guint index);
|
||||
gboolean gst_tag_list_copy_value (GValue * dest,
|
||||
gboolean gst_tag_list_copy_value (GValue * dest,
|
||||
const GstTagList * list,
|
||||
const gchar * tag);
|
||||
|
||||
|
@ -211,7 +211,7 @@ gboolean gst_tag_list_get_string_index (const GstTagList * list,
|
|||
const gchar * tag,
|
||||
guint index,
|
||||
gchar ** value);
|
||||
gboolean gst_tag_list_get_pointer (const GstTagList * list,
|
||||
gboolean gst_tag_list_get_pointer (const GstTagList * list,
|
||||
const gchar * tag,
|
||||
gpointer * value);
|
||||
gboolean gst_tag_list_get_pointer_index (const GstTagList * list,
|
||||
|
|
|
@ -102,3 +102,134 @@ gst_check_message_error (GstMessage * message, GstMessageType type,
|
|||
g_error_free (error);
|
||||
g_free (debug);
|
||||
}
|
||||
|
||||
/* helper functions */
|
||||
GstFlowReturn
|
||||
gst_check_chain_func (GstPad * pad, GstBuffer * buffer)
|
||||
{
|
||||
GST_DEBUG ("chain_func: received buffer %p", buffer);
|
||||
buffers = g_list_append (buffers, buffer);
|
||||
|
||||
return GST_FLOW_OK;
|
||||
}
|
||||
|
||||
/* setup an element for a filter test with mysrcpad and mysinkpad */
|
||||
GstElement *
|
||||
gst_check_setup_element (const gchar * factory)
|
||||
{
|
||||
GstElement *element;
|
||||
|
||||
GST_DEBUG ("setup_element");
|
||||
|
||||
element = gst_element_factory_make (factory, factory);
|
||||
fail_if (element == NULL, "Could not create a %s", factory);
|
||||
ASSERT_OBJECT_REFCOUNT (element, factory, 1);
|
||||
return element;
|
||||
}
|
||||
|
||||
void
|
||||
gst_check_teardown_element (GstElement * element)
|
||||
{
|
||||
GST_DEBUG ("teardown_element");
|
||||
|
||||
fail_unless (gst_element_set_state (element, GST_STATE_NULL) ==
|
||||
GST_STATE_SUCCESS, "could not set to null");
|
||||
ASSERT_OBJECT_REFCOUNT (element, "element", 1);
|
||||
gst_object_unref (element);
|
||||
}
|
||||
|
||||
GstPad *
|
||||
gst_check_setup_src_pad (GstElement * element,
|
||||
GstStaticPadTemplate * srctemplate, GstCaps * caps)
|
||||
{
|
||||
GstPad *srcpad, *sinkpad;
|
||||
|
||||
/* sending pad */
|
||||
srcpad =
|
||||
gst_pad_new_from_template (gst_static_pad_template_get (srctemplate),
|
||||
"src");
|
||||
fail_if (srcpad == NULL, "Could not create a srcpad");
|
||||
ASSERT_OBJECT_REFCOUNT (srcpad, "srcpad", 1);
|
||||
|
||||
sinkpad = gst_element_get_pad (element, "sink");
|
||||
fail_if (sinkpad == NULL, "Could not get sink pad from %s",
|
||||
GST_ELEMENT_NAME (element));
|
||||
ASSERT_OBJECT_REFCOUNT (sinkpad, "sinkpad", 2);
|
||||
gst_pad_set_caps (srcpad, caps);
|
||||
fail_unless (gst_pad_link (srcpad, sinkpad) == GST_PAD_LINK_OK,
|
||||
"Could not link source and %s sink pads", GST_ELEMENT_NAME (element));
|
||||
gst_object_unref (sinkpad); /* because we got it higher up */
|
||||
ASSERT_OBJECT_REFCOUNT (sinkpad, "sinkpad", 1);
|
||||
|
||||
return srcpad;
|
||||
}
|
||||
|
||||
void
|
||||
gst_check_teardown_src_pad (GstElement * element)
|
||||
{
|
||||
GstPad *srcpad, *sinkpad;
|
||||
|
||||
/* clean up floating src pad */
|
||||
sinkpad = gst_element_get_pad (element, "sink");
|
||||
ASSERT_OBJECT_REFCOUNT (sinkpad, "sinkpad", 2);
|
||||
srcpad = gst_pad_get_peer (sinkpad);
|
||||
|
||||
gst_pad_unlink (srcpad, sinkpad);
|
||||
|
||||
/* pad refs held by both creator and this function (through _get) */
|
||||
ASSERT_OBJECT_REFCOUNT (sinkpad, "sinkpad", 2);
|
||||
gst_object_unref (sinkpad);
|
||||
/* one more ref is held by element itself */
|
||||
|
||||
/* pad refs held by both creator and this function (through _get_peer) */
|
||||
ASSERT_OBJECT_REFCOUNT (srcpad, "srcpad", 2);
|
||||
gst_object_unref (srcpad);
|
||||
gst_object_unref (srcpad);
|
||||
}
|
||||
|
||||
GstPad *
|
||||
gst_check_setup_sink_pad (GstElement * element, GstStaticPadTemplate * template,
|
||||
GstCaps * caps)
|
||||
{
|
||||
GstPad *srcpad, *sinkpad;
|
||||
|
||||
/* receiving pad */
|
||||
sinkpad =
|
||||
gst_pad_new_from_template (gst_static_pad_template_get (template),
|
||||
"sink");
|
||||
fail_if (sinkpad == NULL, "Could not create a sinkpad");
|
||||
|
||||
srcpad = gst_element_get_pad (element, "src");
|
||||
fail_if (srcpad == NULL, "Could not get source pad from %s",
|
||||
GST_ELEMENT_NAME (element));
|
||||
gst_pad_set_caps (sinkpad, caps);
|
||||
gst_pad_set_chain_function (sinkpad, gst_check_chain_func);
|
||||
|
||||
fail_unless (gst_pad_link (srcpad, sinkpad) == GST_PAD_LINK_OK,
|
||||
"Could not link %s source and sink pads", GST_ELEMENT_NAME (element));
|
||||
gst_object_unref (srcpad); /* because we got it higher up */
|
||||
ASSERT_OBJECT_REFCOUNT (srcpad, "srcpad", 1);
|
||||
|
||||
return sinkpad;
|
||||
}
|
||||
|
||||
void
|
||||
gst_check_teardown_sink_pad (GstElement * element)
|
||||
{
|
||||
GstPad *srcpad, *sinkpad;
|
||||
|
||||
/* clean up floating sink pad */
|
||||
srcpad = gst_element_get_pad (element, "src");
|
||||
sinkpad = gst_pad_get_peer (srcpad);
|
||||
gst_pad_unlink (srcpad, sinkpad);
|
||||
|
||||
/* pad refs held by both creator and this function (through _get_pad) */
|
||||
ASSERT_OBJECT_REFCOUNT (srcpad, "srcpad", 2);
|
||||
gst_object_unref (srcpad);
|
||||
/* one more ref is held by element itself */
|
||||
|
||||
/* pad refs held by both creator and this function (through _get_peer) */
|
||||
ASSERT_OBJECT_REFCOUNT (sinkpad, "sinkpad", 2);
|
||||
gst_object_unref (sinkpad);
|
||||
gst_object_unref (sinkpad);
|
||||
}
|
||||
|
|
|
@ -43,10 +43,25 @@ extern gboolean _gst_check_threads_running;
|
|||
extern gboolean _gst_check_raised_critical;
|
||||
extern gboolean _gst_check_expecting_log;
|
||||
|
||||
/* global variables used in test methods */
|
||||
GList * buffers;
|
||||
|
||||
void gst_check_init (int *argc, char **argv[]);
|
||||
|
||||
GstFlowReturn gst_check_chain_func (GstPad *pad, GstBuffer *buffer);
|
||||
|
||||
void gst_check_message_error (GstMessage *message, GstMessageType type, GQuark domain, gint code);
|
||||
|
||||
GstElement * gst_check_setup_element (const gchar *factory);
|
||||
void gst_check_teardown_element (GstElement *element);
|
||||
GstPad * gst_check_setup_src_pad (GstElement *element,
|
||||
GstStaticPadTemplate *template, GstCaps *caps);
|
||||
void gst_check_teardown_src_pad (GstElement *element);
|
||||
GstPad * gst_check_setup_sink_pad (GstElement *element,
|
||||
GstStaticPadTemplate *template, GstCaps *caps);
|
||||
void gst_check_teardown_sink_pad (GstElement *element);
|
||||
|
||||
|
||||
#define fail_unless_message_error(msg, domain, code) \
|
||||
gst_check_message_error (msg, GST_MESSAGE_ERROR, \
|
||||
GST_ ## domain ## _ERROR, GST_ ## domain ## _ERROR_ ## code)
|
||||
|
@ -71,6 +86,15 @@ G_STMT_START { \
|
|||
"'" #a "' (%d) is not equal to '" #b"' (%d)", first, second); \
|
||||
} G_STMT_END;
|
||||
|
||||
#define fail_unless_equals_string(a, b) \
|
||||
G_STMT_START { \
|
||||
gchar * first = a; \
|
||||
gchar * second = b; \
|
||||
fail_unless(strcmp (first, second) == 0, \
|
||||
"'" #a "' (%s) is not equal to '" #b"' (%s)", first, second); \
|
||||
} G_STMT_END;
|
||||
|
||||
|
||||
/***
|
||||
* thread test macros and variables
|
||||
*/
|
||||
|
@ -179,7 +203,7 @@ G_STMT_START { \
|
|||
int rc; \
|
||||
rc = GST_OBJECT_REFCOUNT_VALUE (object); \
|
||||
fail_unless (rc == value, \
|
||||
name " refcount is %d instead of %d", rc, value);\
|
||||
"%s refcount is %d instead of %d", name, rc, value); \
|
||||
} G_STMT_END
|
||||
|
||||
#define ASSERT_CAPS_REFCOUNT(caps, name, value) \
|
||||
|
|
|
@ -78,6 +78,7 @@ gst_libs_controller_LDADD = $(GST_OBJ_LIBS) \
|
|||
# valgrind testing
|
||||
# these just need valgrind fixing, period
|
||||
TESTS_TO_FIX = \
|
||||
gst-libs/controller \
|
||||
pipelines/cleanup \
|
||||
pipelines/simple_launch_lines
|
||||
|
||||
|
|
|
@ -24,22 +24,15 @@
|
|||
|
||||
#include <gst/check/gstcheck.h>
|
||||
|
||||
GList *buffers = NULL;
|
||||
gboolean have_eos = FALSE;
|
||||
|
||||
GstPad *mysinkpad;
|
||||
|
||||
static GstStaticPadTemplate sinktemplate = GST_STATIC_PAD_TEMPLATE ("sink",
|
||||
GST_PAD_SINK,
|
||||
GST_PAD_ALWAYS,
|
||||
GST_STATIC_CAPS_ANY);
|
||||
|
||||
GstFlowReturn
|
||||
chain_func (GstPad * pad, GstBuffer * buffer)
|
||||
{
|
||||
buffers = g_list_append (buffers, buffer);
|
||||
|
||||
return GST_FLOW_OK;
|
||||
}
|
||||
|
||||
gboolean
|
||||
event_func (GstPad * pad, GstEvent * event)
|
||||
{
|
||||
|
@ -60,52 +53,20 @@ event_func (GstPad * pad, GstEvent * event)
|
|||
GstElement *
|
||||
setup_fakesrc ()
|
||||
{
|
||||
GstElement *src;
|
||||
GstPad *srcpad, *sinkpad;
|
||||
GstElement *fakesrc;
|
||||
|
||||
src = gst_element_factory_make ("fakesrc", "src");
|
||||
fail_if (src == NULL, "Could not create a fakesrc");
|
||||
|
||||
sinkpad =
|
||||
gst_pad_new_from_template (gst_static_pad_template_get (&sinktemplate),
|
||||
"sink");
|
||||
fail_if (sinkpad == NULL, "Could not create a sinkpad");
|
||||
|
||||
srcpad = gst_element_get_pad (src, "src");
|
||||
fail_if (srcpad == NULL, "Could not get source pad from fakesrc");
|
||||
gst_pad_set_caps (sinkpad, NULL);
|
||||
gst_pad_set_chain_function (sinkpad, chain_func);
|
||||
gst_pad_set_event_function (sinkpad, event_func);
|
||||
|
||||
fail_unless (gst_pad_link (srcpad, sinkpad) == GST_PAD_LINK_OK,
|
||||
"Could not link source and sink pads");
|
||||
return src;
|
||||
GST_DEBUG ("setup_fakesrc");
|
||||
fakesrc = gst_check_setup_element ("fakesrc");
|
||||
mysinkpad = gst_check_setup_sink_pad (fakesrc, &sinktemplate, NULL);
|
||||
gst_pad_set_event_function (mysinkpad, event_func);
|
||||
return fakesrc;
|
||||
}
|
||||
|
||||
void
|
||||
cleanup_fakesrc (GstElement * src)
|
||||
cleanup_fakesrc (GstElement * fakesrc)
|
||||
{
|
||||
GstPad *srcpad, *sinkpad;
|
||||
|
||||
fail_unless (gst_element_set_state (src, GST_STATE_NULL) == GST_STATE_SUCCESS,
|
||||
"could not set to null");
|
||||
|
||||
srcpad = gst_element_get_pad (src, "src");
|
||||
sinkpad = gst_pad_get_peer (srcpad);
|
||||
|
||||
ASSERT_OBJECT_REFCOUNT (src, "src", 1);
|
||||
gst_object_unref (src);
|
||||
|
||||
gst_pad_unlink (srcpad, sinkpad);
|
||||
|
||||
/* pad refs held by both creator and this function (through _get) */
|
||||
ASSERT_OBJECT_REFCOUNT (srcpad, "srcpad", 2);
|
||||
gst_object_unref (srcpad);
|
||||
gst_object_unref (srcpad);
|
||||
|
||||
ASSERT_OBJECT_REFCOUNT (sinkpad, "sinkpad", 2);
|
||||
gst_object_unref (sinkpad);
|
||||
gst_object_unref (sinkpad);
|
||||
gst_check_teardown_sink_pad (fakesrc);
|
||||
gst_check_teardown_element (fakesrc);
|
||||
}
|
||||
|
||||
GST_START_TEST (test_num_buffers)
|
||||
|
|
|
@ -42,15 +42,6 @@ static GstStaticPadTemplate srctemplate = GST_STATIC_PAD_TEMPLATE ("src",
|
|||
GST_PAD_ALWAYS,
|
||||
GST_STATIC_CAPS_ANY);
|
||||
|
||||
GstFlowReturn
|
||||
chain_func (GstPad * pad, GstBuffer * buffer)
|
||||
{
|
||||
GST_DEBUG ("chain_func: received buffer %p", buffer);
|
||||
buffers = g_list_append (buffers, buffer);
|
||||
|
||||
return GST_FLOW_OK;
|
||||
}
|
||||
|
||||
gboolean
|
||||
event_func (GstPad * pad, GstEvent * event)
|
||||
{
|
||||
|
@ -72,90 +63,25 @@ GstElement *
|
|||
setup_identity ()
|
||||
{
|
||||
GstElement *identity;
|
||||
GstPad *srcpad, *sinkpad;
|
||||
|
||||
GST_DEBUG ("setup_identity");
|
||||
|
||||
identity = gst_element_factory_make ("identity", "identity");
|
||||
fail_if (identity == NULL, "Could not create a identity");
|
||||
|
||||
/* sending pad */
|
||||
mysrcpad =
|
||||
gst_pad_new_from_template (gst_static_pad_template_get (&srctemplate),
|
||||
"src");
|
||||
fail_if (mysrcpad == NULL, "Could not create a mysrcpad");
|
||||
ASSERT_OBJECT_REFCOUNT (mysrcpad, "mysrcpad", 1);
|
||||
|
||||
sinkpad = gst_element_get_pad (identity, "sink");
|
||||
fail_if (sinkpad == NULL, "Could not get source pad from identity");
|
||||
ASSERT_OBJECT_REFCOUNT (sinkpad, "sinkpad", 2);
|
||||
gst_pad_set_caps (mysrcpad, NULL);
|
||||
fail_unless (gst_pad_link (mysrcpad, sinkpad) == GST_PAD_LINK_OK,
|
||||
"Could not link source and identity sink pads");
|
||||
gst_object_unref (sinkpad); /* because we got it higher up */
|
||||
ASSERT_OBJECT_REFCOUNT (sinkpad, "sinkpad", 1);
|
||||
|
||||
/* receiving pad */
|
||||
mysinkpad =
|
||||
gst_pad_new_from_template (gst_static_pad_template_get (&sinktemplate),
|
||||
"sink");
|
||||
fail_if (mysinkpad == NULL, "Could not create a mysinkpad");
|
||||
|
||||
srcpad = gst_element_get_pad (identity, "src");
|
||||
fail_if (srcpad == NULL, "Could not get source pad from identity");
|
||||
gst_pad_set_caps (mysinkpad, NULL);
|
||||
gst_pad_set_chain_function (mysinkpad, chain_func);
|
||||
identity = gst_check_setup_element ("identity");
|
||||
mysrcpad = gst_check_setup_src_pad (identity, &srctemplate, NULL);
|
||||
mysinkpad = gst_check_setup_sink_pad (identity, &sinktemplate, NULL);
|
||||
gst_pad_set_event_function (mysinkpad, event_func);
|
||||
|
||||
fail_unless (gst_pad_link (srcpad, mysinkpad) == GST_PAD_LINK_OK,
|
||||
"Could not link identity source and mysink pads");
|
||||
gst_object_unref (srcpad); /* because we got it higher up */
|
||||
ASSERT_OBJECT_REFCOUNT (srcpad, "srcpad", 1);
|
||||
|
||||
return identity;
|
||||
}
|
||||
|
||||
void
|
||||
cleanup_identity (GstElement * identity)
|
||||
{
|
||||
GstPad *srcpad, *sinkpad;
|
||||
|
||||
GST_DEBUG ("cleanup_identity");
|
||||
|
||||
fail_unless (gst_element_set_state (identity, GST_STATE_NULL) ==
|
||||
GST_STATE_SUCCESS, "could not set to null");
|
||||
ASSERT_OBJECT_REFCOUNT (identity, "identity", 1);
|
||||
|
||||
/* clean up floating src pad */
|
||||
sinkpad = gst_element_get_pad (identity, "sink");
|
||||
ASSERT_OBJECT_REFCOUNT (sinkpad, "sinkpad", 2);
|
||||
|
||||
gst_pad_unlink (mysrcpad, sinkpad);
|
||||
|
||||
/* pad refs held by both creator and this function (through _get) */
|
||||
ASSERT_OBJECT_REFCOUNT (mysrcpad, "srcpad", 1);
|
||||
gst_object_unref (mysrcpad);
|
||||
mysrcpad = NULL;
|
||||
|
||||
ASSERT_OBJECT_REFCOUNT (sinkpad, "sinkpad", 2);
|
||||
gst_object_unref (sinkpad);
|
||||
/* one more ref is held by identity itself */
|
||||
|
||||
/* clean up floating sink pad */
|
||||
srcpad = gst_element_get_pad (identity, "src");
|
||||
gst_pad_unlink (srcpad, mysinkpad);
|
||||
|
||||
/* pad refs held by both creator and this function (through _get) */
|
||||
ASSERT_OBJECT_REFCOUNT (srcpad, "srcpad", 2);
|
||||
gst_object_unref (srcpad);
|
||||
/* one more ref is held by identity itself */
|
||||
|
||||
ASSERT_OBJECT_REFCOUNT (mysinkpad, "mysinkpad", 1);
|
||||
gst_object_unref (mysinkpad);
|
||||
mysinkpad = NULL;
|
||||
|
||||
ASSERT_OBJECT_REFCOUNT (identity, "identity", 1);
|
||||
gst_object_unref (identity);
|
||||
gst_check_teardown_src_pad (identity);
|
||||
gst_check_teardown_sink_pad (identity);
|
||||
gst_check_teardown_element (identity);
|
||||
}
|
||||
|
||||
GST_START_TEST (test_one_buffer)
|
||||
|
|
Loading…
Reference in a new issue