+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>
* check/elements/.cvsignore:
$(top_builddir)/libs/gst/controller/libgstcontroller-@GST_MAJORMINOR@.la
# valgrind testing
-
-# these just need fixing, period
+# these just need valgrind fixing, period
TESTS_TO_FIX = \
- gst/gstghostpad \
- gst/gstiterator \
- gst/gstmessage \
- gst/gstsystemclock \
- gst/gsttag \
pipelines/cleanup \
pipelines/simple_launch_lines
iter = gst_iterator_new_list (m, &cookie, &l, NULL, NULL, NULL);
- g_return_if_fail (iter != NULL);
+ fail_unless (iter != NULL);
while (1) {
res = gst_iterator_next (iter, &item);
if (i < NUM_ELEMENTS) {
- g_return_if_fail (res == GST_ITERATOR_OK);
- g_return_if_fail (GPOINTER_TO_INT (item) == i);
+ fail_unless (res == GST_ITERATOR_OK);
+ fail_unless (GPOINTER_TO_INT (item) == i);
i++;
continue;
} else {
- g_return_if_fail (res == GST_ITERATOR_DONE);
+ fail_unless (res == GST_ITERATOR_DONE);
break;
}
}
+ /* clean up */
gst_iterator_free (iter);
+ g_mutex_free (m);
}
-GST_END_TEST
+GST_END_TEST;
+
GST_START_TEST (test_resync)
{
GList *l;
iter = gst_iterator_new_list (m, &cookie, &l, NULL, NULL, NULL);
- g_return_if_fail (iter != NULL);
+ fail_unless (iter != NULL);
while (1) {
res = gst_iterator_next (iter, &item);
if (i < NUM_ELEMENTS / 2) {
- g_return_if_fail (res == GST_ITERATOR_OK);
- g_return_if_fail (GPOINTER_TO_INT (item) == i);
+ fail_unless (res == GST_ITERATOR_OK);
+ fail_unless (GPOINTER_TO_INT (item) == i);
i++;
continue;
} else if (!hacked_list) {
/* 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));
cookie++;
hacked_list = TRUE;
continue;
} else {
- g_return_if_fail (res == GST_ITERATOR_RESYNC);
+ fail_unless (res == GST_ITERATOR_RESYNC);
gst_iterator_resync (iter);
res = gst_iterator_next (iter, &item);
- g_return_if_fail (res == GST_ITERATOR_OK);
- g_return_if_fail (GPOINTER_TO_INT (item) == -1);
+ fail_unless (res == GST_ITERATOR_OK);
+ fail_unless (GPOINTER_TO_INT (item) == -1);
break;
}
}
+ /* clean up */
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)
{
g_value_set_int (ret, g_value_get_int (ret) + GPOINTER_TO_INT (item));
l = make_list_of_ints (NUM_ELEMENTS);
m = g_mutex_new ();
iter = gst_iterator_new_list (m, &cookie, &l, NULL, NULL, NULL);
- g_return_if_fail (iter != NULL);
+ fail_unless (iter != NULL);
expected = 0;
for (i = 0; i < NUM_ELEMENTS; i++)
res = gst_iterator_fold (iter, add_fold_func, &ret, NULL);
- g_return_if_fail (res == GST_ITERATOR_DONE);
- g_return_if_fail (g_value_get_int (&ret) == expected);
+ fail_unless (res == GST_ITERATOR_DONE);
+ 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)
{
Suite *s = suite_create ("GstIterator");
}
GST_END_TEST
-#define TIME_UNIT GST_SECOND
+#define TIME_UNIT (GST_SECOND / 5)
static void
gst_clock_debug (GstClock * clock)
{
result = gst_clock_id_wait_async (id, ok_callback, NULL);
gst_clock_id_unref (id);
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);
g_message ("waiting one second async, with cancel on id %p\n", id);
result = gst_clock_id_wait_async (id, error_callback, NULL);
fail_unless (result == GST_CLOCK_OK, "Waiting did not return OK");
- g_usleep (G_USEC_PER_SEC / 2);
- g_message ("cancel id %p after 0.5 seconds\n", id);
+ g_usleep (TIME_UNIT / (2 * 1000));
+ g_message ("cancel id %p after half a time unit\n", id);
gst_clock_id_unschedule (id);
gst_clock_id_unref (id);
g_message ("canceled id %p\n", id);
g_message ("waiting id %p\n", id2);
result = gst_clock_id_wait_async (id2, error_callback, NULL);
fail_unless (result == GST_CLOCK_OK, "Waiting did not return OK");
- g_usleep (G_USEC_PER_SEC / 2);
- g_message ("cancel id %p after 0.5 seconds\n", id2);
+ g_usleep (TIME_UNIT / (2 * 1000));
+ g_message ("cancel id %p after half a time unit\n", id2);
gst_clock_id_unschedule (id2);
g_message ("canceled id %p\n", id2);
gst_clock_id_unref (id2);
-
- g_usleep (2 * G_USEC_PER_SEC);
+ g_usleep (TIME_UNIT / (2 * 1000));
}
GST_END_TEST
gst_clock_debug (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);
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);
gst_clock_debug (clock);
fail_unless (result == GST_CLOCK_OK, "Waiting did not return OK");
g_message ("waiting for the next async %p\n", id);
result = gst_clock_id_wait_async (id, ok_callback, NULL);
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);
result = gst_clock_id_wait_async (id, ok_callback, NULL);
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);
fail_unless (id2 != NULL, "Could not create second periodic id");
g_message ("waiting some more for another async %p\n", id2);
result = gst_clock_id_wait_async (id2, ok_callback, NULL);
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);
gst_clock_id_unschedule (id);
result = gst_clock_id_wait (id, NULL);
fail_unless (result == GST_CLOCK_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)
Suite *s = suite_create ("GstSystemClock");
TCase *tc_chain = tcase_create ("waiting");
- /* increase timeout */
- tcase_set_timeout (tc_chain, 20);
-
suite_add_tcase (s, tc_chain);
tcase_add_test (tc_chain, test_signedness);
tcase_add_test (tc_chain, test_single_shot);
check_tags (merge, FTAG, FIXED1, NULL);
NEW_LISTS_FIXED (GST_TAG_MERGE_KEEP_ALL);
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 *
* @clock: The clockid to get a single shot notification from
* @time: the requested time
*
- * Get an ID from the given clock to trigger a single shot
+ * Get an ID from the given clock to trigger a single shot
* notification at the requested time. The single shot id should be
* unreffed after usage.
*
*
* For each item retrieved, the @item function is called with the lock
* held. The @free function is called when the iterator is freed.
- *
+ *
* Returns: the new #GstIterator.
*
* MT safe.
* @item: function to call for each item
* @free: function to call when the iterator is freed
*
- * Create a new iterator designed for iterating @list.
- *
+ * Create a new iterator designed for iterating @list.
+ *
* Returns: the new #GstIterator for @list.
*
* MT safe.
* gst_iterator_free:
* @it: The #GstIterator to free
*
- * Free the iterator.
- *
+ * Free the iterator.
+ *
* MT safe.
*/
void
$(top_builddir)/libs/gst/controller/libgstcontroller-@GST_MAJORMINOR@.la
# valgrind testing
-
-# these just need fixing, period
+# these just need valgrind fixing, period
TESTS_TO_FIX = \
- gst/gstghostpad \
- gst/gstiterator \
- gst/gstmessage \
- gst/gstsystemclock \
- gst/gsttag \
pipelines/cleanup \
pipelines/simple_launch_lines
iter = gst_iterator_new_list (m, &cookie, &l, NULL, NULL, NULL);
- g_return_if_fail (iter != NULL);
+ fail_unless (iter != NULL);
while (1) {
res = gst_iterator_next (iter, &item);
if (i < NUM_ELEMENTS) {
- g_return_if_fail (res == GST_ITERATOR_OK);
- g_return_if_fail (GPOINTER_TO_INT (item) == i);
+ fail_unless (res == GST_ITERATOR_OK);
+ fail_unless (GPOINTER_TO_INT (item) == i);
i++;
continue;
} else {
- g_return_if_fail (res == GST_ITERATOR_DONE);
+ fail_unless (res == GST_ITERATOR_DONE);
break;
}
}
+ /* clean up */
gst_iterator_free (iter);
+ g_mutex_free (m);
}
-GST_END_TEST
+GST_END_TEST;
+
GST_START_TEST (test_resync)
{
GList *l;
iter = gst_iterator_new_list (m, &cookie, &l, NULL, NULL, NULL);
- g_return_if_fail (iter != NULL);
+ fail_unless (iter != NULL);
while (1) {
res = gst_iterator_next (iter, &item);
if (i < NUM_ELEMENTS / 2) {
- g_return_if_fail (res == GST_ITERATOR_OK);
- g_return_if_fail (GPOINTER_TO_INT (item) == i);
+ fail_unless (res == GST_ITERATOR_OK);
+ fail_unless (GPOINTER_TO_INT (item) == i);
i++;
continue;
} else if (!hacked_list) {
/* 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));
cookie++;
hacked_list = TRUE;
continue;
} else {
- g_return_if_fail (res == GST_ITERATOR_RESYNC);
+ fail_unless (res == GST_ITERATOR_RESYNC);
gst_iterator_resync (iter);
res = gst_iterator_next (iter, &item);
- g_return_if_fail (res == GST_ITERATOR_OK);
- g_return_if_fail (GPOINTER_TO_INT (item) == -1);
+ fail_unless (res == GST_ITERATOR_OK);
+ fail_unless (GPOINTER_TO_INT (item) == -1);
break;
}
}
+ /* clean up */
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)
{
g_value_set_int (ret, g_value_get_int (ret) + GPOINTER_TO_INT (item));
l = make_list_of_ints (NUM_ELEMENTS);
m = g_mutex_new ();
iter = gst_iterator_new_list (m, &cookie, &l, NULL, NULL, NULL);
- g_return_if_fail (iter != NULL);
+ fail_unless (iter != NULL);
expected = 0;
for (i = 0; i < NUM_ELEMENTS; i++)
res = gst_iterator_fold (iter, add_fold_func, &ret, NULL);
- g_return_if_fail (res == GST_ITERATOR_DONE);
- g_return_if_fail (g_value_get_int (&ret) == expected);
+ fail_unless (res == GST_ITERATOR_DONE);
+ 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)
{
Suite *s = suite_create ("GstIterator");
}
GST_END_TEST
-#define TIME_UNIT GST_SECOND
+#define TIME_UNIT (GST_SECOND / 5)
static void
gst_clock_debug (GstClock * clock)
{
result = gst_clock_id_wait_async (id, ok_callback, NULL);
gst_clock_id_unref (id);
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);
g_message ("waiting one second async, with cancel on id %p\n", id);
result = gst_clock_id_wait_async (id, error_callback, NULL);
fail_unless (result == GST_CLOCK_OK, "Waiting did not return OK");
- g_usleep (G_USEC_PER_SEC / 2);
- g_message ("cancel id %p after 0.5 seconds\n", id);
+ g_usleep (TIME_UNIT / (2 * 1000));
+ g_message ("cancel id %p after half a time unit\n", id);
gst_clock_id_unschedule (id);
gst_clock_id_unref (id);
g_message ("canceled id %p\n", id);
g_message ("waiting id %p\n", id2);
result = gst_clock_id_wait_async (id2, error_callback, NULL);
fail_unless (result == GST_CLOCK_OK, "Waiting did not return OK");
- g_usleep (G_USEC_PER_SEC / 2);
- g_message ("cancel id %p after 0.5 seconds\n", id2);
+ g_usleep (TIME_UNIT / (2 * 1000));
+ g_message ("cancel id %p after half a time unit\n", id2);
gst_clock_id_unschedule (id2);
g_message ("canceled id %p\n", id2);
gst_clock_id_unref (id2);
-
- g_usleep (2 * G_USEC_PER_SEC);
+ g_usleep (TIME_UNIT / (2 * 1000));
}
GST_END_TEST
gst_clock_debug (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);
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);
gst_clock_debug (clock);
fail_unless (result == GST_CLOCK_OK, "Waiting did not return OK");
g_message ("waiting for the next async %p\n", id);
result = gst_clock_id_wait_async (id, ok_callback, NULL);
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);
result = gst_clock_id_wait_async (id, ok_callback, NULL);
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);
fail_unless (id2 != NULL, "Could not create second periodic id");
g_message ("waiting some more for another async %p\n", id2);
result = gst_clock_id_wait_async (id2, ok_callback, NULL);
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);
gst_clock_id_unschedule (id);
result = gst_clock_id_wait (id, NULL);
fail_unless (result == GST_CLOCK_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)
Suite *s = suite_create ("GstSystemClock");
TCase *tc_chain = tcase_create ("waiting");
- /* increase timeout */
- tcase_set_timeout (tc_chain, 20);
-
suite_add_tcase (s, tc_chain);
tcase_add_test (tc_chain, test_signedness);
tcase_add_test (tc_chain, test_single_shot);
check_tags (merge, FTAG, FIXED1, NULL);
NEW_LISTS_FIXED (GST_TAG_MERGE_KEEP_ALL);
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 *