check/gstcheck.h: add macros for checking refcounts on objects and caps

Original commit message from CVS:

* check/gstcheck.h:
add macros for checking refcounts on objects and caps
* check/gst/gstpad.c: (START_TEST), (gst_pad_suite):
add some more unit tests
* gst/gstpad.c: (gst_pad_link_check_compatible_unlocked),
(gst_pad_link_prepare), (gst_pad_link), (gst_pad_get_allowed_caps):
fix leaked refcounts (I hope :)) so unittest works
* gst/gstpad.h:
whitespace removal
This commit is contained in:
Thomas Vander Stichele 2005-06-19 00:52:31 +00:00
parent cb1e56a733
commit 4ae0c46b63
7 changed files with 310 additions and 66 deletions

View file

@ -1,3 +1,15 @@
2005-06-19 Thomas Vander Stichele <thomas at apestaart dot org>
* check/gstcheck.h:
add macros for checking refcounts on objects and caps
* check/gst/gstpad.c: (START_TEST), (gst_pad_suite):
add some more unit tests
* gst/gstpad.c: (gst_pad_link_check_compatible_unlocked),
(gst_pad_link_prepare), (gst_pad_link), (gst_pad_get_allowed_caps):
fix leaked refcounts (I hope :)) so unittest works
* gst/gstpad.h:
whitespace removal
2005-06-19 Thomas Vander Stichele <thomas at apestaart dot org>
* configure.ac: back to HEAD

View file

@ -24,7 +24,7 @@
START_TEST (test_link)
{
GstPad *src, *sink;
GstPadTemplate *srct; //, *sinkt;
GstPadTemplate *srct;
GstPadLinkReturn ret;
gchar *name;
@ -38,7 +38,7 @@ START_TEST (test_link)
sink = gst_pad_new ("sink", GST_PAD_SINK);
fail_if (sink == NULL);
/* linking without templates should fail */
/* linking without templates or caps should fail */
ret = gst_pad_link (src, sink);
fail_unless (ret == GST_PAD_LINK_NOFORMAT);
@ -87,8 +87,103 @@ START_TEST (test_link_unlink_threaded)
}
MAIN_STOP_THREADS ();
}
END_TEST Suite *
gst_pad_suite (void)
END_TEST
START_TEST (test_refcount)
{
GstPad *src, *sink;
GstCaps *caps;
GstPadLinkReturn plr;
sink = gst_pad_new ("sink", GST_PAD_SINK);
fail_if (sink == NULL);
src = gst_pad_new ("src", GST_PAD_SRC);
fail_if (src == NULL);
caps = gst_caps_new_any ();
/* one for me */
ASSERT_CAPS_REFCOUNT (caps, "caps", 1);
gst_pad_set_caps (src, caps);
gst_caps_unref (caps);
gst_pad_set_caps (sink, caps);
gst_caps_unref (caps);
/* one for me and one for each set_caps */
ASSERT_CAPS_REFCOUNT (caps, "caps", 3);
plr = gst_pad_link (src, sink);
fail_unless (GST_PAD_LINK_SUCCESSFUL (plr));
ASSERT_CAPS_REFCOUNT (caps, "caps", 3);
gst_pad_unlink (src, sink);
ASSERT_CAPS_REFCOUNT (caps, "caps", 3);
/* cleanup */
gst_object_unref (GST_OBJECT (src));
gst_object_unref (GST_OBJECT (sink));
ASSERT_CAPS_REFCOUNT (caps, "caps", 1);
gst_caps_unref (caps);
}
END_TEST
START_TEST (test_get_allowed_caps)
{
GstPad *src, *sink;
GstCaps *caps, *gotcaps;
GstBuffer *buffer;
GstPadLinkReturn plr;
int rc;
ASSERT_CRITICAL (gst_pad_get_allowed_caps (NULL));
buffer = gst_buffer_new ();
ASSERT_CRITICAL (gst_pad_get_allowed_caps ((GstPad *) buffer));
gst_buffer_unref (buffer);
sink = gst_pad_new ("sink", GST_PAD_SINK);
ASSERT_CRITICAL (gst_pad_get_allowed_caps (sink));
src = gst_pad_new ("src", GST_PAD_SRC);
fail_if (src == NULL);
caps = gst_pad_get_allowed_caps (src);
fail_unless (caps == NULL);
caps = gst_caps_new_any ();
rc = GST_MINI_OBJECT_REFCOUNT_VALUE (caps);
gst_pad_set_caps (src, caps);
gst_caps_unref (caps);
gst_pad_set_caps (sink, caps);
gst_caps_unref (caps);
ASSERT_CAPS_REFCOUNT (caps, "caps", 3);
plr = gst_pad_link (src, sink);
fail_unless (GST_PAD_LINK_SUCCESSFUL (plr));
gotcaps = gst_pad_get_allowed_caps (src);
fail_if (gotcaps == NULL);
fail_unless (gst_caps_is_equal (gotcaps, caps));
ASSERT_CAPS_REFCOUNT (gotcaps, "gotcaps", 1);
gst_caps_unref (gotcaps);
gst_pad_unlink (src, sink);
/* cleanup */
ASSERT_CAPS_REFCOUNT (caps, "caps", 3);
ASSERT_OBJECT_REFCOUNT (src, "src", 1);
ASSERT_OBJECT_REFCOUNT (sink, "sink", 1);
gst_object_unref (GST_OBJECT (src));
gst_object_unref (GST_OBJECT (sink));
ASSERT_CAPS_REFCOUNT (caps, "caps", 1);
gst_caps_unref (caps);
}
END_TEST Suite * gst_pad_suite (void)
{
Suite *s = suite_create ("GstPad");
TCase *tc_chain = tcase_create ("general");
@ -98,6 +193,8 @@ gst_pad_suite (void)
suite_add_tcase (s, tc_chain);
tcase_add_test (tc_chain, test_link);
tcase_add_test (tc_chain, test_refcount);
tcase_add_test (tc_chain, test_get_allowed_caps);
tcase_add_test (tc_chain, test_link_unlink_threaded);
return s;
}

