Commit d8ceb021 authored by Thomas Vander Stichele's avatar Thomas Vander Stichele
Browse files

move location of test registry

Original commit message from CVS:
move location of test registry
parent 59823d65
......@@ -12,18 +12,11 @@ else
SUBDIRS_EXAMPLES =
endif
if HAVE_CHECK
SUBDIRS_CHECK = check
else
SUBDIRS_CHECK =
endif
SUBDIRS = \
gst-libs \
gst sys $(SUBDIRS_EXT) \
$(SUBDIRS_EXAMPLES) \
tools \
$(SUBDIRS_CHECK) \
docs \
po \
common \
......@@ -31,7 +24,6 @@ SUBDIRS = \
pkgconfig
DIST_SUBDIRS = \
check \
docs \
gst-libs \
gst sys ext \
......@@ -55,7 +47,7 @@ include $(top_srcdir)/common/release.mak
include $(top_srcdir)/common/po.mak
check-valgrind:
cd check && make check-valgrind
cd tests/check && make check-valgrind
check-torture:
cd check && make torture
cd tests/check && make torture
include $(top_srcdir)/common/check.mak
CHECK_REGISTRY = $(top_builddir)/check/test-registry.xml
REGISTRY_ENVIRONMENT = \
GST_REGISTRY=$(CHECK_REGISTRY)
TESTS_ENVIRONMENT = \
CK_DEFAULT_TIMEOUT=20 \
$(REGISTRY_ENVIRONMENT) \
GST_PLUGIN_SYSTEM_PATH= \
GST_PLUGIN_PATH=$(top_builddir)/gst:$(top_builddir)/sys:$(top_builddir)/ext:$(GST_PLUGINS_DIR)
# ths core dumps of some machines have PIDs appended
CLEANFILES = core.* test-registry.xml
clean-local: clean-local-check
$(CHECK_REGISTRY):
$(TESTS_ENVIRONMENT)
TESTS = $(check_PROGRAMS)
if USE_VORBIS
check_vorbis = elements/vorbisdec
else
check_vorbis =
endif
check_PROGRAMS = \
elements/audioconvert \
elements/audioresample \
elements/audiotestsrc \
elements/videotestsrc \
elements/volume \
generic/states \
pipelines/simple_launch_lines \
clocks/selection \
$(check_vorbis)
VALGRIND_TO_FIX = \
elements/audioresample \
generic/states \
pipelines/simple_launch_lines
# these tests don't even pass
noinst_PROGRAMS =
AM_CFLAGS = $(GST_OBJ_CFLAGS) $(GST_CHECK_CFLAGS) $(CHECK_CFLAGS)
LDADD = $(GST_OBJ_LIBS) $(GST_CHECK_LIBS) $(CHECK_LIBS)
# valgrind testing
VALGRIND_TESTS_DISABLE = $(VALGRIND_TO_FIX)
SUPPRESSIONS = $(top_srcdir)/common/gst.supp
/* GStreamer
*
* unit test for clock selection
*
* Copyright (C) <2005> Wim Taymans <wim at fluendo dot com>
*
* 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 <unistd.h>
#include <gst/check/gstcheck.h>
GST_START_TEST (test_add)
{
GstElement *pipeline;
GstStateChangeReturn ret;
pipeline = gst_pipeline_new ("pipeline");
fail_unless (pipeline != NULL, "could not create pipeline");
ret = gst_element_set_state (pipeline, GST_STATE_READY);
fail_unless (ret == GST_STATE_CHANGE_SUCCESS, "could not set to READY");
/* cleanup */
gst_object_unref (pipeline);
}
GST_END_TEST;
Suite *
volume_suite (void)
{
Suite *s = suite_create ("clocks");
TCase *tc_chain = tcase_create ("general");
suite_add_tcase (s, tc_chain);
tcase_add_test (tc_chain, test_add);
return s;
}
int
main (int argc, char **argv)
{
int nf;
Suite *s = volume_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;
}
.dirstamp
audioconvert
audioresample
audiotestsrc
videotestsrc
volume
vorbisdec
/* GStreamer
*
* unit test for audioconvert
*
* Copyright (C) <2005> Thomas Vander Stichele <thomas at apestaart dot org>
*
* 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 <unistd.h>
#include <gst/check/gstcheck.h>
GList *buffers = NULL;
gboolean have_eos = FALSE;
/* For ease of programming we use globals to keep refs for our floating
* src and sink pads we create; otherwise we always have to do get_pad,
* get_peer, and then remove references in every test function */
GstPad *mysrcpad, *mysinkpad;
#define CONVERT_CAPS_TEMPLATE_STRING \
"audio/x-raw-float, " \
"rate = (int) [ 1, MAX ], " \
"channels = (int) [ 1, 8 ], " \
"endianness = (int) BYTE_ORDER, " \
"width = (int) 32;" \
"audio/x-raw-int, " \
"rate = (int) [ 1, MAX ], " \
"channels = (int) [ 1, 8 ], " \
"endianness = (int) { LITTLE_ENDIAN, BIG_ENDIAN }, " \
"width = (int) 32, " \
"depth = (int) [ 1, 32 ], " \
"signed = (boolean) { true, false }; " \
"audio/x-raw-int, " \
"rate = (int) [ 1, MAX ], " \
"channels = (int) [ 1, 8 ], " \
"endianness = (int) { LITTLE_ENDIAN, BIG_ENDIAN }, " \
"width = (int) 24, " \
"depth = (int) [ 1, 24 ], " \
"signed = (boolean) { true, false }; " \
"audio/x-raw-int, " \
"rate = (int) [ 1, MAX ], " \
"channels = (int) [ 1, 8 ], " \
"endianness = (int) { LITTLE_ENDIAN, BIG_ENDIAN }, " \
"width = (int) 16, " \
"depth = (int) [ 1, 16 ], " \
"signed = (boolean) { true, false }; " \
"audio/x-raw-int, " \
"rate = (int) [ 1, MAX ], " \
"channels = (int) [ 1, 8 ], " \
"endianness = (int) { LITTLE_ENDIAN, BIG_ENDIAN }, " \
"width = (int) 8, " \
"depth = (int) [ 1, 8 ], " \
"signed = (boolean) { true, false } "
static GstStaticPadTemplate sinktemplate = GST_STATIC_PAD_TEMPLATE ("sink",
GST_PAD_SINK,
GST_PAD_ALWAYS,
GST_STATIC_CAPS (CONVERT_CAPS_TEMPLATE_STRING)
);
static GstStaticPadTemplate srctemplate = GST_STATIC_PAD_TEMPLATE ("src",
GST_PAD_SRC,
GST_PAD_ALWAYS,
GST_STATIC_CAPS (CONVERT_CAPS_TEMPLATE_STRING)
);
/* takes over reference for outcaps */
GstElement *
setup_audioconvert (GstCaps * outcaps)
{
GstElement *audioconvert;
GST_DEBUG ("setup_audioconvert with caps %" GST_PTR_FORMAT, outcaps);
audioconvert = gst_check_setup_element ("audioconvert");
mysrcpad = gst_check_setup_src_pad (audioconvert, &srctemplate, NULL);
mysinkpad = gst_check_setup_sink_pad (audioconvert, &sinktemplate, NULL);
/* this installs a getcaps func that will always return the caps we set
* later */
gst_pad_use_fixed_caps (mysinkpad);
gst_pad_set_caps (mysinkpad, outcaps);
gst_caps_unref (outcaps);
outcaps = gst_pad_get_negotiated_caps (mysinkpad);
fail_unless (gst_caps_is_fixed (outcaps));
gst_caps_unref (outcaps);
gst_pad_set_active (mysrcpad, TRUE);
gst_pad_set_active (mysinkpad, TRUE);
return audioconvert;
}
void
cleanup_audioconvert (GstElement * audioconvert)
{
GST_DEBUG ("cleanup_audioconvert");
gst_pad_set_active (mysrcpad, FALSE);
gst_pad_set_active (mysinkpad, FALSE);
gst_check_teardown_src_pad (audioconvert);
gst_check_teardown_sink_pad (audioconvert);
gst_check_teardown_element (audioconvert);
}
/* returns a newly allocated caps */
static GstCaps *
get_int_caps (guint channels, gchar * endianness, guint width,
guint depth, gboolean signedness)
{
GstCaps *caps;
gchar *string;
string = g_strdup_printf ("audio/x-raw-int, "
"rate = (int) 44100, "
"channels = (int) %d, "
"endianness = (int) %s, "
"width = (int) %d, "
"depth = (int) %d, "
"signed = (boolean) %s ",
channels, endianness, width, depth, signedness ? "true" : "false");
GST_DEBUG ("creating caps from %s", string);
caps = gst_caps_from_string (string);
g_free (string);
fail_unless (caps != NULL);
GST_DEBUG ("returning caps %p", caps);
return caps;
}
/* eats the refs to the caps */
static void
verify_convert (void *in, int inlength,
GstCaps * incaps, void *out, int outlength, GstCaps * outcaps)
{
GstBuffer *inbuffer, *outbuffer;
GstElement *audioconvert;
GST_DEBUG ("incaps: %" GST_PTR_FORMAT, incaps);
GST_DEBUG ("outcaps: %" GST_PTR_FORMAT, outcaps);
ASSERT_CAPS_REFCOUNT (incaps, "incaps", 1);
ASSERT_CAPS_REFCOUNT (outcaps, "outcaps", 1);
audioconvert = setup_audioconvert (outcaps);
ASSERT_CAPS_REFCOUNT (outcaps, "outcaps", 1);
fail_unless (gst_element_set_state (audioconvert,
GST_STATE_PLAYING) == GST_STATE_CHANGE_SUCCESS,
"could not set to playing");
GST_DEBUG ("Creating buffer of %d bytes", inlength);
inbuffer = gst_buffer_new_and_alloc (inlength);
memcpy (GST_BUFFER_DATA (inbuffer), in, inlength);
gst_buffer_set_caps (inbuffer, incaps);
ASSERT_CAPS_REFCOUNT (incaps, "incaps", 2);
ASSERT_BUFFER_REFCOUNT (inbuffer, "inbuffer", 1);
/* pushing gives away my reference ... */
GST_DEBUG ("push it");
fail_unless (gst_pad_push (mysrcpad, inbuffer) == GST_FLOW_OK);
GST_DEBUG ("pushed it");
/* ... and puts a new buffer on the global list */
fail_unless (g_list_length (buffers) == 1);
fail_if ((outbuffer = (GstBuffer *) buffers->data) == NULL);
ASSERT_BUFFER_REFCOUNT (outbuffer, "outbuffer", 1);
fail_unless_equals_int (GST_BUFFER_SIZE (outbuffer), outlength);
fail_unless (memcmp (GST_BUFFER_DATA (outbuffer), out, outlength) == 0);
buffers = g_list_remove (buffers, outbuffer);
gst_buffer_unref (outbuffer);
fail_unless (gst_element_set_state (audioconvert,
GST_STATE_NULL) == GST_STATE_CHANGE_SUCCESS, "could not set to null");
/* cleanup */
GST_DEBUG ("cleanup audioconvert");
cleanup_audioconvert (audioconvert);
GST_DEBUG ("cleanup, unref incaps");
ASSERT_CAPS_REFCOUNT (incaps, "incaps", 1);
gst_caps_unref (incaps);
}
#define RUN_CONVERSION(inarray, in_get_caps, outarray, out_get_caps) \
verify_convert (inarray, sizeof (inarray), \
in_get_caps, outarray, sizeof (outarray), out_get_caps)
GST_START_TEST (test_int16)
{
/* stereo to mono */
{
gint16 in[] = { 16384, -256, 1024, 1024 };
gint16 out[] = { 8064, 1024 };
RUN_CONVERSION (in, get_int_caps (2, "BYTE_ORDER", 16, 16, TRUE),
out, get_int_caps (1, "BYTE_ORDER", 16, 16, TRUE));
}
/* mono to stereo */
{
gint16 in[] = { 512, 1024 };
gint16 out[] = { 512, 512, 1024, 1024 };
RUN_CONVERSION (in, get_int_caps (1, "BYTE_ORDER", 16, 16, TRUE),
out, get_int_caps (2, "BYTE_ORDER", 16, 16, TRUE));
}
/* signed -> unsigned */
{
gint16 in[] = { 0, -32767, 32767, -32768 };
guint16 out[] = { 32768, 1, 65535, 0 };
RUN_CONVERSION (in, get_int_caps (1, "BYTE_ORDER", 16, 16, TRUE),
out, get_int_caps (1, "BYTE_ORDER", 16, 16, FALSE));
RUN_CONVERSION (out, get_int_caps (1, "BYTE_ORDER", 16, 16, FALSE),
in, get_int_caps (1, "BYTE_ORDER", 16, 16, TRUE));
}
}
GST_END_TEST;
GST_START_TEST (test_int_conversion)
{
/* 8 <-> 16 signed */
/* NOTE: if audioconvert was doing dithering we'd have a problem */
{
gint8 in[] = { 0, 1, 2, 127, -127 };
gint16 out[] = { 0, 256, 512, 32512, -32512 };
RUN_CONVERSION (in, get_int_caps (1, "BYTE_ORDER", 8, 8, TRUE),
out, get_int_caps (1, "BYTE_ORDER", 16, 16, TRUE)
);
RUN_CONVERSION (out, get_int_caps (1, "BYTE_ORDER", 16, 16, TRUE),
in, get_int_caps (1, "BYTE_ORDER", 8, 8, TRUE)
);
}
/* 16 -> 8 signed */
{
gint16 in[] = { 0, 255, 256, 257 };
gint8 out[] = { 0, 0, 1, 1 };
RUN_CONVERSION (in, get_int_caps (1, "BYTE_ORDER", 16, 16, TRUE),
out, get_int_caps (1, "BYTE_ORDER", 8, 8, TRUE)
);
}
/* 8 unsigned <-> 16 signed */
/* NOTE: if audioconvert was doing dithering we'd have a problem */
{
guint8 in[] = { 128, 129, 130, 255, 1 };
gint16 out[] = { 0, 256, 512, 32512, -32512 };
GstCaps *incaps, *outcaps;
/* exploded for easier valgrinding */
incaps = get_int_caps (1, "BYTE_ORDER", 8, 8, FALSE);
outcaps = get_int_caps (1, "BYTE_ORDER", 16, 16, TRUE);
GST_DEBUG ("incaps: %" GST_PTR_FORMAT, incaps);
GST_DEBUG ("outcaps: %" GST_PTR_FORMAT, outcaps);
RUN_CONVERSION (in, incaps, out, outcaps);
RUN_CONVERSION (out, get_int_caps (1, "BYTE_ORDER", 16, 16, TRUE),
in, get_int_caps (1, "BYTE_ORDER", 8, 8, FALSE)
);
}
/* 8 <-> 24 signed */
/* NOTE: if audioconvert was doing dithering we'd have a problem */
{
gint8 in[] = { 0, 1, 127 };
guint8 out[] = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x7f };
RUN_CONVERSION (in, get_int_caps (1, "BYTE_ORDER", 8, 8, TRUE),
out, get_int_caps (1, "BYTE_ORDER", 24, 24, TRUE)
);
RUN_CONVERSION (out, get_int_caps (1, "BYTE_ORDER", 24, 24, TRUE),
in, get_int_caps (1, "BYTE_ORDER", 8, 8, TRUE)
);
}
}
GST_END_TEST;
Suite *
audioconvert_suite (void)
{
Suite *s = suite_create ("audioconvert");
TCase *tc_chain = tcase_create ("general");
suite_add_tcase (s, tc_chain);
tcase_add_test (tc_chain, test_int16);
//tcase_add_test (tc_chain, test_int_conversion);
return s;
}
int
main (int argc, char **argv)
{
int nf;
Suite *s = audioconvert_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;
}
/* GStreamer
*
* unit test for audioresample
*
* Copyright (C) <2005> Thomas Vander Stichele <thomas at apestaart dot org>
*
* 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 <unistd.h>
#include <gst/check/gstcheck.h>
GList *buffers = NULL;
gboolean have_eos = FALSE;
/* For ease of programming we use globals to keep refs for our floating
* src and sink pads we create; otherwise we always have to do get_pad,
* get_peer, and then remove references in every test function */
GstPad *mysrcpad, *mysinkpad;
#define RESAMPLE_CAPS_TEMPLATE_STRING \
"audio/x-raw-int, " \
"channels = (int) [ 1, MAX ], " \
"rate = (int) [ 1, MAX ], " \
"endianness = (int) BYTE_ORDER, " \
"width = (int) 16, " \
"depth = (int) 16, " \
"signed = (bool) TRUE"
static GstStaticPadTemplate sinktemplate = GST_STATIC_PAD_TEMPLATE ("sink",
GST_PAD_SINK,
GST_PAD_ALWAYS,
GST_STATIC_CAPS (RESAMPLE_CAPS_TEMPLATE_STRING)
);
static GstStaticPadTemplate srctemplate = GST_STATIC_PAD_TEMPLATE ("src",
GST_PAD_SRC,
GST_PAD_ALWAYS,
GST_STATIC_CAPS (RESAMPLE_CAPS_TEMPLATE_STRING)
);
GstElement *
setup_audioresample (int channels, int inrate, int outrate)
{
GstElement *audioresample;
GstCaps *caps;
GstStructure *structure;
GstPad *pad;
GST_DEBUG ("setup_audioresample");
audioresample = gst_check_setup_element ("audioresample");
caps = gst_caps_from_string (RESAMPLE_CAPS_TEMPLATE_STRING);
structure = gst_caps_get_structure (caps, 0);
gst_structure_set (structure, "channels", G_TYPE_INT, channels,
"rate", G_TYPE_INT, inrate, NULL);
fail_unless (gst_caps_is_fixed (caps));
mysrcpad = gst_check_setup_src_pad (audioresample, &srctemplate, caps);
pad = gst_pad_get_peer (mysrcpad);
gst_pad_set_caps (pad, caps);
gst_object_unref (GST_OBJECT (pad));
gst_caps_unref (caps);
gst_pad_set_active (mysrcpad, TRUE);
caps = gst_caps_from_string (RESAMPLE_CAPS_TEMPLATE_STRING);
structure = gst_caps_get_structure (caps, 0);
gst_structure_set (structure, "channels", G_TYPE_INT, channels,
"rate", G_TYPE_INT, outrate, NULL);
fail_unless (gst_caps_is_fixed (caps));
mysinkpad = gst_check_setup_sink_pad (audioresample, &sinktemplate, caps);
/* this installs a getcaps func that will always return the caps we set
* later */
gst_pad_use_fixed_caps (mysinkpad);
pad = gst_pad_get_peer (mysinkpad);
gst_pad_set_caps (pad, caps);
gst_object_unref (GST_OBJECT (pad));
gst_caps_unref (caps);
gst_pad_set_active (mysinkpad, TRUE);
return audioresample;
}
void
cleanup_audioresample (GstElement * audioresample)
{
GST_DEBUG ("cleanup_audioresample");
gst_check_teardown_src_pad (audioresample);
gst_check_teardown_sink_pad (audioresample);
gst_check_teardown_element (audioresample);
}
static void
fail_unless_perfect_stream ()
{
guint64 timestamp = 0L, duration = 0L;
guint64 offset = 0L, offset_end = 0L;
GList *l;
GstBuffer *buffer;
for (l = buffers; l; l = l->next) {
buffer = GST_BUFFER (l->data);
ASSERT_BUFFER_REFCOUNT (buffer, "buffer", 1);
GST_DEBUG ("buffer timestamp %" G_GUINT64_FORMAT ", duration %"
G_GUINT64_FORMAT, GST_BUFFER_TIMESTAMP (buffer),
GST_BUFFER_DURATION (buffer));
fail_unless_equals_uint64 (timestamp, GST_BUFFER_TIMESTAMP (buffer));
fail_unless_equals_uint64 (offset, GST_BUFFER_OFFSET (buffer));
duration = GST_BUFFER_DURATION (buffer);
offset_end = GST_BUFFER_OFFSET_END (buffer);
timestamp += duration;
offset = offset_end;
gst_buffer_unref (buffer);