check/: Added checks.
Original commit message from CVS:
* check/.cvsignore:
* check/Makefile.am:
* check/gst-libs/.cvsignore:
* check/gst-libs/gdp.c: (START_TEST), (gst_object_suite), (main):
* check/gst/.cvsignore:
* check/gst/gstbus.c: (pound_bus_with_messages), (pull_messages),
(START_TEST), (gstbus_suite), (main):
* check/gst/gstcaps.c: (START_TEST), (gst_caps_suite), (main):
* check/gst/gstdata.c: (START_TEST), (thread_ref), (thread_unref),
(gst_data_suite), (main):
* check/gst/gstiterator.c: (make_list_of_ints), (START_TEST),
(add_fold_func), (gstiterator_suite), (main):
* check/gst/gstobject.c: (gst_fake_object_get_type), (START_TEST),
(thread_name_object), (thread_name_object_default),
(gst_object_name_compare), (gst_object_suite), (main):
* check/gst/gstpad.c: (START_TEST), (thread_link_unlink),
(gst_pad_suite), (main):
* check/gstcheck.c: (gst_check_log_message_func),
(gst_check_log_critical_func), (gst_check_init):
* check/gstcheck.h:
* check/pipelines/simple_launch_lines.c: (setup_pipeline),
(run_pipeline), (START_TEST), (simple_launch_lines_suite), (main):
Added checks.
2005-03-07 18:33:37 +00:00
|
|
|
/* GStreamer
|
|
|
|
* Copyright (C) 2005 Andy Wingo <wingo@pobox.com>
|
|
|
|
*
|
|
|
|
* gstbus.c: Unit test for the message bus
|
|
|
|
*
|
|
|
|
* 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., 59 Temple Place - Suite 330,
|
|
|
|
* Boston, MA 02111-1307, USA.
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
#include "../gstcheck.h"
|
|
|
|
|
|
|
|
|
|
|
|
static GstBus *test_bus = NULL;
|
|
|
|
|
|
|
|
#define NUM_MESSAGES 1000
|
|
|
|
#define NUM_THREADS 10
|
|
|
|
|
|
|
|
static gpointer
|
|
|
|
pound_bus_with_messages (gpointer data)
|
|
|
|
{
|
|
|
|
gint thread_id = GPOINTER_TO_INT (data);
|
|
|
|
gint i;
|
|
|
|
|
|
|
|
for (i = 0; i < NUM_MESSAGES; i++) {
|
|
|
|
GstMessage *m;
|
|
|
|
GstStructure *s;
|
|
|
|
|
|
|
|
s = gst_structure_new ("test_message",
|
|
|
|
"thread_id", G_TYPE_INT, thread_id, "msg_id", G_TYPE_INT, i, NULL);
|
2005-07-05 08:47:40 +00:00
|
|
|
m = gst_message_new_application (NULL, s);
|
check/: Added checks.
Original commit message from CVS:
* check/.cvsignore:
* check/Makefile.am:
* check/gst-libs/.cvsignore:
* check/gst-libs/gdp.c: (START_TEST), (gst_object_suite), (main):
* check/gst/.cvsignore:
* check/gst/gstbus.c: (pound_bus_with_messages), (pull_messages),
(START_TEST), (gstbus_suite), (main):
* check/gst/gstcaps.c: (START_TEST), (gst_caps_suite), (main):
* check/gst/gstdata.c: (START_TEST), (thread_ref), (thread_unref),
(gst_data_suite), (main):
* check/gst/gstiterator.c: (make_list_of_ints), (START_TEST),
(add_fold_func), (gstiterator_suite), (main):
* check/gst/gstobject.c: (gst_fake_object_get_type), (START_TEST),
(thread_name_object), (thread_name_object_default),
(gst_object_name_compare), (gst_object_suite), (main):
* check/gst/gstpad.c: (START_TEST), (thread_link_unlink),
(gst_pad_suite), (main):
* check/gstcheck.c: (gst_check_log_message_func),
(gst_check_log_critical_func), (gst_check_init):
* check/gstcheck.h:
* check/pipelines/simple_launch_lines.c: (setup_pipeline),
(run_pipeline), (START_TEST), (simple_launch_lines_suite), (main):
Added checks.
2005-03-07 18:33:37 +00:00
|
|
|
gst_bus_post (test_bus, m);
|
|
|
|
}
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
pull_messages ()
|
|
|
|
{
|
|
|
|
GstMessage *m;
|
|
|
|
const GstStructure *s;
|
|
|
|
guint message_ids[NUM_THREADS];
|
|
|
|
gint i;
|
|
|
|
|
|
|
|
for (i = 0; i < NUM_THREADS; i++)
|
|
|
|
message_ids[i] = 0;
|
|
|
|
|
|
|
|
while (1) {
|
|
|
|
gint _t, _i;
|
|
|
|
|
|
|
|
m = gst_bus_pop (test_bus);
|
|
|
|
if (!m)
|
|
|
|
break;
|
|
|
|
g_return_if_fail (GST_MESSAGE_TYPE (m) == GST_MESSAGE_APPLICATION);
|
|
|
|
|
|
|
|
s = gst_message_get_structure (m);
|
|
|
|
if (!gst_structure_get_int (s, "thread_id", &_t))
|
|
|
|
g_critical ("Invalid message");
|
|
|
|
if (!gst_structure_get_int (s, "msg_id", &_i))
|
|
|
|
g_critical ("Invalid message");
|
|
|
|
|
|
|
|
g_return_if_fail (_t < NUM_THREADS);
|
|
|
|
g_return_if_fail (_i == message_ids[_t]++);
|
|
|
|
|
|
|
|
gst_message_unref (m);
|
|
|
|
}
|
|
|
|
|
|
|
|
for (i = 0; i < NUM_THREADS; i++)
|
|
|
|
g_return_if_fail (message_ids[i] == NUM_MESSAGES);
|
|
|
|
}
|
|
|
|
|
|
|
|
START_TEST (test_hammer_bus)
|
|
|
|
{
|
|
|
|
GThread *threads[NUM_THREADS];
|
|
|
|
gint i;
|
|
|
|
|
|
|
|
test_bus = gst_bus_new ();
|
|
|
|
|
|
|
|
for (i = 0; i < NUM_THREADS; i++)
|
|
|
|
threads[i] = g_thread_create (pound_bus_with_messages, GINT_TO_POINTER (i),
|
|
|
|
TRUE, NULL);
|
|
|
|
|
|
|
|
for (i = 0; i < NUM_THREADS; i++)
|
|
|
|
g_thread_join (threads[i]);
|
|
|
|
|
|
|
|
pull_messages ();
|
|
|
|
|
|
|
|
gst_object_unref ((GstObject *) test_bus);
|
|
|
|
}
|
|
|
|
END_TEST Suite *
|
|
|
|
gstbus_suite (void)
|
|
|
|
{
|
|
|
|
Suite *s = suite_create ("GstBus");
|
|
|
|
TCase *tc_chain = tcase_create ("stresstest");
|
|
|
|
|
2005-04-11 11:24:53 +00:00
|
|
|
tcase_set_timeout (tc_chain, 20);
|
check/: Added checks.
Original commit message from CVS:
* check/.cvsignore:
* check/Makefile.am:
* check/gst-libs/.cvsignore:
* check/gst-libs/gdp.c: (START_TEST), (gst_object_suite), (main):
* check/gst/.cvsignore:
* check/gst/gstbus.c: (pound_bus_with_messages), (pull_messages),
(START_TEST), (gstbus_suite), (main):
* check/gst/gstcaps.c: (START_TEST), (gst_caps_suite), (main):
* check/gst/gstdata.c: (START_TEST), (thread_ref), (thread_unref),
(gst_data_suite), (main):
* check/gst/gstiterator.c: (make_list_of_ints), (START_TEST),
(add_fold_func), (gstiterator_suite), (main):
* check/gst/gstobject.c: (gst_fake_object_get_type), (START_TEST),
(thread_name_object), (thread_name_object_default),
(gst_object_name_compare), (gst_object_suite), (main):
* check/gst/gstpad.c: (START_TEST), (thread_link_unlink),
(gst_pad_suite), (main):
* check/gstcheck.c: (gst_check_log_message_func),
(gst_check_log_critical_func), (gst_check_init):
* check/gstcheck.h:
* check/pipelines/simple_launch_lines.c: (setup_pipeline),
(run_pipeline), (START_TEST), (simple_launch_lines_suite), (main):
Added checks.
2005-03-07 18:33:37 +00:00
|
|
|
|
|
|
|
suite_add_tcase (s, tc_chain);
|
|
|
|
tcase_add_test (tc_chain, test_hammer_bus);
|
|
|
|
return s;
|
|
|
|
}
|
|
|
|
|
|
|
|
int
|
|
|
|
main (int argc, char **argv)
|
|
|
|
{
|
|
|
|
int nf;
|
|
|
|
|
|
|
|
Suite *s = gstbus_suite ();
|
|
|
|
SRunner *sr = srunner_create (s);
|
|
|
|
|
|
|
|
gst_check_init (&argc, &argv);
|
|
|
|
|
|
|
|
srunner_run_all (sr, CK_NORMAL);
|
|
|
|
nf = srunner_ntests_failed (sr);
|
|
|
|
srunner_free (sr);
|
|
|
|
|
|
|
|
return nf;
|
|
|
|
}
|