aboutsummaryrefslogtreecommitdiff
path: root/tests/check/libs
diff options
context:
space:
mode:
Diffstat (limited to 'tests/check/libs')
-rw-r--r--tests/check/libs/basesink.c52
-rw-r--r--tests/check/libs/libsabi.c8
-rw-r--r--tests/check/libs/queuearray.c189
3 files changed, 245 insertions, 4 deletions
diff --git a/tests/check/libs/basesink.c b/tests/check/libs/basesink.c
index 18842b3..595c4ce 100644
--- a/tests/check/libs/basesink.c
+++ b/tests/check/libs/basesink.c
@@ -117,6 +117,57 @@ GST_START_TEST (basesink_last_sample_disabled)
GST_END_TEST;
+GST_START_TEST (basesink_test_gap)
+{
+ GstElement *sink, *pipeline;
+ GstPad *pad;
+ GstBus *bus;
+ GstMessage *msg;
+ GstEvent *ev;
+ GstSegment segment;
+
+ pipeline = gst_pipeline_new ("pipeline");
+ sink = gst_element_factory_make ("fakesink", "sink");
+ g_object_set (sink, "sync", TRUE, NULL);
+
+ pad = gst_element_get_static_pad (sink, "sink");
+
+ fail_unless (gst_bin_add (GST_BIN (pipeline), sink) == TRUE);
+
+ bus = gst_element_get_bus (pipeline);
+
+ gst_element_set_state (pipeline, GST_STATE_PLAYING);
+
+ gst_segment_init (&segment, GST_FORMAT_TIME);
+ segment.stop = 120 * GST_SECOND;
+ ev = gst_event_new_segment (&segment);
+
+ fail_unless (gst_pad_send_event (pad, ev));
+
+ ev = gst_event_new_gap (200 * GST_MSECOND, GST_CLOCK_TIME_NONE);
+ fail_unless (gst_pad_send_event (pad, ev));
+
+ ev = gst_event_new_eos ();
+ fail_unless (gst_pad_send_event (pad, ev));
+
+ msg = gst_bus_poll (bus, GST_MESSAGE_EOS | GST_MESSAGE_ERROR, -1);
+
+ fail_unless (msg != NULL);
+ fail_unless (GST_MESSAGE_TYPE (msg) != GST_MESSAGE_ERROR);
+ fail_unless (GST_MESSAGE_TYPE (msg) == GST_MESSAGE_EOS);
+ gst_message_unref (msg);
+
+ gst_element_set_state (pipeline, GST_STATE_NULL);
+
+ GST_INFO ("stopped");
+
+ gst_object_unref (pad);
+ gst_object_unref (bus);
+ gst_object_unref (pipeline);
+}
+
+GST_END_TEST;
+
static Suite *
gst_basesrc_suite (void)
{
@@ -126,6 +177,7 @@ gst_basesrc_suite (void)
suite_add_tcase (s, tc);
tcase_add_test (tc, basesink_last_sample_enabled);
tcase_add_test (tc, basesink_last_sample_disabled);
+ tcase_add_test (tc, basesink_test_gap);
return s;
}
diff --git a/tests/check/libs/libsabi.c b/tests/check/libs/libsabi.c
index a5455a9..e24f4fb 100644
--- a/tests/check/libs/libsabi.c
+++ b/tests/check/libs/libsabi.c
@@ -50,7 +50,7 @@
#else
#ifdef __powerpc64__
#include "struct_ppc64.h"
-#define HAVE_ABI_SIZES TRUE
+#define HAVE_ABI_SIZES FALSE
#else
#ifdef __powerpc__
#include "struct_ppc32.h"
@@ -62,15 +62,15 @@
#else
#ifdef HAVE_CPU_HPPA
#include "struct_hppa.h"
-#define HAVE_ABI_SIZES TRUE
+#define HAVE_ABI_SIZES FALSE
#else
#ifdef HAVE_CPU_SPARC
#include "struct_sparc.h"
-#define HAVE_ABI_SIZES TRUE
+#define HAVE_ABI_SIZES FALSE
#else
#ifdef HAVE_CPU_ARM
#include "struct_arm.h"
-#define HAVE_ABI_SIZES TRUE
+#define HAVE_ABI_SIZES FALSE
#else
/* in case someone wants to generate a new arch */
#include "struct_i386.h"
diff --git a/tests/check/libs/queuearray.c b/tests/check/libs/queuearray.c
index ca5024b..b8fac2b 100644
--- a/tests/check/libs/queuearray.c
+++ b/tests/check/libs/queuearray.c
@@ -226,6 +226,192 @@ GST_START_TEST (test_array_grow_end)
GST_END_TEST;
+static int
+compare_pointer_value (gconstpointer a, gconstpointer b)
+{
+ return (int) ((guintptr) a - (guintptr) b);
+}
+
+GST_START_TEST (test_array_find)
+{
+ GstQueueArray *array;
+ guint i;
+ guint index;
+
+ guint random_initial = g_random_int_range (10, 100);
+ guint value_to_find = 5;
+
+ /* Create an array of initial size 10 */
+ array = gst_queue_array_new (10);
+ fail_unless_equals_int (array->size, 10);
+
+ while (random_initial--) {
+ gst_queue_array_push_tail (array, GINT_TO_POINTER (g_random_int ()));
+ gst_queue_array_pop_head (array);
+ }
+
+ /* push 10 values in */
+ for (i = 0; i < 10; i++)
+ gst_queue_array_push_tail (array, GINT_TO_POINTER (i));
+
+ fail_unless_equals_int (array->length, 10);
+ fail_unless_equals_int (array->size, 10);
+
+ index =
+ gst_queue_array_find (array, compare_pointer_value,
+ GINT_TO_POINTER (value_to_find));
+ fail_if (index == -1);
+ fail_unless_equals_int (value_to_find, GPOINTER_TO_INT (array->array[index]));
+
+ /* push 10 values in */
+ for (i = 0; i < 10; i++)
+ gst_queue_array_pop_head (array);
+
+ index =
+ gst_queue_array_find (array, compare_pointer_value,
+ GINT_TO_POINTER (value_to_find));
+ fail_unless (index == -1);
+
+ gst_queue_array_free (array);
+}
+
+GST_END_TEST;
+
+GST_START_TEST (test_array_drop)
+{
+ GstQueueArray *array;
+ guint i;
+ guint index;
+ guint index_2;
+
+ /* Create an array of initial size 10 */
+ array = gst_queue_array_new (10);
+ fail_unless_equals_int (array->size, 10);
+
+ for (i = 0; i < 5; i++)
+ gst_queue_array_push_tail (array, GINT_TO_POINTER (i));
+
+ fail_unless (array->length == 5);
+
+ /* Naive case remove head */
+ index =
+ gst_queue_array_find (array, compare_pointer_value, GINT_TO_POINTER (0));
+ fail_if (index == -1);
+ gst_queue_array_drop_element (array, index);
+ fail_unless (array->length == 4);
+ index =
+ gst_queue_array_find (array, compare_pointer_value, GINT_TO_POINTER (0));
+ fail_unless (index == -1);
+
+ /* Naive case remove tail */
+ index =
+ gst_queue_array_find (array, compare_pointer_value, GINT_TO_POINTER (4));
+ fail_if (index == -1);
+ gst_queue_array_drop_element (array, index);
+ fail_unless (array->length == 3);
+ index =
+ gst_queue_array_find (array, compare_pointer_value, GINT_TO_POINTER (4));
+ fail_unless (index == -1);
+
+ /* Remove in middle of non-wrapped */
+ index =
+ gst_queue_array_find (array, compare_pointer_value, GINT_TO_POINTER (2));
+ index_2 =
+ gst_queue_array_find (array, compare_pointer_value, GINT_TO_POINTER (3));
+ fail_if (index == -1);
+ fail_if (index_2 == -1);
+ gst_queue_array_drop_element (array, index);
+ fail_unless (array->length == 2);
+ index =
+ gst_queue_array_find (array, compare_pointer_value, GINT_TO_POINTER (2));
+ fail_unless (index == -1);
+ index_2 =
+ gst_queue_array_find (array, compare_pointer_value, GINT_TO_POINTER (3));
+ fail_if (index_2 == -1);
+
+ /* Remove the rest */
+ while (array->length)
+ gst_queue_array_pop_head (array);
+
+ /* Add until wrapping */
+ for (i = 0; i < 9; i++)
+ gst_queue_array_push_tail (array, GINT_TO_POINTER (i));
+
+ fail_unless (array->head > array->tail);
+
+ /* Remove from between head and array end */
+ index =
+ gst_queue_array_find (array, compare_pointer_value, GINT_TO_POINTER (1));
+ fail_if (index == -1);
+ fail_unless (index > array->head);
+ index_2 = array->head;
+ gst_queue_array_drop_element (array, index);
+ fail_unless (array->length == 8);
+ fail_if (array->head == index_2);
+ index =
+ gst_queue_array_find (array, compare_pointer_value, GINT_TO_POINTER (1));
+ fail_unless (index == -1);
+
+ /* Remove from between head and array end */
+ index =
+ gst_queue_array_find (array, compare_pointer_value, GINT_TO_POINTER (8));
+ fail_if (index == -1);
+ fail_unless (index < array->tail);
+ index_2 = array->tail;
+ gst_queue_array_drop_element (array, index);
+ fail_unless (array->length == 7);
+ fail_if (array->tail == index_2);
+ index =
+ gst_queue_array_find (array, compare_pointer_value, GINT_TO_POINTER (8));
+ fail_unless (index == -1);
+
+ gst_queue_array_free (array);
+}
+
+GST_END_TEST;
+
+GST_START_TEST (test_array_drop2)
+{
+#define NUM_QA_ELEMENTS 674
+ gboolean in_array[NUM_QA_ELEMENTS] = { FALSE, };
+ GstQueueArray *array;
+ guint i, j, count, idx;
+
+ array = gst_queue_array_new (10);
+
+ for (i = 0; i < NUM_QA_ELEMENTS; i++) {
+ gpointer element = GUINT_TO_POINTER (i);
+
+ if (g_random_boolean ()) {
+ gst_queue_array_push_tail (array, element);
+ in_array[i] = TRUE;
+ }
+ }
+
+ for (j = 0, count = 0; j < NUM_QA_ELEMENTS; j++)
+ count += in_array[j] ? 1 : 0;
+ fail_unless_equals_int (array->length, count);
+
+ while (array->length > 0) {
+ for (i = 0; i < NUM_QA_ELEMENTS; i++) {
+ if (g_random_boolean () && g_random_boolean () && in_array[i]) {
+ idx = gst_queue_array_find (array, compare_pointer_value,
+ GUINT_TO_POINTER (i));
+ gst_queue_array_drop_element (array, idx);
+ in_array[i] = FALSE;
+ }
+ }
+
+ for (j = 0, count = 0; j < NUM_QA_ELEMENTS; j++)
+ count += in_array[j] ? 1 : 0;
+ fail_unless_equals_int (array->length, count);
+ }
+
+ gst_queue_array_free (array);
+}
+
+GST_END_TEST;
+
static Suite *
gst_queue_array_suite (void)
{
@@ -239,6 +425,9 @@ gst_queue_array_suite (void)
tcase_add_test (tc_chain, test_array_grow_multiple);
tcase_add_test (tc_chain, test_array_grow_middle);
tcase_add_test (tc_chain, test_array_grow_end);
+ tcase_add_test (tc_chain, test_array_find);
+ tcase_add_test (tc_chain, test_array_drop);
+ tcase_add_test (tc_chain, test_array_drop2);
return s;
}