gstreamer/tests/check/gst/gstminiobject.c

486 lines
11 KiB
C
Raw Normal View History

/* GStreamer
*
* unit test for GstMiniObject
*
* Copyright (C) <2005> Thomas Vander Stichele <thomas at apestaart dot org>
* Copyright (C) <2005> Tim-Philipp Müller <tim centricular net>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
* Boston, MA 02110-1301, USA.
*/
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include <gst/check/gstcheck.h>
GST_START_TEST (test_copy)
{
GstBuffer *buffer, *copy;
buffer = gst_buffer_new_and_alloc (4);
copy = GST_BUFFER (gst_mini_object_copy (GST_MINI_OBJECT_CAST (buffer)));
fail_if (copy == NULL, "Copy of buffer returned NULL");
2011-03-21 18:15:27 +00:00
fail_unless (gst_buffer_get_size (copy) == 4,
"Copy of buffer has different size");
gst_buffer_unref (buffer);
gst_buffer_unref (copy);
}
GST_END_TEST;
GST_START_TEST (test_is_writable)
{
GstBuffer *buffer;
GstMiniObject *mobj;
buffer = gst_buffer_new_and_alloc (4);
mobj = GST_MINI_OBJECT_CAST (buffer);
fail_unless (gst_mini_object_is_writable (mobj),
"A buffer with one ref should be writable");
fail_if (gst_mini_object_ref (mobj) == NULL, "Could not ref the mobj");
fail_if (gst_mini_object_is_writable (mobj),
"A buffer with two refs should not be writable");
gst_buffer_unref (buffer);
gst_mini_object_unref (mobj);
}
GST_END_TEST;
GST_START_TEST (test_make_writable)
{
GstBuffer *buffer;
GstMiniObject *mobj, *mobj2, *mobj3;
buffer = gst_buffer_new_and_alloc (4);
mobj = GST_MINI_OBJECT_CAST (buffer);
mobj2 = gst_mini_object_make_writable (mobj);
fail_unless (GST_IS_BUFFER (mobj2), "make_writable did not return a buffer");
fail_unless (mobj == mobj2,
"make_writable returned a copy for a buffer with refcount 1");
mobj2 = gst_mini_object_ref (mobj);
mobj3 = gst_mini_object_make_writable (mobj);
fail_unless (GST_IS_BUFFER (mobj3), "make_writable did not return a buffer");
fail_if (mobj == mobj3,
"make_writable returned same object for a buffer with refcount > 1");
fail_unless (GST_MINI_OBJECT_REFCOUNT_VALUE (mobj) == 1,
"refcount of original mobj object should be back to 1");
mobj2 = gst_mini_object_make_writable (mobj);
fail_unless (GST_IS_BUFFER (mobj2), "make_writable did not return a buffer");
fail_unless (mobj == mobj2,
"make_writable returned a copy for a buffer with refcount 1");
gst_buffer_unref (buffer);
gst_mini_object_unref (mobj3);
}
GST_END_TEST;
And correct even more valid sparse warnings. Original commit message from CVS: * gst/gstelementfactory.h: * tests/check/elements/fakesink.c: * tests/check/elements/fakesrc.c: (setup_fakesrc): * tests/check/elements/fdsrc.c: (setup_fdsrc): * tests/check/elements/filesink.c: (setup_filesink): * tests/check/elements/filesrc.c: (setup_filesrc): * tests/check/elements/identity.c: (setup_identity): * tests/check/elements/tee.c: * tests/check/generic/sinks.c: * tests/check/generic/states.c: (setup), (teardown): * tests/check/gst/gst.c: * tests/check/gst/gstabi.c: * tests/check/gst/gstbin.c: * tests/check/gst/gstbus.c: (pull_messages): * tests/check/gst/gstcaps.c: * tests/check/gst/gstelement.c: * tests/check/gst/gstevent.c: * tests/check/gst/gstghostpad.c: * tests/check/gst/gstiterator.c: * tests/check/gst/gstmessage.c: * tests/check/gst/gstminiobject.c: (my_foo_init): * tests/check/gst/gstobject.c: (thread_name_object), (gst_object_suite): * tests/check/gst/gstpad.c: * tests/check/gst/gstplugin.c: * tests/check/gst/gstpoll.c: * tests/check/gst/gstquery.c: * tests/check/gst/gstsegment.c: * tests/check/gst/gststructure.c: * tests/check/gst/gstsystemclock.c: * tests/check/gst/gsttask.c: * tests/check/gst/gstutils.c: * tests/check/gst/gstvalue.c: * tests/check/gst/struct_hppa.h: * tests/check/gst/struct_i386.h: * tests/check/gst/struct_ppc32.h: * tests/check/gst/struct_ppc64.h: * tests/check/gst/struct_x86_64.h: * tests/check/libs/adapter.c: (create_and_fill_adapter): * tests/check/libs/basesrc.c: * tests/check/libs/controller.c: (GST_START_TEST): * tests/check/libs/gdp.c: * tests/check/libs/gstnetclientclock.c: * tests/check/libs/gstnettimeprovider.c: * tests/check/libs/libsabi.c: * tests/check/libs/struct_hppa.h: * tests/check/libs/struct_i386.h: * tests/check/libs/struct_ppc32.h: * tests/check/libs/struct_ppc64.h: * tests/check/libs/struct_x86_64.h: * tests/check/pipelines/cleanup.c: * tests/check/pipelines/simple-launch-lines.c: * tests/check/pipelines/stress.c: And correct even more valid sparse warnings. * win32/common/libgstreamer.def: Add gst_poll_fd_init to the list of symbols.
2008-02-29 13:59:24 +00:00
static gint num_threads = 10;
static gint refs_per_thread = 10000;
/* test thread-safe refcounting of GstMiniObject */
And correct even more valid sparse warnings. Original commit message from CVS: * gst/gstelementfactory.h: * tests/check/elements/fakesink.c: * tests/check/elements/fakesrc.c: (setup_fakesrc): * tests/check/elements/fdsrc.c: (setup_fdsrc): * tests/check/elements/filesink.c: (setup_filesink): * tests/check/elements/filesrc.c: (setup_filesrc): * tests/check/elements/identity.c: (setup_identity): * tests/check/elements/tee.c: * tests/check/generic/sinks.c: * tests/check/generic/states.c: (setup), (teardown): * tests/check/gst/gst.c: * tests/check/gst/gstabi.c: * tests/check/gst/gstbin.c: * tests/check/gst/gstbus.c: (pull_messages): * tests/check/gst/gstcaps.c: * tests/check/gst/gstelement.c: * tests/check/gst/gstevent.c: * tests/check/gst/gstghostpad.c: * tests/check/gst/gstiterator.c: * tests/check/gst/gstmessage.c: * tests/check/gst/gstminiobject.c: (my_foo_init): * tests/check/gst/gstobject.c: (thread_name_object), (gst_object_suite): * tests/check/gst/gstpad.c: * tests/check/gst/gstplugin.c: * tests/check/gst/gstpoll.c: * tests/check/gst/gstquery.c: * tests/check/gst/gstsegment.c: * tests/check/gst/gststructure.c: * tests/check/gst/gstsystemclock.c: * tests/check/gst/gsttask.c: * tests/check/gst/gstutils.c: * tests/check/gst/gstvalue.c: * tests/check/gst/struct_hppa.h: * tests/check/gst/struct_i386.h: * tests/check/gst/struct_ppc32.h: * tests/check/gst/struct_ppc64.h: * tests/check/gst/struct_x86_64.h: * tests/check/libs/adapter.c: (create_and_fill_adapter): * tests/check/libs/basesrc.c: * tests/check/libs/controller.c: (GST_START_TEST): * tests/check/libs/gdp.c: * tests/check/libs/gstnetclientclock.c: * tests/check/libs/gstnettimeprovider.c: * tests/check/libs/libsabi.c: * tests/check/libs/struct_hppa.h: * tests/check/libs/struct_i386.h: * tests/check/libs/struct_ppc32.h: * tests/check/libs/struct_ppc64.h: * tests/check/libs/struct_x86_64.h: * tests/check/pipelines/cleanup.c: * tests/check/pipelines/simple-launch-lines.c: * tests/check/pipelines/stress.c: And correct even more valid sparse warnings. * win32/common/libgstreamer.def: Add gst_poll_fd_init to the list of symbols.
2008-02-29 13:59:24 +00:00
static void
thread_ref (GstMiniObject * mobj)
{
int j;
THREAD_START ();
for (j = 0; j < refs_per_thread; ++j) {
gst_mini_object_ref (mobj);
if (j % num_threads == 0)
THREAD_SWITCH ();
}
GST_DEBUG ("thread stopped");
}
GST_START_TEST (test_ref_threaded)
{
GstBuffer *buffer;
GstMiniObject *mobj;
gint expected;
buffer = gst_buffer_new_and_alloc (4);
mobj = GST_MINI_OBJECT_CAST (buffer);
MAIN_START_THREADS (num_threads, thread_ref, mobj);
MAIN_STOP_THREADS ();
expected = num_threads * refs_per_thread + 1;
ASSERT_MINI_OBJECT_REFCOUNT (mobj, "miniobject", expected);
while (expected-- != 0)
gst_buffer_unref (buffer);
}
GST_END_TEST;
And correct even more valid sparse warnings. Original commit message from CVS: * gst/gstelementfactory.h: * tests/check/elements/fakesink.c: * tests/check/elements/fakesrc.c: (setup_fakesrc): * tests/check/elements/fdsrc.c: (setup_fdsrc): * tests/check/elements/filesink.c: (setup_filesink): * tests/check/elements/filesrc.c: (setup_filesrc): * tests/check/elements/identity.c: (setup_identity): * tests/check/elements/tee.c: * tests/check/generic/sinks.c: * tests/check/generic/states.c: (setup), (teardown): * tests/check/gst/gst.c: * tests/check/gst/gstabi.c: * tests/check/gst/gstbin.c: * tests/check/gst/gstbus.c: (pull_messages): * tests/check/gst/gstcaps.c: * tests/check/gst/gstelement.c: * tests/check/gst/gstevent.c: * tests/check/gst/gstghostpad.c: * tests/check/gst/gstiterator.c: * tests/check/gst/gstmessage.c: * tests/check/gst/gstminiobject.c: (my_foo_init): * tests/check/gst/gstobject.c: (thread_name_object), (gst_object_suite): * tests/check/gst/gstpad.c: * tests/check/gst/gstplugin.c: * tests/check/gst/gstpoll.c: * tests/check/gst/gstquery.c: * tests/check/gst/gstsegment.c: * tests/check/gst/gststructure.c: * tests/check/gst/gstsystemclock.c: * tests/check/gst/gsttask.c: * tests/check/gst/gstutils.c: * tests/check/gst/gstvalue.c: * tests/check/gst/struct_hppa.h: * tests/check/gst/struct_i386.h: * tests/check/gst/struct_ppc32.h: * tests/check/gst/struct_ppc64.h: * tests/check/gst/struct_x86_64.h: * tests/check/libs/adapter.c: (create_and_fill_adapter): * tests/check/libs/basesrc.c: * tests/check/libs/controller.c: (GST_START_TEST): * tests/check/libs/gdp.c: * tests/check/libs/gstnetclientclock.c: * tests/check/libs/gstnettimeprovider.c: * tests/check/libs/libsabi.c: * tests/check/libs/struct_hppa.h: * tests/check/libs/struct_i386.h: * tests/check/libs/struct_ppc32.h: * tests/check/libs/struct_ppc64.h: * tests/check/libs/struct_x86_64.h: * tests/check/pipelines/cleanup.c: * tests/check/pipelines/simple-launch-lines.c: * tests/check/pipelines/stress.c: And correct even more valid sparse warnings. * win32/common/libgstreamer.def: Add gst_poll_fd_init to the list of symbols.
2008-02-29 13:59:24 +00:00
static void
thread_unref (GstMiniObject * mobj)
{
int j;
THREAD_START ();
for (j = 0; j < refs_per_thread; ++j) {
gst_mini_object_unref (mobj);
if (j % num_threads == 0)
THREAD_SWITCH ();
}
}
GST_START_TEST (test_unref_threaded)
{
GstBuffer *buffer;
GstMiniObject *mobj;
int i;
buffer = gst_buffer_new_and_alloc (4);
mobj = GST_MINI_OBJECT (buffer);
for (i = 0; i < num_threads * refs_per_thread; ++i)
gst_mini_object_ref (mobj);
MAIN_START_THREADS (num_threads, thread_unref, mobj);
MAIN_STOP_THREADS ();
ASSERT_MINI_OBJECT_REFCOUNT (mobj, "miniobject", 1);
/* final unref */
gst_mini_object_unref (mobj);
}
GST_END_TEST;
/* ======== weak ref test ======== */
static gboolean weak_ref_notify_succeeded = FALSE;
static void
on_weak_ref_notify (gpointer data, GstMiniObject * where_object_was)
{
weak_ref_notify_succeeded = TRUE;
}
GST_START_TEST (test_weak_ref)
{
GstBuffer *buffer;
buffer = gst_buffer_new_and_alloc (4);
gst_mini_object_weak_ref (GST_MINI_OBJECT (buffer), on_weak_ref_notify,
&buffer);
gst_buffer_unref (buffer);
fail_unless (weak_ref_notify_succeeded,
"No weak reference notification took place.");
}
GST_END_TEST;
#if 0
/* ======== recycle test ======== */
static gint recycle_buffer_count = 10;
typedef struct _MyBufferPool MyBufferPool;
struct _MyBufferPool
{
GSList *buffers;
gboolean is_closed;
};
static void my_recycle_buffer_destroy (MyRecycleBuffer * buf);
static MyBufferPool *
my_buffer_pool_new (void)
{
return g_new0 (MyBufferPool, 1);
}
static void
my_buffer_pool_free (MyBufferPool * self)
{
while (self->buffers != NULL) {
my_recycle_buffer_destroy (self->buffers->data);
self->buffers = g_slist_delete_link (self->buffers, self->buffers);
}
g_free (self);
}
static void
my_buffer_pool_add (MyBufferPool * self, GstBuffer * buf)
{
g_mutex_lock (mutex);
self->buffers = g_slist_prepend (self->buffers, gst_buffer_ref (buf));
g_mutex_unlock (mutex);
}
static GstBuffer *
my_buffer_pool_drain_one (MyBufferPool * self)
{
GstBuffer *buf = NULL;
g_mutex_lock (mutex);
if (self->buffers != NULL) {
buf = self->buffers->data;
self->buffers = g_slist_delete_link (self->buffers, self->buffers);
}
g_mutex_unlock (mutex);
return buf;
}
static void
my_recycle_buffer_finalize (GstMiniObject * mini_object)
{
GstBuffer *self = GST_BUFFER_CAST (mini_object);
if (self->pool != NULL) {
my_buffer_pool_add (self->pool, GST_BUFFER_CAST (self));
g_usleep (G_USEC_PER_SEC / 100);
} else {
GST_MINI_OBJECT_CLASS (my_recycle_buffer_parent_class)->finalize
(mini_object);
}
}
static GstBuffer *
my_recycle_buffer_new (MyBufferPool * pool)
{
GstBuffer *buf;
buf = gst_buffer_new ();
//buf->pool = pool;
return GST_BUFFER_CAST (buf);
}
static void
my_recycle_buffer_destroy (MyRecycleBuffer * buf)
{
buf->pool = NULL;
gst_buffer_unref (GST_BUFFER_CAST (buf));
}
static void
thread_buffer_producer (MyBufferPool * pool)
{
int j;
THREAD_START ();
for (j = 0; j < recycle_buffer_count; ++j) {
GstBuffer *buf = my_recycle_buffer_new (pool);
gst_buffer_unref (buf);
}
g_atomic_int_set (&pool->is_closed, TRUE);
}
static void
thread_buffer_consumer (MyBufferPool * pool)
{
THREAD_START ();
do {
GstBuffer *buf;
buf = my_buffer_pool_drain_one (pool);
if (buf != NULL)
my_recycle_buffer_destroy (MY_RECYCLE_BUFFER_CAST (buf));
THREAD_SWITCH ();
}
while (!g_atomic_int_get (&pool->is_closed));
}
GST_START_TEST (test_recycle_threaded)
{
MyBufferPool *pool;
pool = my_buffer_pool_new ();
MAIN_START_THREADS (1, thread_buffer_producer, pool);
MAIN_START_THREADS (1, thread_buffer_consumer, pool);
MAIN_STOP_THREADS ();
my_buffer_pool_free (pool);
}
GST_END_TEST;
#endif
/* ======== value collection test ======== */
typedef struct _MyFoo
{
GObject object;
} MyFoo;
typedef struct _MyFooClass
{
GObjectClass gobject_class;
} MyFooClass;
enum
{
PROP_BUFFER = 1
};
GType my_foo_get_type (void);
And correct even more valid sparse warnings. Original commit message from CVS: * gst/gstelementfactory.h: * tests/check/elements/fakesink.c: * tests/check/elements/fakesrc.c: (setup_fakesrc): * tests/check/elements/fdsrc.c: (setup_fdsrc): * tests/check/elements/filesink.c: (setup_filesink): * tests/check/elements/filesrc.c: (setup_filesrc): * tests/check/elements/identity.c: (setup_identity): * tests/check/elements/tee.c: * tests/check/generic/sinks.c: * tests/check/generic/states.c: (setup), (teardown): * tests/check/gst/gst.c: * tests/check/gst/gstabi.c: * tests/check/gst/gstbin.c: * tests/check/gst/gstbus.c: (pull_messages): * tests/check/gst/gstcaps.c: * tests/check/gst/gstelement.c: * tests/check/gst/gstevent.c: * tests/check/gst/gstghostpad.c: * tests/check/gst/gstiterator.c: * tests/check/gst/gstmessage.c: * tests/check/gst/gstminiobject.c: (my_foo_init): * tests/check/gst/gstobject.c: (thread_name_object), (gst_object_suite): * tests/check/gst/gstpad.c: * tests/check/gst/gstplugin.c: * tests/check/gst/gstpoll.c: * tests/check/gst/gstquery.c: * tests/check/gst/gstsegment.c: * tests/check/gst/gststructure.c: * tests/check/gst/gstsystemclock.c: * tests/check/gst/gsttask.c: * tests/check/gst/gstutils.c: * tests/check/gst/gstvalue.c: * tests/check/gst/struct_hppa.h: * tests/check/gst/struct_i386.h: * tests/check/gst/struct_ppc32.h: * tests/check/gst/struct_ppc64.h: * tests/check/gst/struct_x86_64.h: * tests/check/libs/adapter.c: (create_and_fill_adapter): * tests/check/libs/basesrc.c: * tests/check/libs/controller.c: (GST_START_TEST): * tests/check/libs/gdp.c: * tests/check/libs/gstnetclientclock.c: * tests/check/libs/gstnettimeprovider.c: * tests/check/libs/libsabi.c: * tests/check/libs/struct_hppa.h: * tests/check/libs/struct_i386.h: * tests/check/libs/struct_ppc32.h: * tests/check/libs/struct_ppc64.h: * tests/check/libs/struct_x86_64.h: * tests/check/pipelines/cleanup.c: * tests/check/pipelines/simple-launch-lines.c: * tests/check/pipelines/stress.c: And correct even more valid sparse warnings. * win32/common/libgstreamer.def: Add gst_poll_fd_init to the list of symbols.
2008-02-29 13:59:24 +00:00
G_DEFINE_TYPE (MyFoo, my_foo, G_TYPE_OBJECT);
And correct even more valid sparse warnings. Original commit message from CVS: * gst/gstelementfactory.h: * tests/check/elements/fakesink.c: * tests/check/elements/fakesrc.c: (setup_fakesrc): * tests/check/elements/fdsrc.c: (setup_fdsrc): * tests/check/elements/filesink.c: (setup_filesink): * tests/check/elements/filesrc.c: (setup_filesrc): * tests/check/elements/identity.c: (setup_identity): * tests/check/elements/tee.c: * tests/check/generic/sinks.c: * tests/check/generic/states.c: (setup), (teardown): * tests/check/gst/gst.c: * tests/check/gst/gstabi.c: * tests/check/gst/gstbin.c: * tests/check/gst/gstbus.c: (pull_messages): * tests/check/gst/gstcaps.c: * tests/check/gst/gstelement.c: * tests/check/gst/gstevent.c: * tests/check/gst/gstghostpad.c: * tests/check/gst/gstiterator.c: * tests/check/gst/gstmessage.c: * tests/check/gst/gstminiobject.c: (my_foo_init): * tests/check/gst/gstobject.c: (thread_name_object), (gst_object_suite): * tests/check/gst/gstpad.c: * tests/check/gst/gstplugin.c: * tests/check/gst/gstpoll.c: * tests/check/gst/gstquery.c: * tests/check/gst/gstsegment.c: * tests/check/gst/gststructure.c: * tests/check/gst/gstsystemclock.c: * tests/check/gst/gsttask.c: * tests/check/gst/gstutils.c: * tests/check/gst/gstvalue.c: * tests/check/gst/struct_hppa.h: * tests/check/gst/struct_i386.h: * tests/check/gst/struct_ppc32.h: * tests/check/gst/struct_ppc64.h: * tests/check/gst/struct_x86_64.h: * tests/check/libs/adapter.c: (create_and_fill_adapter): * tests/check/libs/basesrc.c: * tests/check/libs/controller.c: (GST_START_TEST): * tests/check/libs/gdp.c: * tests/check/libs/gstnetclientclock.c: * tests/check/libs/gstnettimeprovider.c: * tests/check/libs/libsabi.c: * tests/check/libs/struct_hppa.h: * tests/check/libs/struct_i386.h: * tests/check/libs/struct_ppc32.h: * tests/check/libs/struct_ppc64.h: * tests/check/libs/struct_x86_64.h: * tests/check/pipelines/cleanup.c: * tests/check/pipelines/simple-launch-lines.c: * tests/check/pipelines/stress.c: And correct even more valid sparse warnings. * win32/common/libgstreamer.def: Add gst_poll_fd_init to the list of symbols.
2008-02-29 13:59:24 +00:00
static void
my_foo_init (MyFoo * foo)
{
}
static void
my_foo_get_property (GObject * object, guint prop_id, GValue * value,
GParamSpec * pspec)
{
GstBuffer *new_buf;
g_assert (prop_id == PROP_BUFFER);
new_buf = gst_buffer_new_and_alloc (1024);
g_value_set_boxed (value, GST_MINI_OBJECT (new_buf));
gst_buffer_unref (new_buf);
}
static void
my_foo_set_property (GObject * object, guint prop_id, const GValue * value,
GParamSpec * pspec)
{
GstMiniObject *mini_obj;
g_assert (prop_id == PROP_BUFFER);
mini_obj = g_value_get_boxed (value);
g_assert (GST_IS_BUFFER (mini_obj));
#if 0
/* gst_value_dup_mini_object() does not exist yet */
mini_obj = gst_value_dup_mini_object (value);
g_assert (GST_IS_MINI_OBJECT (mini_obj));
g_assert (GST_IS_BUFFER (mini_obj));
gst_mini_object_unref (mini_obj);
#endif
}
static void
my_foo_class_init (MyFooClass * klass)
{
GObjectClass *gobject_klass = G_OBJECT_CLASS (klass);
gobject_klass->get_property = my_foo_get_property;
gobject_klass->set_property = my_foo_set_property;
g_object_class_install_property (gobject_klass, PROP_BUFFER,
g_param_spec_boxed ("buffer", "Buffer",
"a newly created GstBuffer", GST_TYPE_BUFFER, G_PARAM_READWRITE));
}
GST_START_TEST (test_value_collection)
{
GstBuffer *buf = NULL;
MyFoo *foo;
foo = (MyFoo *) g_object_new (my_foo_get_type (), NULL);
/* test g_object_get() refcounting */
g_object_get (foo, "buffer", &buf, NULL);
g_assert (GST_IS_BUFFER (buf));
g_assert (GST_MINI_OBJECT_REFCOUNT_VALUE (GST_MINI_OBJECT_CAST (buf)) == 1);
gst_buffer_unref (buf);
/* test g_object_set() refcounting */
buf = gst_buffer_new_and_alloc (1024);
g_object_set (foo, "buffer", buf, NULL);
g_assert (GST_MINI_OBJECT_REFCOUNT_VALUE (GST_MINI_OBJECT_CAST (buf)) == 1);
gst_buffer_unref (buf);
g_object_unref (foo);
}
GST_END_TEST;
GST_START_TEST (test_dup_null_mini_object)
{
GValue value = { 0, };
GstMiniObject *mo;
g_value_init (&value, GST_TYPE_BUFFER);
g_value_set_boxed (&value, NULL);
mo = GST_MINI_OBJECT_CAST (g_value_dup_boxed (&value));
g_assert (mo == NULL);
g_value_unset (&value);
}
GST_END_TEST;
And correct even more valid sparse warnings. Original commit message from CVS: * gst/gstelementfactory.h: * tests/check/elements/fakesink.c: * tests/check/elements/fakesrc.c: (setup_fakesrc): * tests/check/elements/fdsrc.c: (setup_fdsrc): * tests/check/elements/filesink.c: (setup_filesink): * tests/check/elements/filesrc.c: (setup_filesrc): * tests/check/elements/identity.c: (setup_identity): * tests/check/elements/tee.c: * tests/check/generic/sinks.c: * tests/check/generic/states.c: (setup), (teardown): * tests/check/gst/gst.c: * tests/check/gst/gstabi.c: * tests/check/gst/gstbin.c: * tests/check/gst/gstbus.c: (pull_messages): * tests/check/gst/gstcaps.c: * tests/check/gst/gstelement.c: * tests/check/gst/gstevent.c: * tests/check/gst/gstghostpad.c: * tests/check/gst/gstiterator.c: * tests/check/gst/gstmessage.c: * tests/check/gst/gstminiobject.c: (my_foo_init): * tests/check/gst/gstobject.c: (thread_name_object), (gst_object_suite): * tests/check/gst/gstpad.c: * tests/check/gst/gstplugin.c: * tests/check/gst/gstpoll.c: * tests/check/gst/gstquery.c: * tests/check/gst/gstsegment.c: * tests/check/gst/gststructure.c: * tests/check/gst/gstsystemclock.c: * tests/check/gst/gsttask.c: * tests/check/gst/gstutils.c: * tests/check/gst/gstvalue.c: * tests/check/gst/struct_hppa.h: * tests/check/gst/struct_i386.h: * tests/check/gst/struct_ppc32.h: * tests/check/gst/struct_ppc64.h: * tests/check/gst/struct_x86_64.h: * tests/check/libs/adapter.c: (create_and_fill_adapter): * tests/check/libs/basesrc.c: * tests/check/libs/controller.c: (GST_START_TEST): * tests/check/libs/gdp.c: * tests/check/libs/gstnetclientclock.c: * tests/check/libs/gstnettimeprovider.c: * tests/check/libs/libsabi.c: * tests/check/libs/struct_hppa.h: * tests/check/libs/struct_i386.h: * tests/check/libs/struct_ppc32.h: * tests/check/libs/struct_ppc64.h: * tests/check/libs/struct_x86_64.h: * tests/check/pipelines/cleanup.c: * tests/check/pipelines/simple-launch-lines.c: * tests/check/pipelines/stress.c: And correct even more valid sparse warnings. * win32/common/libgstreamer.def: Add gst_poll_fd_init to the list of symbols.
2008-02-29 13:59:24 +00:00
static Suite *
gst_mini_object_suite (void)
{
Suite *s = suite_create ("GstMiniObject");
TCase *tc_chain = tcase_create ("general");
/* turn off timeout */
tcase_set_timeout (tc_chain, 60);
suite_add_tcase (s, tc_chain);
tcase_add_test (tc_chain, test_copy);
tcase_add_test (tc_chain, test_is_writable);
tcase_add_test (tc_chain, test_make_writable);
tcase_add_test (tc_chain, test_ref_threaded);
tcase_add_test (tc_chain, test_unref_threaded);
tcase_add_test (tc_chain, test_weak_ref);
//tcase_add_test (tc_chain, test_recycle_threaded);
tcase_add_test (tc_chain, test_value_collection);
tcase_add_test (tc_chain, test_dup_null_mini_object);
return s;
}
tests/check/: use the new macro Original commit message from CVS: * tests/check/elements/fakesink.c: * tests/check/elements/fakesrc.c: * tests/check/elements/fdsrc.c: * tests/check/elements/identity.c: * tests/check/generic/sinks.c: (gst_sinks_suite): * tests/check/generic/states.c: * tests/check/gst/gst.c: * tests/check/gst/gstabi.c: * tests/check/gst/gstbin.c: * tests/check/gst/gstbuffer.c: (gst_buffer_suite): * tests/check/gst/gstbus.c: (gst_bus_suite): * tests/check/gst/gstcaps.c: (GST_START_TEST): * tests/check/gst/gstelement.c: * tests/check/gst/gstevent.c: (gst_event_suite): * tests/check/gst/gstghostpad.c: * tests/check/gst/gstiterator.c: (gst_iterator_suite): * tests/check/gst/gstmessage.c: (gst_message_suite): * tests/check/gst/gstminiobject.c: * tests/check/gst/gstobject.c: * tests/check/gst/gstpad.c: * tests/check/gst/gstpipeline.c: * tests/check/gst/gstplugin.c: * tests/check/gst/gstquery.c: (gst_query_suite): * tests/check/gst/gstsegment.c: (gst_segment_suite): * tests/check/gst/gststructure.c: * tests/check/gst/gstsystemclock.c: * tests/check/gst/gsttag.c: * tests/check/gst/gsttask.c: (gst_task_suite): * tests/check/gst/gstutils.c: * tests/check/gst/gstvalue.c: * tests/check/libs/adapter.c: * tests/check/libs/basesrc.c: * tests/check/libs/collectpads.c: * tests/check/libs/controller.c: * tests/check/libs/gdp.c: (gst_dp_suite): * tests/check/libs/gstnetclientclock.c: * tests/check/libs/gstnettimeprovider.c: * tests/check/libs/libsabi.c: (libsabi_suite): * tests/check/libs/typefindhelper.c: * tests/check/pipelines/cleanup.c: * tests/check/pipelines/parse-launch.c: * tests/check/pipelines/simple-launch-lines.c: * tests/check/pipelines/stress.c: (stress_suite): use the new macro
2006-07-01 20:56:56 +00:00
GST_CHECK_MAIN (gst_mini_object);