View file

@ -144,6 +144,22 @@ G_STMT_START { \
_gst_check_expecting_log = FALSE; \
} G_STMT_END
#define ASSERT_OBJECT_REFCOUNT(object, name, value) \
G_STMT_START { \
int rc; \
rc = GST_OBJECT_REFCOUNT_VALUE (object); \
fail_unless (rc == value, \
name " refcount is %d instead of %d", rc, value);\
} G_STMT_END
#define ASSERT_CAPS_REFCOUNT(caps, name, value) \
G_STMT_START { \
int rc; \
rc = GST_MINI_OBJECT_REFCOUNT_VALUE (caps); \
fail_unless (rc == value, \
name " refcount is %d instead of %d", rc, value);\
} G_STMT_END
#endif /* __GST_CHECK_H__ */

View file

@ -1221,6 +1221,9 @@ gst_pad_link_check_compatible_unlocked (GstPad * src, GstPad * sink)
GstCaps *icaps;
icaps = gst_caps_intersect (srccaps, sinkcaps);
gst_caps_unref (srccaps);
gst_caps_unref (sinkcaps);
GST_CAT_DEBUG (GST_CAT_CAPS,
"intersection caps %p %" GST_PTR_FORMAT, icaps, icaps);
@ -1233,10 +1236,10 @@ gst_pad_link_check_compatible_unlocked (GstPad * src, GstPad * sink)
/* FIXME leftover from an attempt at refactoring... */
/* call with the two pads unlocked */
static GstPadLinkReturn
gst_pad_link_prepare (GstPad * srcpad, GstPad * sinkpad)
{
/* generic checks */
g_return_val_if_fail (GST_IS_PAD (srcpad), GST_PAD_LINK_REFUSED);
g_return_val_if_fail (GST_IS_PAD (sinkpad), GST_PAD_LINK_REFUSED);
@ -1327,6 +1330,7 @@ gst_pad_link (GstPad * srcpad, GstPad * sinkpad)
{
GstPadLinkReturn result;
/* prepare will also lock the two pads */
result = gst_pad_link_prepare (srcpad, sinkpad);
if (result != GST_PAD_LINK_OK)
@ -1358,7 +1362,7 @@ gst_pad_link (GstPad * srcpad, GstPad * sinkpad)
GST_UNLOCK (sinkpad);
GST_UNLOCK (srcpad);
/* fire off a signal to each of the pads telling them
/* fire off a signal to each of the pads telling them
* that they've been linked */
g_signal_emit (G_OBJECT (srcpad), gst_pad_signals[PAD_LINKED], 0, sinkpad);
g_signal_emit (G_OBJECT (sinkpad), gst_pad_signals[PAD_LINKED], 0, srcpad);
@ -1417,6 +1421,7 @@ gst_pad_get_pad_template (GstPad * pad)
/* should be called with the pad LOCK held */
/* refs the caps, so caller is responsible for getting it unreffed */
static GstCaps *
gst_pad_get_caps_unlocked (GstPad * pad)
{
@ -1496,7 +1501,7 @@ done:
*
* Gets the capabilities of this pad.
*
* Returns: the #GstCaps of this pad. This function returns a new caps, so use
* Returns: the #GstCaps of this pad. This function returns a new caps, so use
* gst_caps_unref to get rid of it.
*
* MT safe.
@ -1861,12 +1866,12 @@ gst_pad_get_peer (GstPad * pad)
* gst_pad_get_allowed_caps:
* @srcpad: a #GstPad, it must a a source pad.
*
* Gets the capabilities of the allowed media types that can flow through @pad
* and its peer. The pad must be a source pad.
* Gets the capabilities of the allowed media types that can flow through
* @srcpad and its peer. The pad must be a source pad.
* The caller must free the resulting caps.
*
* Returns: the allowed #GstCaps of the pad link. Free the caps when
* you no longer need it. This function returns NULL when the @pad has no
* you no longer need it. This function returns NULL when the @srcpad has no
* peer.
*
* MT safe.
@ -1880,10 +1885,12 @@ gst_pad_get_allowed_caps (GstPad * srcpad)
GstPad *peer;
g_return_val_if_fail (GST_IS_PAD (srcpad), NULL);
g_return_val_if_fail (GST_PAD_IS_SRC (srcpad), NULL);
GST_LOCK (srcpad);
if (G_UNLIKELY ((peer = GST_PAD_PEER (srcpad)) == NULL))
peer = GST_PAD_PEER (srcpad);
if (G_UNLIKELY (peer == NULL))
goto no_peer;
GST_CAT_DEBUG (GST_CAT_PROPERTIES, "%s:%s: getting allowed caps",
@ -1918,15 +1925,15 @@ no_peer:
* gst_pad_get_negotiated_caps:
* @pad: a #GstPad.
*
* Gets the capabilities of the media type that currently flows through @pad
* Gets the capabilities of the media type that currently flows through @pad
* and its peer.
*
* This function can be used on both src and sinkpads. Note that srcpads are
* always negotiated before sinkpads so it is possible that the negotiated caps
* always negotiated before sinkpads so it is possible that the negotiated caps
* on the srcpad do not match the negotiated caps of the peer.
*
* Returns: the negotiated #GstCaps of the pad link. Free the caps when
* you no longer need it. This function returns NULL when the @pad has no
* you no longer need it. This function returns NULL when the @pad has no
* peer or is not negotiated yet.
*
* MT safe.

View file

@ -72,9 +72,9 @@ typedef enum {
#define GST_PAD_LINK_SUCCESSFUL(ret) ((ret) >= GST_PAD_LINK_OK)
typedef enum {
GST_FLOW_OK = 0, /* data passing was ok */
GST_FLOW_OK = 0, /* data passing was ok */
GST_FLOW_RESEND = 1, /* resend buffer, possibly with new caps */
GST_FLOW_ERROR = -1, /* some (fatal) error occured */
GST_FLOW_ERROR = -1, /* some (fatal) error occured */
GST_FLOW_NOT_CONNECTED = -2, /* pad is not connected */
GST_FLOW_NOT_NEGOTIATED = -3, /* pad is not negotiated */
GST_FLOW_WRONG_STATE = -4, /* pad is in wrong state */
@ -90,19 +90,18 @@ typedef enum {
#define GST_PAD_MODE_ACTIVATE(mode) ((mode) != GST_ACTIVATE_NONE)
/* pad states */
typedef gboolean (*GstPadActivateFunction) (GstPad *pad, GstActivateMode mode);
typedef gboolean (*GstPadActivateFunction) (GstPad *pad, GstActivateMode mode);
/* data passing */
typedef GstFlowReturn (*GstPadChainFunction) (GstPad *pad, GstBuffer *buffer);
typedef GstFlowReturn (*GstPadGetRangeFunction) (GstPad *pad, guint64 offset,
typedef GstFlowReturn (*GstPadChainFunction) (GstPad *pad, GstBuffer *buffer);
typedef GstFlowReturn (*GstPadGetRangeFunction) (GstPad *pad, guint64 offset,
guint length, GstBuffer **buffer);
typedef gboolean (*GstPadEventFunction) (GstPad *pad, GstEvent *event);
/* deprecate me, check range should use seeking query, loop function is internal */
typedef gboolean (*GstPadCheckGetRangeFunction) (GstPad *pad);
typedef void (*GstPadLoopFunction) (GstPad *pad);
typedef gboolean (*GstPadCheckGetRangeFunction) (GstPad *pad);
typedef void (*GstPadLoopFunction) (GstPad *pad);
/* internal links */
typedef GList* (*GstPadIntLinkFunction) (GstPad *pad);
@ -112,20 +111,20 @@ typedef const GstQueryType* (*GstPadQueryTypeFunction) (GstPad *pad);
typedef gboolean (*GstPadQueryFunction) (GstPad *pad, GstQuery *query);
/* linking */
typedef GstPadLinkReturn (*GstPadLinkFunction) (GstPad *pad, GstPad *peer);
typedef void (*GstPadUnlinkFunction) (GstPad *pad);
typedef GstPadLinkReturn (*GstPadLinkFunction) (GstPad *pad, GstPad *peer);
typedef void (*GstPadUnlinkFunction) (GstPad *pad);
/* caps nego */
typedef GstCaps* (*GstPadGetCapsFunction) (GstPad *pad);
typedef gboolean (*GstPadSetCapsFunction) (GstPad *pad, GstCaps *caps);
typedef gboolean (*GstPadAcceptCapsFunction) (GstPad *pad, GstCaps *caps);
typedef GstCaps* (*GstPadFixateCapsFunction) (GstPad *pad, GstCaps *caps);
typedef GstFlowReturn (*GstPadBufferAllocFunction) (GstPad *pad, guint64 offset, guint size,
typedef GstCaps* (*GstPadGetCapsFunction) (GstPad *pad);
typedef gboolean (*GstPadSetCapsFunction) (GstPad *pad, GstCaps *caps);
typedef gboolean (*GstPadAcceptCapsFunction) (GstPad *pad, GstCaps *caps);
typedef GstCaps* (*GstPadFixateCapsFunction) (GstPad *pad, GstCaps *caps);
typedef GstFlowReturn (*GstPadBufferAllocFunction) (GstPad *pad, guint64 offset, guint size,
GstCaps *caps, GstBuffer **buf);
/* misc */
typedef gboolean (*GstPadDispatcherFunction) (GstPad *pad, gpointer data);
typedef gboolean (*GstPadDispatcherFunction) (GstPad *pad, gpointer data);
typedef void (*GstPadBlockCallback) (GstPad *pad, gboolean blocked, gpointer user_data);
typedef void (*GstPadBlockCallback) (GstPad *pad, gboolean blocked, gpointer user_data);
typedef enum {
GST_PAD_UNKNOWN,
@ -143,14 +142,14 @@ typedef enum {
} GstPadFlags;
struct _GstPad {
GstObject object;
GstObject object;
gpointer element_private;
gpointer element_private;
GstPadTemplate *padtemplate; /* the template for this pad */
GstPadTemplate *padtemplate;
/* direction cannot change after creating the pad */
GstPadDirection direction;
GstPadDirection direction;
/*< public >*/ /* with STREAM_LOCK */
/* streaming rec_lock */
@ -167,26 +166,26 @@ struct _GstPad {
gpointer block_data;
/* the pad capabilities */
GstCaps *caps;
GstPadGetCapsFunction getcapsfunc;
GstPadSetCapsFunction setcapsfunc;
GstPadAcceptCapsFunction acceptcapsfunc;
GstPadFixateCapsFunction fixatecapsfunc;
GstCaps *caps;
GstPadGetCapsFunction getcapsfunc;
GstPadSetCapsFunction setcapsfunc;
GstPadAcceptCapsFunction acceptcapsfunc;
GstPadFixateCapsFunction fixatecapsfunc;
GstPadActivateFunction activatefunc;
/* pad link */
GstPadLinkFunction linkfunc;
GstPadUnlinkFunction unlinkfunc;
GstPad *peer;
GstPadLinkFunction linkfunc;
GstPadUnlinkFunction unlinkfunc;
GstPad *peer;
gpointer sched_private;
gpointer sched_private;
/* data transport functions */
GstPadLoopFunction loopfunc;
GstPadChainFunction chainfunc;
GstPadCheckGetRangeFunction checkgetrangefunc;
GstPadGetRangeFunction getrangefunc;
GstPadLoopFunction loopfunc;
GstPadChainFunction chainfunc;
GstPadCheckGetRangeFunction checkgetrangefunc;
GstPadGetRangeFunction getrangefunc;
GstPadEventFunction eventfunc;
GstActivateMode mode;
@ -212,7 +211,7 @@ struct _GstPadClass {
/* signal callbacks */
void (*linked) (GstPad *pad, GstPad *peer);
void (*unlinked) (GstPad *pad, GstPad *peer);
void (*request_link) (GstPad *pad);
void (*request_link) (GstPad *pad);
/*< private >*/
gpointer _gst_reserved[GST_PADDING];
@ -371,7 +370,7 @@ gpointer gst_pad_get_element_private (GstPad *pad);
GstPadTemplate* gst_pad_get_pad_template (GstPad *pad);
void gst_pad_set_bufferalloc_function (GstPad *pad, GstPadBufferAllocFunction bufalloc);
GstFlowReturn gst_pad_alloc_buffer (GstPad *pad, guint64 offset, gint size,
GstFlowReturn gst_pad_alloc_buffer (GstPad *pad, guint64 offset, gint size,
GstCaps *caps, GstBuffer **buf);
/* data passing setup functions */
@ -386,7 +385,7 @@ void gst_pad_set_event_function (GstPad *pad, GstPadEventFunction event);
void gst_pad_set_link_function (GstPad *pad, GstPadLinkFunction link);
void gst_pad_set_unlink_function (GstPad *pad, GstPadUnlinkFunction unlink);
GstPadLinkReturn gst_pad_link (GstPad *srcpad, GstPad *sinkpad);
GstPadLinkReturn gst_pad_link (GstPad *srcpad, GstPad *sinkpad);
gboolean gst_pad_unlink (GstPad *srcpad, GstPad *sinkpad);
gboolean gst_pad_is_linked (GstPad *pad);
@ -401,17 +400,17 @@ void gst_pad_set_setcaps_function (GstPad *pad, GstPadSetCapsFunction setcaps
G_CONST_RETURN GstCaps* gst_pad_get_pad_template_caps (GstPad *pad);
/* capsnego function for connected/unconnected pads */
GstCaps * gst_pad_get_caps (GstPad * pad);
GstCaps* gst_pad_fixate_caps (GstPad * pad, GstCaps *caps);
gboolean gst_pad_accept_caps (GstPad * pad, GstCaps *caps);
gboolean gst_pad_set_caps (GstPad * pad, GstCaps *caps);
GstCaps * gst_pad_get_caps (GstPad * pad);
GstCaps* gst_pad_fixate_caps (GstPad * pad, GstCaps *caps);
gboolean gst_pad_accept_caps (GstPad * pad, GstCaps *caps);
gboolean gst_pad_set_caps (GstPad * pad, GstCaps *caps);
GstCaps * gst_pad_peer_get_caps (GstPad * pad);
gboolean gst_pad_peer_accept_caps (GstPad * pad, GstCaps *caps);
GstCaps * gst_pad_peer_get_caps (GstPad * pad);
gboolean gst_pad_peer_accept_caps (GstPad * pad, GstCaps *caps);
/* capsnego for connected pads */
GstCaps * gst_pad_get_allowed_caps (GstPad * srcpad);
GstCaps * gst_pad_get_negotiated_caps (GstPad * pad);
GstCaps * gst_pad_get_allowed_caps (GstPad * srcpad);
GstCaps * gst_pad_get_negotiated_caps (GstPad * pad);
/* data passing functions to peer */
GstFlowReturn gst_pad_push (GstPad *pad, GstBuffer *buffer);
@ -428,10 +427,10 @@ GstFlowReturn gst_pad_get_range (GstPad *pad, guint64 offset, guint size,
gboolean gst_pad_send_event (GstPad *pad, GstEvent *event);
/* pad tasks */
gboolean gst_pad_start_task (GstPad *pad, GstTaskFunction func,
gboolean gst_pad_start_task (GstPad *pad, GstTaskFunction func,
gpointer data);
gboolean gst_pad_pause_task (GstPad *pad);
gboolean gst_pad_stop_task (GstPad *pad);
gboolean gst_pad_pause_task (GstPad *pad);
gboolean gst_pad_stop_task (GstPad *pad);
/* internal links */
void gst_pad_set_internal_link_function (GstPad *pad, GstPadIntLinkFunction intlink);

View file

@ -24,7 +24,7 @@
START_TEST (test_link)
{
GstPad *src, *sink;
GstPadTemplate *srct; //, *sinkt;
GstPadTemplate *srct;
GstPadLinkReturn ret;
gchar *name;
@ -38,7 +38,7 @@ START_TEST (test_link)
sink = gst_pad_new ("sink", GST_PAD_SINK);
fail_if (sink == NULL);
/* linking without templates should fail */
/* linking without templates or caps should fail */
ret = gst_pad_link (src, sink);
fail_unless (ret == GST_PAD_LINK_NOFORMAT);
@ -87,8 +87,103 @@ START_TEST (test_link_unlink_threaded)
}
MAIN_STOP_THREADS ();
}
END_TEST Suite *
gst_pad_suite (void)
END_TEST
START_TEST (test_refcount)
{
GstPad *src, *sink;
GstCaps *caps;
GstPadLinkReturn plr;
sink = gst_pad_new ("sink", GST_PAD_SINK);
fail_if (sink == NULL);
src = gst_pad_new ("src", GST_PAD_SRC);
fail_if (src == NULL);
caps = gst_caps_new_any ();
/* one for me */
ASSERT_CAPS_REFCOUNT (caps, "caps", 1);
gst_pad_set_caps (src, caps);
gst_caps_unref (caps);
gst_pad_set_caps (sink, caps);
gst_caps_unref (caps);
/* one for me and one for each set_caps */
ASSERT_CAPS_REFCOUNT (caps, "caps", 3);
plr = gst_pad_link (src, sink);
fail_unless (GST_PAD_LINK_SUCCESSFUL (plr));
ASSERT_CAPS_REFCOUNT (caps, "caps", 3);
gst_pad_unlink (src, sink);
ASSERT_CAPS_REFCOUNT (caps, "caps", 3);
/* cleanup */
gst_object_unref (GST_OBJECT (src));
gst_object_unref (GST_OBJECT (sink));
ASSERT_CAPS_REFCOUNT (caps, "caps", 1);
gst_caps_unref (caps);
}
END_TEST
START_TEST (test_get_allowed_caps)
{
GstPad *src, *sink;
GstCaps *caps, *gotcaps;
GstBuffer *buffer;
GstPadLinkReturn plr;
int rc;
ASSERT_CRITICAL (gst_pad_get_allowed_caps (NULL));
buffer = gst_buffer_new ();
ASSERT_CRITICAL (gst_pad_get_allowed_caps ((GstPad *) buffer));
gst_buffer_unref (buffer);
sink = gst_pad_new ("sink", GST_PAD_SINK);
ASSERT_CRITICAL (gst_pad_get_allowed_caps (sink));
src = gst_pad_new ("src", GST_PAD_SRC);
fail_if (src == NULL);
caps = gst_pad_get_allowed_caps (src);
fail_unless (caps == NULL);
caps = gst_caps_new_any ();
rc = GST_MINI_OBJECT_REFCOUNT_VALUE (caps);
gst_pad_set_caps (src, caps);
gst_caps_unref (caps);
gst_pad_set_caps (sink, caps);
gst_caps_unref (caps);
ASSERT_CAPS_REFCOUNT (caps, "caps", 3);
plr = gst_pad_link (src, sink);
fail_unless (GST_PAD_LINK_SUCCESSFUL (plr));
gotcaps = gst_pad_get_allowed_caps (src);
fail_if (gotcaps == NULL);
fail_unless (gst_caps_is_equal (gotcaps, caps));
ASSERT_CAPS_REFCOUNT (gotcaps, "gotcaps", 1);
gst_caps_unref (gotcaps);
gst_pad_unlink (src, sink);
/* cleanup */
ASSERT_CAPS_REFCOUNT (caps, "caps", 3);
ASSERT_OBJECT_REFCOUNT (src, "src", 1);
ASSERT_OBJECT_REFCOUNT (sink, "sink", 1);
gst_object_unref (GST_OBJECT (src));
gst_object_unref (GST_OBJECT (sink));
ASSERT_CAPS_REFCOUNT (caps, "caps", 1);
gst_caps_unref (caps);
}
END_TEST Suite * gst_pad_suite (void)
{
Suite *s = suite_create ("GstPad");
TCase *tc_chain = tcase_create ("general");
@ -98,6 +193,8 @@ gst_pad_suite (void)
suite_add_tcase (s, tc_chain);
tcase_add_test (tc_chain, test_link);
tcase_add_test (tc_chain, test_refcount);
tcase_add_test (tc_chain, test_get_allowed_caps);
tcase_add_test (tc_chain, test_link_unlink_threaded);
return s;
}

View file

@ -144,6 +144,22 @@ G_STMT_START { \
_gst_check_expecting_log = FALSE; \
} G_STMT_END
#define ASSERT_OBJECT_REFCOUNT(object, name, value) \
G_STMT_START { \
int rc; \
rc = GST_OBJECT_REFCOUNT_VALUE (object); \
fail_unless (rc == value, \
name " refcount is %d instead of %d", rc, value);\
} G_STMT_END
#define ASSERT_CAPS_REFCOUNT(caps, name, value) \
G_STMT_START { \
int rc; \
rc = GST_MINI_OBJECT_REFCOUNT_VALUE (caps); \
fail_unless (rc == value, \
name " refcount is %d instead of %d", rc, value);\
} G_STMT_END
#endif /* __GST_CHECK_H__ */