mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-12-26 18:20:44 +00:00
Added missing tests
Original commit message from CVS: Added missing tests
This commit is contained in:
parent
78fb74c8da
commit
8448b21439
4 changed files with 200 additions and 0 deletions
49
tests/old/testsuite/threads/staticrec.c
Normal file
49
tests/old/testsuite/threads/staticrec.c
Normal file
|
@ -0,0 +1,49 @@
|
|||
#include <glib.h>
|
||||
|
||||
GStaticRecMutex mutex = G_STATIC_REC_MUTEX_INIT;
|
||||
|
||||
static void *
|
||||
thread1 (void *t)
|
||||
{
|
||||
gint i = 0;
|
||||
|
||||
while (TRUE) {
|
||||
g_static_rec_mutex_lock (&mutex);
|
||||
if (i++ % 100000 == 0)
|
||||
g_print ("*");
|
||||
g_static_rec_mutex_unlock (&mutex);
|
||||
if (i++ % 100000 == 0)
|
||||
g_print ("*");
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static void *
|
||||
thread2 (void *t)
|
||||
{
|
||||
gint i = 0;
|
||||
|
||||
while (TRUE) {
|
||||
g_static_rec_mutex_lock (&mutex);
|
||||
if (i++ % 100000 == 0)
|
||||
g_print (".");
|
||||
g_static_rec_mutex_unlock (&mutex);
|
||||
if (i++ % 100000 == 0)
|
||||
g_print (".");
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
int
|
||||
main (gint argc, gchar * argv[])
|
||||
{
|
||||
g_thread_init (NULL);
|
||||
g_thread_create_full (thread1,
|
||||
NULL, 0x200000, FALSE, TRUE, G_THREAD_PRIORITY_NORMAL, NULL);
|
||||
g_thread_create_full (thread2,
|
||||
NULL, 0x200000, FALSE, TRUE, G_THREAD_PRIORITY_NORMAL, NULL);
|
||||
|
||||
g_usleep (G_MAXLONG);
|
||||
|
||||
return 0;
|
||||
}
|
51
tests/old/testsuite/threads/threadh.c
Normal file
51
tests/old/testsuite/threads/threadh.c
Normal file
|
@ -0,0 +1,51 @@
|
|||
#include <unistd.h>
|
||||
#include <gst/gst.h>
|
||||
|
||||
static GstElement *thread, *pipeline;
|
||||
static GstElement *src, *sink;
|
||||
|
||||
static void
|
||||
handoff_src (GstElement * element)
|
||||
{
|
||||
g_print ("identity handoff\n");
|
||||
|
||||
if (gst_element_set_state (thread, GST_STATE_PAUSED) != GST_STATE_SUCCESS)
|
||||
g_assert_not_reached ();
|
||||
|
||||
if (gst_element_set_state (sink, GST_STATE_READY) != GST_STATE_SUCCESS)
|
||||
g_assert_not_reached ();
|
||||
|
||||
gst_bin_remove (GST_BIN (thread), src);
|
||||
}
|
||||
|
||||
int
|
||||
main (int argc, char **argv)
|
||||
{
|
||||
gst_init (&argc, &argv);
|
||||
|
||||
pipeline = gst_element_factory_make ("pipeline", "pipeline");
|
||||
|
||||
thread = gst_element_factory_make ("thread", "thread");
|
||||
g_assert (thread);
|
||||
|
||||
src = gst_element_factory_make ("fakesrc", "src");
|
||||
g_assert (src);
|
||||
g_signal_connect (G_OBJECT (src), "handoff", (GCallback) handoff_src, NULL);
|
||||
g_object_set (G_OBJECT (src), "signal-handoffs", TRUE, NULL);
|
||||
sink = gst_element_factory_make ("fakesink", "sink");
|
||||
g_assert (sink);
|
||||
|
||||
gst_bin_add (GST_BIN (pipeline), thread);
|
||||
|
||||
gst_bin_add_many (GST_BIN (thread), src, sink, NULL);
|
||||
if (!gst_element_link_many (src, sink, NULL))
|
||||
g_assert_not_reached ();
|
||||
|
||||
/* run a bit */
|
||||
if (gst_element_set_state (pipeline, GST_STATE_PLAYING) != GST_STATE_SUCCESS)
|
||||
g_assert_not_reached ();
|
||||
|
||||
sleep (2);
|
||||
|
||||
return 0;
|
||||
}
|
49
testsuite/threads/staticrec.c
Normal file
49
testsuite/threads/staticrec.c
Normal file
|
@ -0,0 +1,49 @@
|
|||
#include <glib.h>
|
||||
|
||||
GStaticRecMutex mutex = G_STATIC_REC_MUTEX_INIT;
|
||||
|
||||
static void *
|
||||
thread1 (void *t)
|
||||
{
|
||||
gint i = 0;
|
||||
|
||||
while (TRUE) {
|
||||
g_static_rec_mutex_lock (&mutex);
|
||||
if (i++ % 100000 == 0)
|
||||
g_print ("*");
|
||||
g_static_rec_mutex_unlock (&mutex);
|
||||
if (i++ % 100000 == 0)
|
||||
g_print ("*");
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static void *
|
||||
thread2 (void *t)
|
||||
{
|
||||
gint i = 0;
|
||||
|
||||
while (TRUE) {
|
||||
g_static_rec_mutex_lock (&mutex);
|
||||
if (i++ % 100000 == 0)
|
||||
g_print (".");
|
||||
g_static_rec_mutex_unlock (&mutex);
|
||||
if (i++ % 100000 == 0)
|
||||
g_print (".");
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
int
|
||||
main (gint argc, gchar * argv[])
|
||||
{
|
||||
g_thread_init (NULL);
|
||||
g_thread_create_full (thread1,
|
||||
NULL, 0x200000, FALSE, TRUE, G_THREAD_PRIORITY_NORMAL, NULL);
|
||||
g_thread_create_full (thread2,
|
||||
NULL, 0x200000, FALSE, TRUE, G_THREAD_PRIORITY_NORMAL, NULL);
|
||||
|
||||
g_usleep (G_MAXLONG);
|
||||
|
||||
return 0;
|
||||
}
|
51
testsuite/threads/threadh.c
Normal file
51
testsuite/threads/threadh.c
Normal file
|
@ -0,0 +1,51 @@
|
|||
#include <unistd.h>
|
||||
#include <gst/gst.h>
|
||||
|
||||
static GstElement *thread, *pipeline;
|
||||
static GstElement *src, *sink;
|
||||
|
||||
static void
|
||||
handoff_src (GstElement * element)
|
||||
{
|
||||
g_print ("identity handoff\n");
|
||||
|
||||
if (gst_element_set_state (thread, GST_STATE_PAUSED) != GST_STATE_SUCCESS)
|
||||
g_assert_not_reached ();
|
||||
|
||||
if (gst_element_set_state (sink, GST_STATE_READY) != GST_STATE_SUCCESS)
|
||||
g_assert_not_reached ();
|
||||
|
||||
gst_bin_remove (GST_BIN (thread), src);
|
||||
}
|
||||
|
||||
int
|
||||
main (int argc, char **argv)
|
||||
{
|
||||
gst_init (&argc, &argv);
|
||||
|
||||
pipeline = gst_element_factory_make ("pipeline", "pipeline");
|
||||
|
||||
thread = gst_element_factory_make ("thread", "thread");
|
||||
g_assert (thread);
|
||||
|
||||
src = gst_element_factory_make ("fakesrc", "src");
|
||||
g_assert (src);
|
||||
g_signal_connect (G_OBJECT (src), "handoff", (GCallback) handoff_src, NULL);
|
||||
g_object_set (G_OBJECT (src), "signal-handoffs", TRUE, NULL);
|
||||
sink = gst_element_factory_make ("fakesink", "sink");
|
||||
g_assert (sink);
|
||||
|
||||
gst_bin_add (GST_BIN (pipeline), thread);
|
||||
|
||||
gst_bin_add_many (GST_BIN (thread), src, sink, NULL);
|
||||
if (!gst_element_link_many (src, sink, NULL))
|
||||
g_assert_not_reached ();
|
||||
|
||||
/* run a bit */
|
||||
if (gst_element_set_state (pipeline, GST_STATE_PLAYING) != GST_STATE_SUCCESS)
|
||||
g_assert_not_reached ();
|
||||
|
||||
sleep (2);
|
||||
|
||||
return 0;
|
||||
}
|
Loading…
Reference in a new issue