mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-11-23 02:01:12 +00:00
valgrind more tests
Original commit message from CVS: valgrind more tests
This commit is contained in:
parent
8ce827c406
commit
dcfa474078
11 changed files with 130 additions and 88 deletions
10
ChangeLog
10
ChangeLog
|
@ -1,3 +1,13 @@
|
||||||
|
2005-08-20 Thomas Vander Stichele <thomas at apestaart dot org>
|
||||||
|
|
||||||
|
* check/Makefile.am:
|
||||||
|
* check/gst/gstiterator.c: (GST_START_TEST):
|
||||||
|
* check/gst/gstsystemclock.c: (GST_START_TEST),
|
||||||
|
(gst_systemclock_suite):
|
||||||
|
* check/gst/gsttag.c: (GST_START_TEST), (gst_tag_suite):
|
||||||
|
* gst/gstclock.c:
|
||||||
|
valgrind more tests
|
||||||
|
|
||||||
2005-08-20 Thomas Vander Stichele <thomas at apestaart dot org>
|
2005-08-20 Thomas Vander Stichele <thomas at apestaart dot org>
|
||||||
|
|
||||||
* check/elements/.cvsignore:
|
* check/elements/.cvsignore:
|
||||||
|
|
|
@ -75,14 +75,8 @@ gst_libs_controller_LDADD = $(GST_OBJ_LIBS) \
|
||||||
$(top_builddir)/libs/gst/controller/libgstcontroller-@GST_MAJORMINOR@.la
|
$(top_builddir)/libs/gst/controller/libgstcontroller-@GST_MAJORMINOR@.la
|
||||||
|
|
||||||
# valgrind testing
|
# valgrind testing
|
||||||
|
# these just need valgrind fixing, period
|
||||||
# these just need fixing, period
|
|
||||||
TESTS_TO_FIX = \
|
TESTS_TO_FIX = \
|
||||||
gst/gstghostpad \
|
|
||||||
gst/gstiterator \
|
|
||||||
gst/gstmessage \
|
|
||||||
gst/gstsystemclock \
|
|
||||||
gst/gsttag \
|
|
||||||
pipelines/cleanup \
|
pipelines/cleanup \
|
||||||
pipelines/simple_launch_lines
|
pipelines/simple_launch_lines
|
||||||
|
|
||||||
|
|
|
@ -52,25 +52,28 @@ GST_START_TEST (test_manual_iteration)
|
||||||
|
|
||||||
iter = gst_iterator_new_list (m, &cookie, &l, NULL, NULL, NULL);
|
iter = gst_iterator_new_list (m, &cookie, &l, NULL, NULL, NULL);
|
||||||
|
|
||||||
g_return_if_fail (iter != NULL);
|
fail_unless (iter != NULL);
|
||||||
|
|
||||||
while (1) {
|
while (1) {
|
||||||
res = gst_iterator_next (iter, &item);
|
res = gst_iterator_next (iter, &item);
|
||||||
if (i < NUM_ELEMENTS) {
|
if (i < NUM_ELEMENTS) {
|
||||||
g_return_if_fail (res == GST_ITERATOR_OK);
|
fail_unless (res == GST_ITERATOR_OK);
|
||||||
g_return_if_fail (GPOINTER_TO_INT (item) == i);
|
fail_unless (GPOINTER_TO_INT (item) == i);
|
||||||
i++;
|
i++;
|
||||||
continue;
|
continue;
|
||||||
} else {
|
} else {
|
||||||
g_return_if_fail (res == GST_ITERATOR_DONE);
|
fail_unless (res == GST_ITERATOR_DONE);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* clean up */
|
||||||
gst_iterator_free (iter);
|
gst_iterator_free (iter);
|
||||||
|
g_mutex_free (m);
|
||||||
}
|
}
|
||||||
|
|
||||||
GST_END_TEST
|
GST_END_TEST;
|
||||||
|
|
||||||
GST_START_TEST (test_resync)
|
GST_START_TEST (test_resync)
|
||||||
{
|
{
|
||||||
GList *l;
|
GList *l;
|
||||||
|
@ -87,35 +90,40 @@ GST_START_TEST (test_resync)
|
||||||
|
|
||||||
iter = gst_iterator_new_list (m, &cookie, &l, NULL, NULL, NULL);
|
iter = gst_iterator_new_list (m, &cookie, &l, NULL, NULL, NULL);
|
||||||
|
|
||||||
g_return_if_fail (iter != NULL);
|
fail_unless (iter != NULL);
|
||||||
|
|
||||||
while (1) {
|
while (1) {
|
||||||
res = gst_iterator_next (iter, &item);
|
res = gst_iterator_next (iter, &item);
|
||||||
if (i < NUM_ELEMENTS / 2) {
|
if (i < NUM_ELEMENTS / 2) {
|
||||||
g_return_if_fail (res == GST_ITERATOR_OK);
|
fail_unless (res == GST_ITERATOR_OK);
|
||||||
g_return_if_fail (GPOINTER_TO_INT (item) == i);
|
fail_unless (GPOINTER_TO_INT (item) == i);
|
||||||
i++;
|
i++;
|
||||||
continue;
|
continue;
|
||||||
} else if (!hacked_list) {
|
} else if (!hacked_list) {
|
||||||
/* here's where we test resync */
|
/* here's where we test resync */
|
||||||
g_return_if_fail (res == GST_ITERATOR_OK);
|
fail_unless (res == GST_ITERATOR_OK);
|
||||||
l = g_list_prepend (l, GINT_TO_POINTER (-1));
|
l = g_list_prepend (l, GINT_TO_POINTER (-1));
|
||||||
cookie++;
|
cookie++;
|
||||||
hacked_list = TRUE;
|
hacked_list = TRUE;
|
||||||
continue;
|
continue;
|
||||||
} else {
|
} else {
|
||||||
g_return_if_fail (res == GST_ITERATOR_RESYNC);
|
fail_unless (res == GST_ITERATOR_RESYNC);
|
||||||
gst_iterator_resync (iter);
|
gst_iterator_resync (iter);
|
||||||
res = gst_iterator_next (iter, &item);
|
res = gst_iterator_next (iter, &item);
|
||||||
g_return_if_fail (res == GST_ITERATOR_OK);
|
fail_unless (res == GST_ITERATOR_OK);
|
||||||
g_return_if_fail (GPOINTER_TO_INT (item) == -1);
|
fail_unless (GPOINTER_TO_INT (item) == -1);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* clean up */
|
||||||
gst_iterator_free (iter);
|
gst_iterator_free (iter);
|
||||||
|
g_mutex_free (m);
|
||||||
}
|
}
|
||||||
GST_END_TEST static gboolean
|
|
||||||
|
GST_END_TEST;
|
||||||
|
|
||||||
|
static gboolean
|
||||||
add_fold_func (gpointer item, GValue * ret, gpointer user_data)
|
add_fold_func (gpointer item, GValue * ret, gpointer user_data)
|
||||||
{
|
{
|
||||||
g_value_set_int (ret, g_value_get_int (ret) + GPOINTER_TO_INT (item));
|
g_value_set_int (ret, g_value_get_int (ret) + GPOINTER_TO_INT (item));
|
||||||
|
@ -135,7 +143,7 @@ GST_START_TEST (test_fold)
|
||||||
l = make_list_of_ints (NUM_ELEMENTS);
|
l = make_list_of_ints (NUM_ELEMENTS);
|
||||||
m = g_mutex_new ();
|
m = g_mutex_new ();
|
||||||
iter = gst_iterator_new_list (m, &cookie, &l, NULL, NULL, NULL);
|
iter = gst_iterator_new_list (m, &cookie, &l, NULL, NULL, NULL);
|
||||||
g_return_if_fail (iter != NULL);
|
fail_unless (iter != NULL);
|
||||||
|
|
||||||
expected = 0;
|
expected = 0;
|
||||||
for (i = 0; i < NUM_ELEMENTS; i++)
|
for (i = 0; i < NUM_ELEMENTS; i++)
|
||||||
|
@ -146,10 +154,17 @@ GST_START_TEST (test_fold)
|
||||||
|
|
||||||
res = gst_iterator_fold (iter, add_fold_func, &ret, NULL);
|
res = gst_iterator_fold (iter, add_fold_func, &ret, NULL);
|
||||||
|
|
||||||
g_return_if_fail (res == GST_ITERATOR_DONE);
|
fail_unless (res == GST_ITERATOR_DONE);
|
||||||
g_return_if_fail (g_value_get_int (&ret) == expected);
|
fail_unless (g_value_get_int (&ret) == expected);
|
||||||
|
|
||||||
|
/* clean up */
|
||||||
|
gst_iterator_free (iter);
|
||||||
|
g_mutex_free (m);
|
||||||
}
|
}
|
||||||
GST_END_TEST Suite *
|
|
||||||
|
GST_END_TEST;
|
||||||
|
|
||||||
|
Suite *
|
||||||
gstiterator_suite (void)
|
gstiterator_suite (void)
|
||||||
{
|
{
|
||||||
Suite *s = suite_create ("GstIterator");
|
Suite *s = suite_create ("GstIterator");
|
||||||
|
|
|
@ -37,7 +37,7 @@ GST_START_TEST (test_signedness)
|
||||||
}
|
}
|
||||||
|
|
||||||
GST_END_TEST
|
GST_END_TEST
|
||||||
#define TIME_UNIT GST_SECOND
|
#define TIME_UNIT (GST_SECOND / 5)
|
||||||
static void
|
static void
|
||||||
gst_clock_debug (GstClock * clock)
|
gst_clock_debug (GstClock * clock)
|
||||||
{
|
{
|
||||||
|
@ -97,14 +97,14 @@ GST_START_TEST (test_single_shot)
|
||||||
result = gst_clock_id_wait_async (id, ok_callback, NULL);
|
result = gst_clock_id_wait_async (id, ok_callback, NULL);
|
||||||
gst_clock_id_unref (id);
|
gst_clock_id_unref (id);
|
||||||
fail_unless (result == GST_CLOCK_OK, "Waiting did not return OK");
|
fail_unless (result == GST_CLOCK_OK, "Waiting did not return OK");
|
||||||
g_usleep (2 * G_USEC_PER_SEC);
|
g_usleep (TIME_UNIT / (2 * 1000));
|
||||||
|
|
||||||
id = gst_clock_new_single_shot_id (clock, base + 5 * TIME_UNIT);
|
id = gst_clock_new_single_shot_id (clock, base + 5 * TIME_UNIT);
|
||||||
g_message ("waiting one second async, with cancel on id %p\n", id);
|
g_message ("waiting one second async, with cancel on id %p\n", id);
|
||||||
result = gst_clock_id_wait_async (id, error_callback, NULL);
|
result = gst_clock_id_wait_async (id, error_callback, NULL);
|
||||||
fail_unless (result == GST_CLOCK_OK, "Waiting did not return OK");
|
fail_unless (result == GST_CLOCK_OK, "Waiting did not return OK");
|
||||||
g_usleep (G_USEC_PER_SEC / 2);
|
g_usleep (TIME_UNIT / (2 * 1000));
|
||||||
g_message ("cancel id %p after 0.5 seconds\n", id);
|
g_message ("cancel id %p after half a time unit\n", id);
|
||||||
gst_clock_id_unschedule (id);
|
gst_clock_id_unschedule (id);
|
||||||
gst_clock_id_unref (id);
|
gst_clock_id_unref (id);
|
||||||
g_message ("canceled id %p\n", id);
|
g_message ("canceled id %p\n", id);
|
||||||
|
@ -119,13 +119,12 @@ GST_START_TEST (test_single_shot)
|
||||||
g_message ("waiting id %p\n", id2);
|
g_message ("waiting id %p\n", id2);
|
||||||
result = gst_clock_id_wait_async (id2, error_callback, NULL);
|
result = gst_clock_id_wait_async (id2, error_callback, NULL);
|
||||||
fail_unless (result == GST_CLOCK_OK, "Waiting did not return OK");
|
fail_unless (result == GST_CLOCK_OK, "Waiting did not return OK");
|
||||||
g_usleep (G_USEC_PER_SEC / 2);
|
g_usleep (TIME_UNIT / (2 * 1000));
|
||||||
g_message ("cancel id %p after 0.5 seconds\n", id2);
|
g_message ("cancel id %p after half a time unit\n", id2);
|
||||||
gst_clock_id_unschedule (id2);
|
gst_clock_id_unschedule (id2);
|
||||||
g_message ("canceled id %p\n", id2);
|
g_message ("canceled id %p\n", id2);
|
||||||
gst_clock_id_unref (id2);
|
gst_clock_id_unref (id2);
|
||||||
|
g_usleep (TIME_UNIT / (2 * 1000));
|
||||||
g_usleep (2 * G_USEC_PER_SEC);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
GST_END_TEST
|
GST_END_TEST
|
||||||
|
@ -142,11 +141,11 @@ GST_START_TEST (test_periodic_shot)
|
||||||
gst_clock_debug (clock);
|
gst_clock_debug (clock);
|
||||||
base = gst_clock_get_time (clock);
|
base = gst_clock_get_time (clock);
|
||||||
|
|
||||||
/* signal every half a second */
|
/* signal every half a time unit */
|
||||||
id = gst_clock_new_periodic_id (clock, base + TIME_UNIT, TIME_UNIT / 2);
|
id = gst_clock_new_periodic_id (clock, base + TIME_UNIT, TIME_UNIT / 2);
|
||||||
fail_unless (id != NULL, "Could not create periodic id");
|
fail_unless (id != NULL, "Could not create periodic id");
|
||||||
|
|
||||||
g_message ("waiting one second\n");
|
g_message ("waiting one time unit\n");
|
||||||
result = gst_clock_id_wait (id, NULL);
|
result = gst_clock_id_wait (id, NULL);
|
||||||
gst_clock_debug (clock);
|
gst_clock_debug (clock);
|
||||||
fail_unless (result == GST_CLOCK_OK, "Waiting did not return OK");
|
fail_unless (result == GST_CLOCK_OK, "Waiting did not return OK");
|
||||||
|
@ -159,12 +158,12 @@ GST_START_TEST (test_periodic_shot)
|
||||||
g_message ("waiting for the next async %p\n", id);
|
g_message ("waiting for the next async %p\n", id);
|
||||||
result = gst_clock_id_wait_async (id, ok_callback, NULL);
|
result = gst_clock_id_wait_async (id, ok_callback, NULL);
|
||||||
fail_unless (result == GST_CLOCK_OK, "Waiting did not return OK");
|
fail_unless (result == GST_CLOCK_OK, "Waiting did not return OK");
|
||||||
g_usleep (2 * G_USEC_PER_SEC);
|
g_usleep (TIME_UNIT / (2 * 1000));
|
||||||
|
|
||||||
g_message ("waiting some more for the next async %p\n", id);
|
g_message ("waiting some more for the next async %p\n", id);
|
||||||
result = gst_clock_id_wait_async (id, ok_callback, NULL);
|
result = gst_clock_id_wait_async (id, ok_callback, NULL);
|
||||||
fail_unless (result == GST_CLOCK_OK, "Waiting did not return OK");
|
fail_unless (result == GST_CLOCK_OK, "Waiting did not return OK");
|
||||||
g_usleep (2 * G_USEC_PER_SEC);
|
g_usleep (TIME_UNIT / (2 * 1000));
|
||||||
|
|
||||||
id2 = gst_clock_new_periodic_id (clock, base + TIME_UNIT, TIME_UNIT / 2);
|
id2 = gst_clock_new_periodic_id (clock, base + TIME_UNIT, TIME_UNIT / 2);
|
||||||
fail_unless (id2 != NULL, "Could not create second periodic id");
|
fail_unless (id2 != NULL, "Could not create second periodic id");
|
||||||
|
@ -172,7 +171,7 @@ GST_START_TEST (test_periodic_shot)
|
||||||
g_message ("waiting some more for another async %p\n", id2);
|
g_message ("waiting some more for another async %p\n", id2);
|
||||||
result = gst_clock_id_wait_async (id2, ok_callback, NULL);
|
result = gst_clock_id_wait_async (id2, ok_callback, NULL);
|
||||||
fail_unless (result == GST_CLOCK_OK, "Waiting did not return OK");
|
fail_unless (result == GST_CLOCK_OK, "Waiting did not return OK");
|
||||||
g_usleep (2 * G_USEC_PER_SEC);
|
g_usleep (TIME_UNIT / (2 * 1000));
|
||||||
|
|
||||||
g_message ("unschedule %p\n", id);
|
g_message ("unschedule %p\n", id);
|
||||||
gst_clock_id_unschedule (id);
|
gst_clock_id_unschedule (id);
|
||||||
|
@ -184,7 +183,10 @@ GST_START_TEST (test_periodic_shot)
|
||||||
result = gst_clock_id_wait (id, NULL);
|
result = gst_clock_id_wait (id, NULL);
|
||||||
fail_unless (result == GST_CLOCK_UNSCHEDULED,
|
fail_unless (result == GST_CLOCK_UNSCHEDULED,
|
||||||
"Waiting did not return UNSCHEDULED");
|
"Waiting did not return UNSCHEDULED");
|
||||||
g_usleep (2 * G_USEC_PER_SEC);
|
g_usleep (TIME_UNIT / (2 * 1000));
|
||||||
|
|
||||||
|
/* clean up */
|
||||||
|
gst_clock_id_unref (id);
|
||||||
}
|
}
|
||||||
|
|
||||||
GST_END_TEST Suite * gst_systemclock_suite (void)
|
GST_END_TEST Suite * gst_systemclock_suite (void)
|
||||||
|
@ -192,9 +194,6 @@ GST_END_TEST Suite * gst_systemclock_suite (void)
|
||||||
Suite *s = suite_create ("GstSystemClock");
|
Suite *s = suite_create ("GstSystemClock");
|
||||||
TCase *tc_chain = tcase_create ("waiting");
|
TCase *tc_chain = tcase_create ("waiting");
|
||||||
|
|
||||||
/* increase timeout */
|
|
||||||
tcase_set_timeout (tc_chain, 20);
|
|
||||||
|
|
||||||
suite_add_tcase (s, tc_chain);
|
suite_add_tcase (s, tc_chain);
|
||||||
tcase_add_test (tc_chain, test_signedness);
|
tcase_add_test (tc_chain, test_signedness);
|
||||||
tcase_add_test (tc_chain, test_single_shot);
|
tcase_add_test (tc_chain, test_single_shot);
|
||||||
|
|
|
@ -171,6 +171,14 @@ GST_START_TEST (test_merge)
|
||||||
check_tags (merge, FTAG, FIXED1, NULL);
|
check_tags (merge, FTAG, FIXED1, NULL);
|
||||||
NEW_LISTS_FIXED (GST_TAG_MERGE_KEEP_ALL);
|
NEW_LISTS_FIXED (GST_TAG_MERGE_KEEP_ALL);
|
||||||
check_tags (merge, FTAG, FIXED1, NULL);
|
check_tags (merge, FTAG, FIXED1, NULL);
|
||||||
|
|
||||||
|
/* clean up */
|
||||||
|
if (list)
|
||||||
|
gst_tag_list_free (list);
|
||||||
|
if (list2)
|
||||||
|
gst_tag_list_free (list2);
|
||||||
|
if (merge)
|
||||||
|
gst_tag_list_free (merge);
|
||||||
}
|
}
|
||||||
|
|
||||||
GST_END_TEST Suite *
|
GST_END_TEST Suite *
|
||||||
|
|
|
@ -75,14 +75,8 @@ gst_libs_controller_LDADD = $(GST_OBJ_LIBS) \
|
||||||
$(top_builddir)/libs/gst/controller/libgstcontroller-@GST_MAJORMINOR@.la
|
$(top_builddir)/libs/gst/controller/libgstcontroller-@GST_MAJORMINOR@.la
|
||||||
|
|
||||||
# valgrind testing
|
# valgrind testing
|
||||||
|
# these just need valgrind fixing, period
|
||||||
# these just need fixing, period
|
|
||||||
TESTS_TO_FIX = \
|
TESTS_TO_FIX = \
|
||||||
gst/gstghostpad \
|
|
||||||
gst/gstiterator \
|
|
||||||
gst/gstmessage \
|
|
||||||
gst/gstsystemclock \
|
|
||||||
gst/gsttag \
|
|
||||||
pipelines/cleanup \
|
pipelines/cleanup \
|
||||||
pipelines/simple_launch_lines
|
pipelines/simple_launch_lines
|
||||||
|
|
||||||
|
|
|
@ -52,25 +52,28 @@ GST_START_TEST (test_manual_iteration)
|
||||||
|
|
||||||
iter = gst_iterator_new_list (m, &cookie, &l, NULL, NULL, NULL);
|
iter = gst_iterator_new_list (m, &cookie, &l, NULL, NULL, NULL);
|
||||||
|
|
||||||
g_return_if_fail (iter != NULL);
|
fail_unless (iter != NULL);
|
||||||
|
|
||||||
while (1) {
|
while (1) {
|
||||||
res = gst_iterator_next (iter, &item);
|
res = gst_iterator_next (iter, &item);
|
||||||
if (i < NUM_ELEMENTS) {
|
if (i < NUM_ELEMENTS) {
|
||||||
g_return_if_fail (res == GST_ITERATOR_OK);
|
fail_unless (res == GST_ITERATOR_OK);
|
||||||
g_return_if_fail (GPOINTER_TO_INT (item) == i);
|
fail_unless (GPOINTER_TO_INT (item) == i);
|
||||||
i++;
|
i++;
|
||||||
continue;
|
continue;
|
||||||
} else {
|
} else {
|
||||||
g_return_if_fail (res == GST_ITERATOR_DONE);
|
fail_unless (res == GST_ITERATOR_DONE);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* clean up */
|
||||||
gst_iterator_free (iter);
|
gst_iterator_free (iter);
|
||||||
|
g_mutex_free (m);
|
||||||
}
|
}
|
||||||
|
|
||||||
GST_END_TEST
|
GST_END_TEST;
|
||||||
|
|
||||||
GST_START_TEST (test_resync)
|
GST_START_TEST (test_resync)
|
||||||
{
|
{
|
||||||
GList *l;
|
GList *l;
|
||||||
|
@ -87,35 +90,40 @@ GST_START_TEST (test_resync)
|
||||||
|
|
||||||
iter = gst_iterator_new_list (m, &cookie, &l, NULL, NULL, NULL);
|
iter = gst_iterator_new_list (m, &cookie, &l, NULL, NULL, NULL);
|
||||||
|
|
||||||
g_return_if_fail (iter != NULL);
|
fail_unless (iter != NULL);
|
||||||
|
|
||||||
while (1) {
|
while (1) {
|
||||||
res = gst_iterator_next (iter, &item);
|
res = gst_iterator_next (iter, &item);
|
||||||
if (i < NUM_ELEMENTS / 2) {
|
if (i < NUM_ELEMENTS / 2) {
|
||||||
g_return_if_fail (res == GST_ITERATOR_OK);
|
fail_unless (res == GST_ITERATOR_OK);
|
||||||
g_return_if_fail (GPOINTER_TO_INT (item) == i);
|
fail_unless (GPOINTER_TO_INT (item) == i);
|
||||||
i++;
|
i++;
|
||||||
continue;
|
continue;
|
||||||
} else if (!hacked_list) {
|
} else if (!hacked_list) {
|
||||||
/* here's where we test resync */
|
/* here's where we test resync */
|
||||||
g_return_if_fail (res == GST_ITERATOR_OK);
|
fail_unless (res == GST_ITERATOR_OK);
|
||||||
l = g_list_prepend (l, GINT_TO_POINTER (-1));
|
l = g_list_prepend (l, GINT_TO_POINTER (-1));
|
||||||
cookie++;
|
cookie++;
|
||||||
hacked_list = TRUE;
|
hacked_list = TRUE;
|
||||||
continue;
|
continue;
|
||||||
} else {
|
} else {
|
||||||
g_return_if_fail (res == GST_ITERATOR_RESYNC);
|
fail_unless (res == GST_ITERATOR_RESYNC);
|
||||||
gst_iterator_resync (iter);
|
gst_iterator_resync (iter);
|
||||||
res = gst_iterator_next (iter, &item);
|
res = gst_iterator_next (iter, &item);
|
||||||
g_return_if_fail (res == GST_ITERATOR_OK);
|
fail_unless (res == GST_ITERATOR_OK);
|
||||||
g_return_if_fail (GPOINTER_TO_INT (item) == -1);
|
fail_unless (GPOINTER_TO_INT (item) == -1);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* clean up */
|
||||||
gst_iterator_free (iter);
|
gst_iterator_free (iter);
|
||||||
|
g_mutex_free (m);
|
||||||
}
|
}
|
||||||
GST_END_TEST static gboolean
|
|
||||||
|
GST_END_TEST;
|
||||||
|
|
||||||
|
static gboolean
|
||||||
add_fold_func (gpointer item, GValue * ret, gpointer user_data)
|
add_fold_func (gpointer item, GValue * ret, gpointer user_data)
|
||||||
{
|
{
|
||||||
g_value_set_int (ret, g_value_get_int (ret) + GPOINTER_TO_INT (item));
|
g_value_set_int (ret, g_value_get_int (ret) + GPOINTER_TO_INT (item));
|
||||||
|
@ -135,7 +143,7 @@ GST_START_TEST (test_fold)
|
||||||
l = make_list_of_ints (NUM_ELEMENTS);
|
l = make_list_of_ints (NUM_ELEMENTS);
|
||||||
m = g_mutex_new ();
|
m = g_mutex_new ();
|
||||||
iter = gst_iterator_new_list (m, &cookie, &l, NULL, NULL, NULL);
|
iter = gst_iterator_new_list (m, &cookie, &l, NULL, NULL, NULL);
|
||||||
g_return_if_fail (iter != NULL);
|
fail_unless (iter != NULL);
|
||||||
|
|
||||||
expected = 0;
|
expected = 0;
|
||||||
for (i = 0; i < NUM_ELEMENTS; i++)
|
for (i = 0; i < NUM_ELEMENTS; i++)
|
||||||
|
@ -146,10 +154,17 @@ GST_START_TEST (test_fold)
|
||||||
|
|
||||||
res = gst_iterator_fold (iter, add_fold_func, &ret, NULL);
|
res = gst_iterator_fold (iter, add_fold_func, &ret, NULL);
|
||||||
|
|
||||||
g_return_if_fail (res == GST_ITERATOR_DONE);
|
fail_unless (res == GST_ITERATOR_DONE);
|
||||||
g_return_if_fail (g_value_get_int (&ret) == expected);
|
fail_unless (g_value_get_int (&ret) == expected);
|
||||||
|
|
||||||
|
/* clean up */
|
||||||
|
gst_iterator_free (iter);
|
||||||
|
g_mutex_free (m);
|
||||||
}
|
}
|
||||||
GST_END_TEST Suite *
|
|
||||||
|
GST_END_TEST;
|
||||||
|
|
||||||
|
Suite *
|
||||||
gstiterator_suite (void)
|
gstiterator_suite (void)
|
||||||
{
|
{
|
||||||
Suite *s = suite_create ("GstIterator");
|
Suite *s = suite_create ("GstIterator");
|
||||||
|
|
|
@ -37,7 +37,7 @@ GST_START_TEST (test_signedness)
|
||||||
}
|
}
|
||||||
|
|
||||||
GST_END_TEST
|
GST_END_TEST
|
||||||
#define TIME_UNIT GST_SECOND
|
#define TIME_UNIT (GST_SECOND / 5)
|
||||||
static void
|
static void
|
||||||
gst_clock_debug (GstClock * clock)
|
gst_clock_debug (GstClock * clock)
|
||||||
{
|
{
|
||||||
|
@ -97,14 +97,14 @@ GST_START_TEST (test_single_shot)
|
||||||
result = gst_clock_id_wait_async (id, ok_callback, NULL);
|
result = gst_clock_id_wait_async (id, ok_callback, NULL);
|
||||||
gst_clock_id_unref (id);
|
gst_clock_id_unref (id);
|
||||||
fail_unless (result == GST_CLOCK_OK, "Waiting did not return OK");
|
fail_unless (result == GST_CLOCK_OK, "Waiting did not return OK");
|
||||||
g_usleep (2 * G_USEC_PER_SEC);
|
g_usleep (TIME_UNIT / (2 * 1000));
|
||||||
|
|
||||||
id = gst_clock_new_single_shot_id (clock, base + 5 * TIME_UNIT);
|
id = gst_clock_new_single_shot_id (clock, base + 5 * TIME_UNIT);
|
||||||
g_message ("waiting one second async, with cancel on id %p\n", id);
|
g_message ("waiting one second async, with cancel on id %p\n", id);
|
||||||
result = gst_clock_id_wait_async (id, error_callback, NULL);
|
result = gst_clock_id_wait_async (id, error_callback, NULL);
|
||||||
fail_unless (result == GST_CLOCK_OK, "Waiting did not return OK");
|
fail_unless (result == GST_CLOCK_OK, "Waiting did not return OK");
|
||||||
g_usleep (G_USEC_PER_SEC / 2);
|
g_usleep (TIME_UNIT / (2 * 1000));
|
||||||
g_message ("cancel id %p after 0.5 seconds\n", id);
|
g_message ("cancel id %p after half a time unit\n", id);
|
||||||
gst_clock_id_unschedule (id);
|
gst_clock_id_unschedule (id);
|
||||||
gst_clock_id_unref (id);
|
gst_clock_id_unref (id);
|
||||||
g_message ("canceled id %p\n", id);
|
g_message ("canceled id %p\n", id);
|
||||||
|
@ -119,13 +119,12 @@ GST_START_TEST (test_single_shot)
|
||||||
g_message ("waiting id %p\n", id2);
|
g_message ("waiting id %p\n", id2);
|
||||||
result = gst_clock_id_wait_async (id2, error_callback, NULL);
|
result = gst_clock_id_wait_async (id2, error_callback, NULL);
|
||||||
fail_unless (result == GST_CLOCK_OK, "Waiting did not return OK");
|
fail_unless (result == GST_CLOCK_OK, "Waiting did not return OK");
|
||||||
g_usleep (G_USEC_PER_SEC / 2);
|
g_usleep (TIME_UNIT / (2 * 1000));
|
||||||
g_message ("cancel id %p after 0.5 seconds\n", id2);
|
g_message ("cancel id %p after half a time unit\n", id2);
|
||||||
gst_clock_id_unschedule (id2);
|
gst_clock_id_unschedule (id2);
|
||||||
g_message ("canceled id %p\n", id2);
|
g_message ("canceled id %p\n", id2);
|
||||||
gst_clock_id_unref (id2);
|
gst_clock_id_unref (id2);
|
||||||
|
g_usleep (TIME_UNIT / (2 * 1000));
|
||||||
g_usleep (2 * G_USEC_PER_SEC);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
GST_END_TEST
|
GST_END_TEST
|
||||||
|
@ -142,11 +141,11 @@ GST_START_TEST (test_periodic_shot)
|
||||||
gst_clock_debug (clock);
|
gst_clock_debug (clock);
|
||||||
base = gst_clock_get_time (clock);
|
base = gst_clock_get_time (clock);
|
||||||
|
|
||||||
/* signal every half a second */
|
/* signal every half a time unit */
|
||||||
id = gst_clock_new_periodic_id (clock, base + TIME_UNIT, TIME_UNIT / 2);
|
id = gst_clock_new_periodic_id (clock, base + TIME_UNIT, TIME_UNIT / 2);
|
||||||
fail_unless (id != NULL, "Could not create periodic id");
|
fail_unless (id != NULL, "Could not create periodic id");
|
||||||
|
|
||||||
g_message ("waiting one second\n");
|
g_message ("waiting one time unit\n");
|
||||||
result = gst_clock_id_wait (id, NULL);
|
result = gst_clock_id_wait (id, NULL);
|
||||||
gst_clock_debug (clock);
|
gst_clock_debug (clock);
|
||||||
fail_unless (result == GST_CLOCK_OK, "Waiting did not return OK");
|
fail_unless (result == GST_CLOCK_OK, "Waiting did not return OK");
|
||||||
|
@ -159,12 +158,12 @@ GST_START_TEST (test_periodic_shot)
|
||||||
g_message ("waiting for the next async %p\n", id);
|
g_message ("waiting for the next async %p\n", id);
|
||||||
result = gst_clock_id_wait_async (id, ok_callback, NULL);
|
result = gst_clock_id_wait_async (id, ok_callback, NULL);
|
||||||
fail_unless (result == GST_CLOCK_OK, "Waiting did not return OK");
|
fail_unless (result == GST_CLOCK_OK, "Waiting did not return OK");
|
||||||
g_usleep (2 * G_USEC_PER_SEC);
|
g_usleep (TIME_UNIT / (2 * 1000));
|
||||||
|
|
||||||
g_message ("waiting some more for the next async %p\n", id);
|
g_message ("waiting some more for the next async %p\n", id);
|
||||||
result = gst_clock_id_wait_async (id, ok_callback, NULL);
|
result = gst_clock_id_wait_async (id, ok_callback, NULL);
|
||||||
fail_unless (result == GST_CLOCK_OK, "Waiting did not return OK");
|
fail_unless (result == GST_CLOCK_OK, "Waiting did not return OK");
|
||||||
g_usleep (2 * G_USEC_PER_SEC);
|
g_usleep (TIME_UNIT / (2 * 1000));
|
||||||
|
|
||||||
id2 = gst_clock_new_periodic_id (clock, base + TIME_UNIT, TIME_UNIT / 2);
|
id2 = gst_clock_new_periodic_id (clock, base + TIME_UNIT, TIME_UNIT / 2);
|
||||||
fail_unless (id2 != NULL, "Could not create second periodic id");
|
fail_unless (id2 != NULL, "Could not create second periodic id");
|
||||||
|
@ -172,7 +171,7 @@ GST_START_TEST (test_periodic_shot)
|
||||||
g_message ("waiting some more for another async %p\n", id2);
|
g_message ("waiting some more for another async %p\n", id2);
|
||||||
result = gst_clock_id_wait_async (id2, ok_callback, NULL);
|
result = gst_clock_id_wait_async (id2, ok_callback, NULL);
|
||||||
fail_unless (result == GST_CLOCK_OK, "Waiting did not return OK");
|
fail_unless (result == GST_CLOCK_OK, "Waiting did not return OK");
|
||||||
g_usleep (2 * G_USEC_PER_SEC);
|
g_usleep (TIME_UNIT / (2 * 1000));
|
||||||
|
|
||||||
g_message ("unschedule %p\n", id);
|
g_message ("unschedule %p\n", id);
|
||||||
gst_clock_id_unschedule (id);
|
gst_clock_id_unschedule (id);
|
||||||
|
@ -184,7 +183,10 @@ GST_START_TEST (test_periodic_shot)
|
||||||
result = gst_clock_id_wait (id, NULL);
|
result = gst_clock_id_wait (id, NULL);
|
||||||
fail_unless (result == GST_CLOCK_UNSCHEDULED,
|
fail_unless (result == GST_CLOCK_UNSCHEDULED,
|
||||||
"Waiting did not return UNSCHEDULED");
|
"Waiting did not return UNSCHEDULED");
|
||||||
g_usleep (2 * G_USEC_PER_SEC);
|
g_usleep (TIME_UNIT / (2 * 1000));
|
||||||
|
|
||||||
|
/* clean up */
|
||||||
|
gst_clock_id_unref (id);
|
||||||
}
|
}
|
||||||
|
|
||||||
GST_END_TEST Suite * gst_systemclock_suite (void)
|
GST_END_TEST Suite * gst_systemclock_suite (void)
|
||||||
|
@ -192,9 +194,6 @@ GST_END_TEST Suite * gst_systemclock_suite (void)
|
||||||
Suite *s = suite_create ("GstSystemClock");
|
Suite *s = suite_create ("GstSystemClock");
|
||||||
TCase *tc_chain = tcase_create ("waiting");
|
TCase *tc_chain = tcase_create ("waiting");
|
||||||
|
|
||||||
/* increase timeout */
|
|
||||||
tcase_set_timeout (tc_chain, 20);
|
|
||||||
|
|
||||||
suite_add_tcase (s, tc_chain);
|
suite_add_tcase (s, tc_chain);
|
||||||
tcase_add_test (tc_chain, test_signedness);
|
tcase_add_test (tc_chain, test_signedness);
|
||||||
tcase_add_test (tc_chain, test_single_shot);
|
tcase_add_test (tc_chain, test_single_shot);
|
||||||
|
|
|
@ -171,6 +171,14 @@ GST_START_TEST (test_merge)
|
||||||
check_tags (merge, FTAG, FIXED1, NULL);
|
check_tags (merge, FTAG, FIXED1, NULL);
|
||||||
NEW_LISTS_FIXED (GST_TAG_MERGE_KEEP_ALL);
|
NEW_LISTS_FIXED (GST_TAG_MERGE_KEEP_ALL);
|
||||||
check_tags (merge, FTAG, FIXED1, NULL);
|
check_tags (merge, FTAG, FIXED1, NULL);
|
||||||
|
|
||||||
|
/* clean up */
|
||||||
|
if (list)
|
||||||
|
gst_tag_list_free (list);
|
||||||
|
if (list2)
|
||||||
|
gst_tag_list_free (list2);
|
||||||
|
if (merge)
|
||||||
|
gst_tag_list_free (merge);
|
||||||
}
|
}
|
||||||
|
|
||||||
GST_END_TEST Suite *
|
GST_END_TEST Suite *
|
||||||
|
|
Loading…
Reference in a new issue