diff options
author | Mathieu Duponchelle <mathieu.duponchelle@epitech.eu> | 2013-05-27 20:52:36 +0200 |
---|---|---|
committer | Nicolas Dufresne <nicolas.dufresne@collabora.com> | 2013-05-28 17:04:21 -0400 |
commit | 8b1e549921f2543e94ffc1f8cbd6dc0ab2aa1ed4 (patch) | |
tree | 8bfb57bd75270b386e8055b6ea6d236f5f298fca | |
parent | 7ac0f028b1ebe0a3a8e06c98b1773a200335ebea (diff) |
tests: sanitization.
+ Create a no_install libtestutils.
+ Remove code from common.h to put it in common.c
+ Abstract away bus polling from test_simplest # TODO use it as much as possible.
+ Fix various little errors spotted thanks to new flags.
-rw-r--r-- | tests/check/Makefile.am | 22 | ||||
-rw-r--r-- | tests/check/gnl/common.c | 346 | ||||
-rw-r--r-- | tests/check/gnl/common.h | 320 | ||||
-rw-r--r-- | tests/check/gnl/complex.c | 2 | ||||
-rw-r--r-- | tests/check/gnl/gnlcomposition.c | 3 | ||||
-rw-r--r-- | tests/check/gnl/gnloperation.c | 2 | ||||
-rw-r--r-- | tests/check/gnl/gnlsource.c | 2 | ||||
-rw-r--r-- | tests/check/gnl/seek.c | 2 | ||||
-rw-r--r-- | tests/check/gnl/simple.c | 65 |
9 files changed, 392 insertions, 372 deletions
diff --git a/tests/check/Makefile.am b/tests/check/Makefile.am index 4524bf8..cb8ce91 100644 --- a/tests/check/Makefile.am +++ b/tests/check/Makefile.am @@ -15,10 +15,27 @@ TESTS_ENVIRONMENT = \ # ths core dumps of some machines have PIDs appended CLEANFILES = core.* test-registry.xml +common_cflags=-I$(top_srcdir) $(GST_PLUGINS_BASE_CFLAGS) $(GST_OBJ_CFLAGS) \ + $(GST_CHECK_CFLAGS) $(GST_OPTION_CFLAGS) $(GST_CFLAGS) +common_ldadd= $(GST_PLUGINS_BASE_LIBS) \ + $(GST_OBJ_LIBS) $(GST_CHECK_LIBS) $(CHECK_LIBS) + +testutils_noisnt_libraries=libtestutils.la +testutils_noinst_headers=gnl/common.h +libtestutils_la_LIBADD=$(common_ldadd) +libtestutils_la_CFLAGS=$(common_cflags) +libtestutils_la_SOURCES=gnl/common.c + clean-local: clean-local-check +noinst_LTLIBRARIES=$(testutils_noisnt_libraries) +noinst_HEADERS=$(testutils_noinst_headers) + TESTS = $(check_PROGRAMS) +AM_CFLAGS = $(common_cflags) -UG_DISABLE_ASSERT -UG_DISABLE_CAST_CHECKS -DGST_USE_UNSTABLE_API +LDADD = $(common_ldadd) libtestutils.la + check_PROGRAMS = \ gnl/simple \ gnl/complex \ @@ -27,12 +44,7 @@ check_PROGRAMS = \ gnl/gnlcomposition \ gnl/seek -noinst_HEADERS = \ - gnl/common.h # these tests don't even pass noinst_PROGRAMS = -AM_CFLAGS = -DGST_USE_UNSTABLE_API $(GST_OBJ_CFLAGS) $(GST_CHECK_CFLAGS) $(CHECK_CFLAGS) -LDADD = $(GST_OBJ_LIBS) $(GST_CHECK_LIBS) $(CHECK_LIBS) - SUPPRESSIONS = $(top_srcdir)/common/gst.supp diff --git a/tests/check/gnl/common.c b/tests/check/gnl/common.c new file mode 100644 index 0000000..479f7ab --- /dev/null +++ b/tests/check/gnl/common.c @@ -0,0 +1,346 @@ +#include "common.h" + +void +poll_the_bus (GstBus * bus) +{ + GstMessage *message; + gboolean carry_on = TRUE; + + while (carry_on) { + message = gst_bus_poll (bus, GST_MESSAGE_ANY, GST_SECOND / 10); + if (message) { + switch (GST_MESSAGE_TYPE (message)) { + case GST_MESSAGE_EOS: + /* we should check if we really finished here */ + GST_DEBUG ("Got an EOS"); + carry_on = FALSE; + break; + case GST_MESSAGE_SEGMENT_START: + case GST_MESSAGE_SEGMENT_DONE: + /* We shouldn't see any segement messages, since we didn't do a segment seek */ + GST_WARNING ("Saw a Segment start/stop"); + fail_if (TRUE); + break; + case GST_MESSAGE_ERROR: + fail_error_message (message); + default: + break; + } + gst_mini_object_unref (GST_MINI_OBJECT (message)); + } + } +} + +GstElement * +gst_element_factory_make_or_warn (const gchar * factoryname, const gchar * name) +{ + GstElement *element; + + element = gst_element_factory_make (factoryname, name); + fail_unless (element != NULL, "Failed to make element %s", factoryname); + return element; +} + +void +composition_pad_added_cb (GstElement * composition, GstPad * pad, + CollectStructure * collect) +{ + fail_if (!(gst_element_link_pads_full (composition, GST_OBJECT_NAME (pad), + collect->sink, "sink", GST_PAD_LINK_CHECK_NOTHING))); +} + +/* return TRUE to discard the Segment */ +static gboolean +compare_segments (CollectStructure * collect, Segment * segment, + GstEvent * event) +{ + const GstSegment *orig; + guint64 running_stop, running_start, running_duration; + + gst_event_parse_segment (event, &orig); + + GST_DEBUG ("Got Segment rate:%f, format:%s, start:%" GST_TIME_FORMAT + ", stop:%" GST_TIME_FORMAT ", time:%" GST_TIME_FORMAT + ", base:%" GST_TIME_FORMAT ", offset:%" GST_TIME_FORMAT, + orig->rate, gst_format_get_name (orig->format), + GST_TIME_ARGS (orig->start), GST_TIME_ARGS (orig->stop), + GST_TIME_ARGS (orig->time), GST_TIME_ARGS (orig->base), + GST_TIME_ARGS (orig->offset)); + GST_DEBUG ("[RUNNING] start:%" GST_TIME_FORMAT " [STREAM] start:%" + GST_TIME_FORMAT, GST_TIME_ARGS (gst_segment_to_running_time (orig, + GST_FORMAT_TIME, orig->start)), + GST_TIME_ARGS (gst_segment_to_stream_time (orig, GST_FORMAT_TIME, + orig->start))); + + GST_DEBUG ("Expecting rate:%f, format:%s, start:%" GST_TIME_FORMAT + ", stop:%" GST_TIME_FORMAT ", position:%" GST_TIME_FORMAT ", base:%" + GST_TIME_FORMAT, segment->rate, gst_format_get_name (segment->format), + GST_TIME_ARGS (segment->start), GST_TIME_ARGS (segment->stop), + GST_TIME_ARGS (segment->position), + GST_TIME_ARGS (collect->expected_base)); + + running_start = + gst_segment_to_running_time (orig, GST_FORMAT_TIME, orig->start); + running_stop = + gst_segment_to_running_time (orig, GST_FORMAT_TIME, orig->stop); + running_duration = running_stop - running_start; + fail_if (orig->rate != segment->rate); + fail_if (orig->format != segment->format); + fail_unless_equals_int64 (orig->time, segment->position); + fail_unless_equals_int64 (orig->base, collect->expected_base); + fail_unless_equals_uint64 (orig->stop - orig->start, + segment->stop - segment->start); + + collect->expected_base += running_duration; + + GST_DEBUG ("Segment was valid, discarding expected Segment"); + + return TRUE; +} + +static GstPadProbeReturn +sinkpad_event_probe (GstPad * sinkpad, GstEvent * event, + CollectStructure * collect) +{ + Segment *segment; + + GST_DEBUG_OBJECT (sinkpad, "event:%p (%s seqnum:%d) , collect:%p", event, + GST_EVENT_TYPE_NAME (event), GST_EVENT_SEQNUM (event), collect); + + if (GST_EVENT_TYPE (event) == GST_EVENT_SEGMENT) { + fail_if (collect->expected_segments == NULL, "Received unexpected segment"); + + if (!collect->gotsegment) + collect->seen_segments = + g_list_append (NULL, GINT_TO_POINTER (GST_EVENT_SEQNUM (event))); + else { + fail_if (g_list_find (collect->seen_segments, + GINT_TO_POINTER (GST_EVENT_SEQNUM (event))), + "Got a segment event we already saw before !"); + collect->seen_segments = + g_list_append (collect->seen_segments, + GINT_TO_POINTER (GST_EVENT_SEQNUM (event))); + } + + segment = (Segment *) collect->expected_segments->data; + + if (compare_segments (collect, segment, event)) { + collect->expected_segments = + g_list_remove (collect->expected_segments, segment); + g_free (segment); + } + collect->gotsegment = TRUE; + } + + return GST_PAD_PROBE_OK; +} + +static GstPadProbeReturn +sinkpad_buffer_probe (GstPad * sinkpad, GstBuffer * buffer, + CollectStructure * collect) +{ + GST_DEBUG_OBJECT (sinkpad, "buffer:%p (%" GST_TIME_FORMAT ") , collect:%p", + buffer, GST_TIME_ARGS (GST_BUFFER_TIMESTAMP (buffer)), collect); + fail_if (!collect->gotsegment, + "Received a buffer without a preceding segment"); + return GST_PAD_PROBE_OK; +} + +GstPadProbeReturn +sinkpad_probe (GstPad * sinkpad, GstPadProbeInfo * info, + CollectStructure * collect) +{ + if (info->type & GST_PAD_PROBE_TYPE_BUFFER) + return sinkpad_buffer_probe (sinkpad, (GstBuffer *) info->data, collect); + if (info->type & GST_PAD_PROBE_TYPE_EVENT_DOWNSTREAM) + return sinkpad_event_probe (sinkpad, (GstEvent *) info->data, collect); + return GST_PAD_PROBE_OK; +} + +static GstElement * +new_gnl_src (const gchar * name, guint64 start, gint64 duration, gint priority) +{ + GstElement *gnlsource = NULL; + + gnlsource = gst_element_factory_make_or_warn ("gnlsource", name); + fail_if (gnlsource == NULL); + + g_object_set (G_OBJECT (gnlsource), + "start", start, + "duration", duration, + "media-start", start, + "media-duration", duration, "priority", priority, NULL); + + return gnlsource; +} + +GstElement * +videotest_gnl_src (const gchar * name, guint64 start, gint64 duration, + gint pattern, guint priority) +{ + GstElement *gnlsource = NULL; + GstElement *videotestsrc = NULL; + GstCaps *caps = + gst_caps_from_string + ("video/x-raw,format=(string)I420,framerate=(fraction)3/2"); + + fail_if (caps == NULL); + + videotestsrc = gst_element_factory_make_or_warn ("videotestsrc", NULL); + g_object_set (G_OBJECT (videotestsrc), "pattern", pattern, NULL); + + gnlsource = new_gnl_src (name, start, duration, priority); + g_object_set (G_OBJECT (gnlsource), "caps", caps, NULL); + gst_caps_unref (caps); + + gst_bin_add (GST_BIN (gnlsource), videotestsrc); + + return gnlsource; +} + +GstElement * +videotest_gnl_src_full (const gchar * name, guint64 start, gint64 duration, + guint64 mediastart, gint64 mediaduration, gint pattern, guint priority) +{ + GstElement *gnls; + + gnls = videotest_gnl_src (name, start, duration, pattern, priority); + if (gnls) { + g_object_set (G_OBJECT (gnls), + "media-start", mediastart, "media-duration", mediaduration, NULL); + } + + return gnls; +} + +GstElement * +videotest_in_bin_gnl_src (const gchar * name, guint64 start, gint64 duration, + gint pattern, guint priority) +{ + GstElement *gnlsource = NULL; + GstElement *videotestsrc = NULL; + GstElement *bin = NULL; + GstElement *alpha = NULL; + GstPad *srcpad = NULL; + + alpha = gst_element_factory_make ("alpha", NULL); + if (alpha == NULL) + return NULL; + + videotestsrc = gst_element_factory_make_or_warn ("videotestsrc", NULL); + g_object_set (G_OBJECT (videotestsrc), "pattern", pattern, NULL); + bin = gst_bin_new (NULL); + + gnlsource = new_gnl_src (name, start, duration, priority); + + gst_bin_add (GST_BIN (bin), videotestsrc); + gst_bin_add (GST_BIN (bin), alpha); + + gst_element_link_pads_full (videotestsrc, "src", alpha, "sink", + GST_PAD_LINK_CHECK_NOTHING); + + gst_bin_add (GST_BIN (gnlsource), bin); + + srcpad = gst_element_get_static_pad (alpha, "src"); + + gst_element_add_pad (bin, gst_ghost_pad_new ("src", srcpad)); + + gst_object_unref (srcpad); + + return gnlsource; +} + +GstElement * +audiotest_bin_src (const gchar * name, guint64 start, + gint64 duration, guint priority, gboolean intaudio) +{ + GstElement *source = NULL; + GstElement *identity = NULL; + GstElement *audiotestsrc = NULL; + GstElement *audioconvert = NULL; + GstElement *bin = NULL; + GstCaps *caps; + GstPad *srcpad = NULL; + + audiotestsrc = gst_element_factory_make_or_warn ("audiotestsrc", NULL); + identity = gst_element_factory_make_or_warn ("identity", NULL); + bin = gst_bin_new (NULL); + source = new_gnl_src (name, start, duration, priority); + audioconvert = gst_element_factory_make_or_warn ("audioconvert", NULL); + + if (intaudio) + caps = gst_caps_from_string ("audio/x-raw,format=(string)S16LE"); + else + caps = gst_caps_from_string ("audio/x-raw,format=(string)F32LE"); + + gst_bin_add_many (GST_BIN (bin), audiotestsrc, audioconvert, identity, NULL); + gst_element_link_pads_full (audiotestsrc, "src", audioconvert, "sink", + GST_PAD_LINK_CHECK_NOTHING); + fail_if ((gst_element_link_filtered (audioconvert, identity, caps)) != TRUE); + + gst_caps_unref (caps); + + gst_bin_add (GST_BIN (source), bin); + + srcpad = gst_element_get_static_pad (identity, "src"); + + gst_element_add_pad (bin, gst_ghost_pad_new ("src", srcpad)); + + gst_object_unref (srcpad); + + return source; +} + +GstElement * +new_operation (const gchar * name, const gchar * factory, guint64 start, + gint64 duration, guint priority) +{ + GstElement *gnloperation = NULL; + GstElement *operation = NULL; + + operation = gst_element_factory_make_or_warn (factory, NULL); + gnloperation = gst_element_factory_make_or_warn ("gnloperation", name); + + g_object_set (G_OBJECT (gnloperation), + "start", start, "duration", duration, "priority", priority, NULL); + + gst_bin_add (GST_BIN (gnloperation), operation); + + return gnloperation; +} + + +Segment * +segment_new (gdouble rate, GstFormat format, gint64 start, gint64 stop, + gint64 position) +{ + Segment *segment; + + segment = g_new0 (Segment, 1); + + segment->rate = rate; + segment->format = format; + segment->start = start; + segment->stop = stop; + segment->position = position; + + return segment; +} + +GList * +copy_segment_list (GList * list) +{ + GList *res = NULL; + + while (list) { + Segment *pdata = (Segment *) list->data; + + res = + g_list_append (res, segment_new (pdata->rate, pdata->format, + pdata->start, pdata->stop, pdata->position)); + + list = list->next; + } + + return res; +} diff --git a/tests/check/gnl/common.h b/tests/check/gnl/common.h index 13bfe74..6a2a0ef 100644 --- a/tests/check/gnl/common.h +++ b/tests/check/gnl/common.h @@ -48,304 +48,24 @@ typedef struct _CollectStructure { guint64 expected_base; } CollectStructure; -static GstElement * -gst_element_factory_make_or_warn (const gchar * factoryname, const gchar * name) -{ - GstElement * element; - - element = gst_element_factory_make (factoryname, name); - fail_unless (element != NULL, "Failed to make element %s", factoryname); - return element; -} - -static void -composition_pad_added_cb (GstElement *composition, GstPad *pad, CollectStructure * collect) -{ - fail_if (!(gst_element_link_pads_full (composition, GST_OBJECT_NAME (pad), collect->sink, "sink", - GST_PAD_LINK_CHECK_NOTHING))); -} - -/* return TRUE to discard the Segment */ -static gboolean -compare_segments (CollectStructure *collect, Segment * segment, GstEvent * event) -{ - const GstSegment *orig; - guint64 running_stop, running_start, running_duration; - - gst_event_parse_segment (event, &orig); - - GST_DEBUG ("Got Segment rate:%f, format:%s, start:%"GST_TIME_FORMAT - ", stop:%"GST_TIME_FORMAT", time:%"GST_TIME_FORMAT - ", base:%"GST_TIME_FORMAT", offset:%"GST_TIME_FORMAT, - orig->rate, gst_format_get_name(orig->format), GST_TIME_ARGS (orig->start), - GST_TIME_ARGS (orig->stop), - GST_TIME_ARGS (orig->time), - GST_TIME_ARGS (orig->base), - GST_TIME_ARGS (orig->offset)); - GST_DEBUG ("[RUNNING] start:%"GST_TIME_FORMAT" [STREAM] start:%"GST_TIME_FORMAT, - GST_TIME_ARGS (gst_segment_to_running_time (orig, GST_FORMAT_TIME, orig->start)), - GST_TIME_ARGS (gst_segment_to_stream_time (orig, GST_FORMAT_TIME, orig->start))); - - GST_DEBUG ("Expecting rate:%f, format:%s, start:%"GST_TIME_FORMAT - ", stop:%"GST_TIME_FORMAT", position:%"GST_TIME_FORMAT", base:%"GST_TIME_FORMAT, - segment->rate, gst_format_get_name (segment->format), - GST_TIME_ARGS (segment->start), - GST_TIME_ARGS (segment->stop), - GST_TIME_ARGS (segment->position), - GST_TIME_ARGS (collect->expected_base)); - - running_start = gst_segment_to_running_time (orig, GST_FORMAT_TIME, orig->start); - running_stop = gst_segment_to_running_time (orig, GST_FORMAT_TIME, orig->stop); - running_duration = running_stop - running_start; - fail_if (orig->rate != segment->rate); - fail_if (orig->format != segment->format); - fail_unless_equals_int64 (orig->time, segment->position); - fail_unless_equals_int64 (orig->base, collect->expected_base); - fail_unless_equals_uint64 (orig->stop - orig->start, segment->stop -segment->start); - - collect->expected_base += running_duration; - - GST_DEBUG ("Segment was valid, discarding expected Segment"); - - return TRUE; -} - -static GstPadProbeReturn -sinkpad_event_probe (GstPad * sinkpad, GstEvent * event, CollectStructure * collect) -{ - Segment * segment; - - GST_DEBUG_OBJECT (sinkpad, "event:%p (%s seqnum:%d) , collect:%p", event, - GST_EVENT_TYPE_NAME (event), - GST_EVENT_SEQNUM (event), collect); - - if (GST_EVENT_TYPE (event) == GST_EVENT_SEGMENT) { - fail_if (collect->expected_segments == NULL, "Received unexpected segment"); - - if (!collect->gotsegment) - collect->seen_segments = g_list_append(NULL, GINT_TO_POINTER(GST_EVENT_SEQNUM(event))); - else { - fail_if(g_list_find(collect->seen_segments, GINT_TO_POINTER(GST_EVENT_SEQNUM(event))), - "Got a segment event we already saw before !"); - collect->seen_segments = g_list_append(collect->seen_segments, GINT_TO_POINTER(GST_EVENT_SEQNUM(event))); - } - - segment = (Segment *) collect->expected_segments->data; - - if (compare_segments (collect, segment, event)) { - collect->expected_segments = g_list_remove (collect->expected_segments, segment); - g_free (segment); - } - collect->gotsegment = TRUE; - } - - return GST_PAD_PROBE_OK; -} - -static GstPadProbeReturn -sinkpad_buffer_probe (GstPad * sinkpad, GstBuffer * buffer, CollectStructure * collect) -{ - GST_DEBUG_OBJECT (sinkpad, "buffer:%p (%"GST_TIME_FORMAT") , collect:%p", buffer, - GST_TIME_ARGS (GST_BUFFER_TIMESTAMP (buffer)), collect); - fail_if(!collect->gotsegment, "Received a buffer without a preceding segment"); - return GST_PAD_PROBE_OK; -} - -static GstPadProbeReturn -sinkpad_probe (GstPad *sinkpad, GstPadProbeInfo * info, CollectStructure * collect) -{ - if (info->type & GST_PAD_PROBE_TYPE_BUFFER) - return sinkpad_buffer_probe (sinkpad, (GstBuffer*) info->data, collect); - if (info->type & GST_PAD_PROBE_TYPE_EVENT_DOWNSTREAM) - return sinkpad_event_probe (sinkpad, (GstEvent *) info->data, collect); - return GST_PAD_PROBE_OK; -} - -static GstElement * -new_gnl_src (const gchar * name, guint64 start, gint64 duration, gint priority) -{ - GstElement * gnlsource = NULL; - - gnlsource = gst_element_factory_make_or_warn ("gnlsource", name); - fail_if (gnlsource == NULL); - - g_object_set (G_OBJECT (gnlsource), - "start", start, - "duration", duration, - "media-start", start, - "media-duration", duration, - "priority", priority, - NULL); - - return gnlsource; -} - -static GstElement * -videotest_gnl_src (const gchar * name, guint64 start, gint64 duration, - gint pattern, guint priority) -{ - GstElement * gnlsource = NULL; - GstElement * videotestsrc = NULL; - GstCaps * caps = gst_caps_from_string ("video/x-raw,format=(string)I420,framerate=(fraction)3/2"); - - fail_if (caps == NULL); - - videotestsrc = gst_element_factory_make_or_warn ("videotestsrc", NULL); - g_object_set (G_OBJECT (videotestsrc), "pattern", pattern, NULL); - - gnlsource = new_gnl_src (name, start, duration, priority); - g_object_set (G_OBJECT (gnlsource), "caps", caps, NULL); - gst_caps_unref(caps); - - gst_bin_add (GST_BIN (gnlsource), videotestsrc); - - return gnlsource; -} - -static GstElement * -videotest_gnl_src_full (const gchar * name, guint64 start, gint64 duration, - guint64 mediastart, gint64 mediaduration, - gint pattern, guint priority) -{ - GstElement * gnls; - - gnls = videotest_gnl_src (name, start, duration, pattern, priority); - if (gnls) { - g_object_set (G_OBJECT (gnls), - "media-start", mediastart, - "media-duration", mediaduration, - NULL); - } - - return gnls; -} - -static GstElement * -videotest_in_bin_gnl_src (const gchar * name, guint64 start, gint64 duration, gint pattern, guint priority) -{ - GstElement * gnlsource = NULL; - GstElement * videotestsrc = NULL; - GstElement * bin = NULL; - GstElement * alpha = NULL; - GstPad *srcpad = NULL; - - alpha = gst_element_factory_make ("alpha", NULL); - if (alpha == NULL) - return NULL; - - videotestsrc = gst_element_factory_make_or_warn ("videotestsrc", NULL); - g_object_set (G_OBJECT (videotestsrc), "pattern", pattern, NULL); - bin = gst_bin_new (NULL); - - gnlsource = new_gnl_src (name, start, duration, priority); - - gst_bin_add (GST_BIN (bin), videotestsrc); - gst_bin_add (GST_BIN (bin), alpha); - - gst_element_link_pads_full (videotestsrc, "src", alpha, "sink", - GST_PAD_LINK_CHECK_NOTHING); - - gst_bin_add (GST_BIN (gnlsource), bin); - - srcpad = gst_element_get_static_pad (alpha, "src"); - - gst_element_add_pad (bin, gst_ghost_pad_new ("src", srcpad)); - - gst_object_unref (srcpad); - - return gnlsource; -} - -static GstElement * +void poll_the_bus(GstBus *bus); +void composition_pad_added_cb (GstElement *composition, GstPad *pad, CollectStructure * collect); +GstPadProbeReturn sinkpad_probe (GstPad *sinkpad, GstPadProbeInfo * info, CollectStructure * collect); +GstElement *videotest_gnl_src (const gchar * name, guint64 start, gint64 duration, + gint pattern, guint priority); +GstElement * videotest_gnl_src_full (const gchar * name, guint64 start, gint64 duration, + guint64 mediastart, gint64 mediaduration, + gint pattern, guint priority); +GstElement * +videotest_in_bin_gnl_src (const gchar * name, guint64 start, gint64 duration, gint pattern, guint priority); +GstElement * audiotest_bin_src (const gchar * name, guint64 start, - gint64 duration, guint priority, gboolean intaudio) -{ - GstElement * source = NULL; - GstElement * identity = NULL; - GstElement * audiotestsrc = NULL; - GstElement * audioconvert = NULL; - GstElement * bin = NULL; - GstCaps * caps; - GstPad *srcpad = NULL; - - audiotestsrc = gst_element_factory_make_or_warn ("audiotestsrc", NULL); - identity = gst_element_factory_make_or_warn ("identity", NULL); - bin = gst_bin_new (NULL); - source = new_gnl_src (name, start, duration, priority); - audioconvert = gst_element_factory_make_or_warn ("audioconvert", NULL); - - if (intaudio) - caps = gst_caps_from_string ("audio/x-raw,format=(string)S16LE"); - else - caps = gst_caps_from_string ("audio/x-raw,format=(string)F32LE"); - - gst_bin_add_many (GST_BIN (bin), audiotestsrc, audioconvert, identity, NULL); - gst_element_link_pads_full (audiotestsrc, "src", audioconvert, "sink", - GST_PAD_LINK_CHECK_NOTHING); - fail_if ((gst_element_link_filtered (audioconvert, identity, caps)) != TRUE); - - gst_caps_unref (caps); - - gst_bin_add (GST_BIN (source), bin); - - srcpad = gst_element_get_static_pad (identity, "src"); - - gst_element_add_pad (bin, gst_ghost_pad_new ("src", srcpad)); - - gst_object_unref (srcpad); - - return source; -} - -static GstElement * -new_operation (const gchar * name, const gchar * factory, guint64 start, gint64 duration, guint priority) -{ - GstElement * gnloperation = NULL; - GstElement * operation = NULL; - - operation = gst_element_factory_make_or_warn (factory, NULL); - gnloperation = gst_element_factory_make_or_warn ("gnloperation", name); - - g_object_set (G_OBJECT (gnloperation), - "start", start, - "duration", duration, - "priority", priority, - NULL); - - gst_bin_add (GST_BIN (gnloperation), operation); - - return gnloperation; -} - - -static Segment * -segment_new (gdouble rate, GstFormat format, gint64 start, gint64 stop, gint64 position) -{ - Segment * segment; - - segment = g_new0 (Segment, 1); - - segment->rate = rate; - segment->format = format; - segment->start = start; - segment->stop = stop; - segment->position = position; - - return segment; -} - -static GList * -copy_segment_list (GList *list) -{ - GList *res = NULL; - - while (list) { - Segment *pdata = (Segment*) list->data; - - res = g_list_append(res, segment_new(pdata->rate, pdata->format, pdata->start, pdata->stop, pdata->position)); - - list = list->next; - } - - return res; -} + gint64 duration, guint priority, gboolean intaudio); +GstElement * +new_operation (const gchar * name, const gchar * factory, guint64 start, gint64 duration, guint priority); +GList * +copy_segment_list (GList *list); +GstElement * +gst_element_factory_make_or_warn (const gchar * factoryname, const gchar * name); +Segment * +segment_new (gdouble rate, GstFormat format, gint64 start, gint64 stop, gint64 position); diff --git a/tests/check/gnl/complex.c b/tests/check/gnl/complex.c index ee8aa07..423903c 100644 --- a/tests/check/gnl/complex.c +++ b/tests/check/gnl/complex.c @@ -780,7 +780,7 @@ GST_START_TEST (test_one_above_another) GST_END_TEST; -Suite * +static Suite * gnonlin_suite (void) { Suite *s = suite_create ("gnonlin-complex"); diff --git a/tests/check/gnl/gnlcomposition.c b/tests/check/gnl/gnlcomposition.c index c48dc40..5a2c372 100644 --- a/tests/check/gnl/gnlcomposition.c +++ b/tests/check/gnl/gnlcomposition.c @@ -476,7 +476,8 @@ GST_START_TEST (test_simple_adder) if (GST_CLOCK_DIFF (start_playing_time, gst_util_get_timestamp ()) > total_time + GST_SECOND) { - GST_ERROR ("No EOS found after %i sec", (total_time / GST_SECOND) + 1); + GST_ERROR ("No EOS found after %" GST_TIME_FORMAT " sec", + GST_TIME_ARGS ((total_time / GST_SECOND) + 1)); GST_DEBUG_BIN_TO_DOT_FILE_WITH_TS (GST_BIN (pipeline), GST_DEBUG_GRAPH_SHOW_ALL, "gnl-simple-adder-test-fail"); diff --git a/tests/check/gnl/gnloperation.c b/tests/check/gnl/gnloperation.c index e4499b9..e017938 100644 --- a/tests/check/gnl/gnloperation.c +++ b/tests/check/gnl/gnloperation.c @@ -678,7 +678,7 @@ GST_END_TEST; -Suite * +static Suite * gnonlin_suite (void) { Suite *s = suite_create ("gnloperation"); diff --git a/tests/check/gnl/gnlsource.c b/tests/check/gnl/gnlsource.c index 1325a09..07bb7aa 100644 --- a/tests/check/gnl/gnlsource.c +++ b/tests/check/gnl/gnlsource.c @@ -203,7 +203,7 @@ GST_START_TEST (test_videotestsrc_in_bin) GST_END_TEST; -Suite * +static Suite * gnonlin_suite (void) { Suite *s = suite_create ("gnlsource"); diff --git a/tests/check/gnl/seek.c b/tests/check/gnl/seek.c index 07c2828..f6f3c93 100644 --- a/tests/check/gnl/seek.c +++ b/tests/check/gnl/seek.c @@ -718,7 +718,7 @@ GST_START_TEST (test_one_bin_after_other) GST_END_TEST; -Suite * +static Suite * gnonlin_suite (void) { Suite *s = suite_create ("gnonlin-seek"); diff --git a/tests/check/gnl/simple.c b/tests/check/gnl/simple.c index ba58f21..14b269f 100644 --- a/tests/check/gnl/simple.c +++ b/tests/check/gnl/simple.c @@ -1,6 +1,5 @@ #include "common.h" - /* macros for 'update' property enabling */ #define DISABLE_ASYNC_UPDATE { if (async) g_object_set(comp, "update", FALSE, NULL); } #define ENABLE_ASYNC_UPDATE { if (async) g_object_set(comp, "update", TRUE, NULL); } @@ -12,8 +11,6 @@ test_simplest_full (gboolean async) GstElement *comp, *sink, *source1; CollectStructure *collect; GstBus *bus; - GstMessage *message; - gboolean carry_on = TRUE; GstPad *sinkpad; pipeline = gst_pipeline_new ("test_pipeline"); @@ -75,29 +72,7 @@ test_simplest_full (gboolean async) GST_DEBUG ("Let's poll the bus"); - while (carry_on) { - message = gst_bus_poll (bus, GST_MESSAGE_ANY, GST_SECOND / 10); - if (message) { - switch (GST_MESSAGE_TYPE (message)) { - case GST_MESSAGE_EOS: - /* we should check if we really finished here */ - GST_WARNING ("Got an EOS"); - carry_on = FALSE; - break; - case GST_MESSAGE_SEGMENT_START: - case GST_MESSAGE_SEGMENT_DONE: - /* We shouldn't see any segement messages, since we didn't do a segment seek */ - GST_WARNING ("Saw a Segment start/stop"); - fail_if (TRUE); - break; - case GST_MESSAGE_ERROR: - fail_error_message (message); - default: - break; - } - gst_mini_object_unref (GST_MINI_OBJECT (message)); - } - } + poll_the_bus (bus); GST_DEBUG ("Setting pipeline to NULL"); @@ -119,34 +94,9 @@ test_simplest_full (gboolean async) fail_if (gst_element_set_state (GST_ELEMENT (pipeline), GST_STATE_PLAYING) == GST_STATE_CHANGE_FAILURE); - carry_on = TRUE; - GST_DEBUG ("Let's poll the bus AGAIN"); - while (carry_on) { - message = gst_bus_poll (bus, GST_MESSAGE_ANY, GST_SECOND / 10); - if (message) { - switch (GST_MESSAGE_TYPE (message)) { - case GST_MESSAGE_EOS: - /* we should check if we really finished here */ - carry_on = FALSE; - break; - case GST_MESSAGE_SEGMENT_START: - case GST_MESSAGE_SEGMENT_DONE: - /* We shouldn't see any segement messages, since we didn't do a segment seek */ - GST_WARNING ("Saw a Segment start/stop"); - fail_if (TRUE); - break; - case GST_MESSAGE_ERROR: - fail_error_message (message); - default: - break; - } - gst_mini_object_unref (GST_MINI_OBJECT (message)); - } else { - GST_DEBUG ("bus_poll responded, but there wasn't any message..."); - } - } + poll_the_bus (bus); fail_if (collect->expected_segments != NULL); @@ -851,16 +801,7 @@ GST_START_TEST (test_one_bin_after_other) GST_END_TEST; -GST_START_TEST (test_one_bin_after_other_async) -{ - test_one_bin_after_other_full (TRUE); -} - -GST_END_TEST; - - - -Suite * +static Suite * gnonlin_suite (void) { Suite *s = suite_create ("gnonlin-simple"); |