mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-12-19 14:56:36 +00:00
add test for amrnbenc, enable test infrastructure, and fix a leak
Original commit message from CVS: add test for amrnbenc, enable test infrastructure, and fix a leak * common/check.mak: allow for specifying more than one suppressions file in SUPPRESSIONS * Makefile.am: * tests/Makefile.am: * tests/check/.cvsignore: * tests/check/Makefile.am: * tests/check/elements/.cvsignore: * configure.ac: add tests/check * tests/check/gst-plugins-ugly.supp: add suppressions for libs used by -ugly * tests/check/elements/amrnbenc.c: (buffer_new), (buffer_unref), (setup_amrnbenc), (cleanup_amrnbenc), (push_data), (GST_START_TEST), (amrnbenc_suite), (main): add a simple test for encoding amr * ext/amrnb/amrnbenc.c: (gst_amrnbenc_init): fix pad template leaks
This commit is contained in:
parent
c201d235e0
commit
566525df79
11 changed files with 325 additions and 10 deletions
20
ChangeLog
20
ChangeLog
|
@ -1,3 +1,23 @@
|
|||
2006-04-10 Thomas Vander Stichele <thomas at apestaart dot org>
|
||||
|
||||
* common/check.mak:
|
||||
allow for specifying more than one suppressions file in SUPPRESSIONS
|
||||
* Makefile.am:
|
||||
* tests/Makefile.am:
|
||||
* tests/check/.cvsignore:
|
||||
* tests/check/Makefile.am:
|
||||
* tests/check/elements/.cvsignore:
|
||||
* configure.ac:
|
||||
add tests/check
|
||||
* tests/check/gst-plugins-ugly.supp:
|
||||
add suppressions for libs used by -ugly
|
||||
* tests/check/elements/amrnbenc.c: (buffer_new), (buffer_unref),
|
||||
(setup_amrnbenc), (cleanup_amrnbenc), (push_data),
|
||||
(GST_START_TEST), (amrnbenc_suite), (main):
|
||||
add a simple test for encoding amr
|
||||
* ext/amrnb/amrnbenc.c: (gst_amrnbenc_init):
|
||||
fix pad template leaks
|
||||
|
||||
2006-04-10 Michael Smith <msmith@fluendo.com>
|
||||
|
||||
* ext/amrnb/amrnbenc.c: (gst_amrnbenc_chain):
|
||||
|
|
11
Makefile.am
11
Makefile.am
|
@ -1,7 +1,7 @@
|
|||
DISTCHECK_CONFIGURE_FLAGS=--enable-gtk-doc
|
||||
|
||||
SUBDIRS = \
|
||||
gst ext docs m4 common
|
||||
gst ext docs m4 tests common
|
||||
|
||||
EXTRA_DIST = \
|
||||
gst-plugins-ugly.spec depcomp \
|
||||
|
@ -16,7 +16,12 @@ include $(top_srcdir)/common/release.mak
|
|||
include $(top_srcdir)/common/po.mak
|
||||
|
||||
check-valgrind:
|
||||
@true
|
||||
cd tests/check && make check-valgrind
|
||||
|
||||
if HAVE_CHECK
|
||||
check-torture:
|
||||
@true
|
||||
cd tests/check && make torture
|
||||
else
|
||||
check-torture:
|
||||
true
|
||||
endif
|
||||
|
|
2
common
2
common
|
@ -1 +1 @@
|
|||
Subproject commit 1783855e983a5294434673694e8a57e44980b6f1
|
||||
Subproject commit a6710e67fd82147e32a18f1b63177583faffd498
|
|
@ -419,6 +419,8 @@ ext/sidplay/Makefile
|
|||
docs/Makefile
|
||||
docs/plugins/Makefile
|
||||
docs/version.entities
|
||||
tests/Makefile
|
||||
tests/check/Makefile
|
||||
common/Makefile
|
||||
common/m4/Makefile
|
||||
m4/Makefile
|
||||
|
|
|
@ -114,17 +114,13 @@ static void
|
|||
gst_amrnbenc_init (GstAmrnbEnc * amrnbenc)
|
||||
{
|
||||
/* create the sink pad */
|
||||
amrnbenc->sinkpad =
|
||||
gst_pad_new_from_template (gst_static_pad_template_get (&sink_template),
|
||||
"sink");
|
||||
amrnbenc->sinkpad = gst_pad_new_from_static_template (&sink_template, "sink");
|
||||
gst_pad_set_setcaps_function (amrnbenc->sinkpad, gst_amrnbenc_setcaps);
|
||||
gst_pad_set_chain_function (amrnbenc->sinkpad, gst_amrnbenc_chain);
|
||||
gst_element_add_pad (GST_ELEMENT (amrnbenc), amrnbenc->sinkpad);
|
||||
|
||||
/* create the src pad */
|
||||
amrnbenc->srcpad =
|
||||
gst_pad_new_from_template (gst_static_pad_template_get (&src_template),
|
||||
"src");
|
||||
amrnbenc->srcpad = gst_pad_new_from_static_template (&src_template, "src");
|
||||
gst_pad_use_fixed_caps (amrnbenc->srcpad);
|
||||
gst_element_add_pad (GST_ELEMENT (amrnbenc), amrnbenc->srcpad);
|
||||
|
||||
|
|
9
tests/Makefile.am
Normal file
9
tests/Makefile.am
Normal file
|
@ -0,0 +1,9 @@
|
|||
if HAVE_CHECK
|
||||
SUBDIRS_CHECK = check
|
||||
else
|
||||
SUBDIRS_CHECK =
|
||||
endif
|
||||
|
||||
SUBDIRS = $(SUBDIRS_CHECK)
|
||||
|
||||
DIST_SUBDIRS = check
|
1
tests/check/.gitignore
vendored
Normal file
1
tests/check/.gitignore
vendored
Normal file
|
@ -0,0 +1 @@
|
|||
test-registry.xml
|
43
tests/check/Makefile.am
Normal file
43
tests/check/Makefile.am
Normal file
|
@ -0,0 +1,43 @@
|
|||
include $(top_srcdir)/common/check.mak
|
||||
|
||||
CHECK_REGISTRY = $(top_builddir)/tests/check/test-registry.xml
|
||||
|
||||
REGISTRY_ENVIRONMENT = \
|
||||
GST_REGISTRY=$(CHECK_REGISTRY)
|
||||
|
||||
TESTS_ENVIRONMENT = \
|
||||
$(REGISTRY_ENVIRONMENT) \
|
||||
GST_PLUGIN_SYSTEM_PATH= \
|
||||
GST_PLUGIN_PATH=$(top_builddir)/gst:$(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
|
||||
|
||||
TESTS = $(check_PROGRAMS)
|
||||
|
||||
if USE_AMRNB
|
||||
AMRNB = elements/amrnbenc
|
||||
else
|
||||
AMRNB =
|
||||
endif
|
||||
|
||||
check_PROGRAMS = \
|
||||
$(AMRNB)
|
||||
|
||||
# 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 =
|
||||
|
||||
SUPPRESSIONS = $(top_srcdir)/common/gst.supp $(srcdir)/gst-plugins-ugly.supp
|
||||
|
||||
elements_cmmldec_CFLAGS = $(GST_PLUGINS_BASE_CFLAGS)
|
||||
elements_cmmlenc_CFLAGS = $(GST_PLUGINS_BASE_CFLAGS)
|
||||
|
||||
EXTRA_DIST = gst-plugins-ugly.supp
|
2
tests/check/elements/.gitignore
vendored
Normal file
2
tests/check/elements/.gitignore
vendored
Normal file
|
@ -0,0 +1,2 @@
|
|||
amrnbenc
|
||||
.dirstamp
|
165
tests/check/elements/amrnbenc.c
Normal file
165
tests/check/elements/amrnbenc.c
Normal file
|
@ -0,0 +1,165 @@
|
|||
/*
|
||||
* GStreamer
|
||||
*
|
||||
* unit test for amrnbenc
|
||||
*
|
||||
* Copyright (C) 2006 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 <gst/check/gstcheck.h>
|
||||
|
||||
#define SRC_CAPS "audio/x-raw-int,width=16,depth=16,channels=1,rate=8000"
|
||||
#define SINK_CAPS "audio/AMR"
|
||||
|
||||
GList *buffers;
|
||||
GList *current_buf = NULL;
|
||||
|
||||
GstPad *srcpad, *sinkpad;
|
||||
|
||||
static GstStaticPadTemplate sinktemplate = GST_STATIC_PAD_TEMPLATE ("sink",
|
||||
GST_PAD_SINK,
|
||||
GST_PAD_ALWAYS,
|
||||
GST_STATIC_CAPS (SINK_CAPS)
|
||||
);
|
||||
|
||||
static GstStaticPadTemplate srctemplate = GST_STATIC_PAD_TEMPLATE ("src",
|
||||
GST_PAD_SRC,
|
||||
GST_PAD_ALWAYS,
|
||||
GST_STATIC_CAPS (SRC_CAPS)
|
||||
);
|
||||
|
||||
/* takes a copy of the passed buffer data */
|
||||
GstBuffer *
|
||||
buffer_new (const gchar * buffer_data, guint size)
|
||||
{
|
||||
GstBuffer *buffer;
|
||||
GstCaps *caps;
|
||||
|
||||
buffer = gst_buffer_new_and_alloc (size);
|
||||
memcpy (GST_BUFFER_DATA (buffer), buffer_data, size);
|
||||
caps = gst_caps_from_string (SRC_CAPS);
|
||||
gst_buffer_set_caps (buffer, caps);
|
||||
gst_caps_unref (caps);
|
||||
|
||||
return buffer;
|
||||
}
|
||||
|
||||
static void
|
||||
buffer_unref (void *buffer, void *user_data)
|
||||
{
|
||||
gst_buffer_unref (GST_BUFFER (buffer));
|
||||
}
|
||||
|
||||
GstElement *
|
||||
setup_amrnbenc ()
|
||||
{
|
||||
GstElement *amrnbenc;
|
||||
GstBus *bus;
|
||||
guint64 granulerate_n, granulerate_d;
|
||||
|
||||
GST_DEBUG ("setup_amrnbenc");
|
||||
|
||||
amrnbenc = gst_check_setup_element ("amrnbenc");
|
||||
srcpad = gst_check_setup_src_pad (amrnbenc, &srctemplate, NULL);
|
||||
sinkpad = gst_check_setup_sink_pad (amrnbenc, &sinktemplate, NULL);
|
||||
|
||||
bus = gst_bus_new ();
|
||||
gst_element_set_bus (amrnbenc, bus);
|
||||
|
||||
fail_unless (gst_element_set_state (amrnbenc,
|
||||
GST_STATE_PLAYING) != GST_STATE_CHANGE_FAILURE,
|
||||
"could not set to playing");
|
||||
|
||||
buffers = NULL;
|
||||
return amrnbenc;
|
||||
}
|
||||
|
||||
static void
|
||||
cleanup_amrnbenc (GstElement * amrnbenc)
|
||||
{
|
||||
GstBus *bus;
|
||||
|
||||
/* free encoded buffers */
|
||||
g_list_foreach (buffers, buffer_unref, NULL);
|
||||
g_list_free (buffers);
|
||||
buffers = NULL;
|
||||
|
||||
bus = GST_ELEMENT_BUS (amrnbenc);
|
||||
gst_bus_set_flushing (bus, TRUE);
|
||||
gst_object_unref (bus);
|
||||
|
||||
GST_DEBUG ("cleanup_amrnbenc");
|
||||
gst_check_teardown_src_pad (amrnbenc);
|
||||
gst_check_teardown_sink_pad (amrnbenc);
|
||||
gst_check_teardown_element (amrnbenc);
|
||||
}
|
||||
|
||||
/* push a random block of audio of the given size */
|
||||
static void
|
||||
push_data (gint size, GstFlowReturn expected_return)
|
||||
{
|
||||
GstBuffer *buffer;
|
||||
GstFlowReturn res;
|
||||
gchar *data = g_malloc (size);
|
||||
|
||||
buffer = buffer_new (data, size);
|
||||
g_free (data);
|
||||
res = gst_pad_push (srcpad, buffer);
|
||||
fail_unless (res == expected_return,
|
||||
"pushing audio returned %d not %d", res, expected_return);
|
||||
}
|
||||
|
||||
GST_START_TEST (test_enc)
|
||||
{
|
||||
GstElement *amrnbenc;
|
||||
|
||||
amrnbenc = setup_amrnbenc ();
|
||||
push_data (1000, GST_FLOW_OK);
|
||||
|
||||
cleanup_amrnbenc (amrnbenc);
|
||||
}
|
||||
|
||||
GST_END_TEST;
|
||||
|
||||
static Suite *
|
||||
amrnbenc_suite ()
|
||||
{
|
||||
Suite *s = suite_create ("amrnbenc");
|
||||
TCase *tc_chain = tcase_create ("general");
|
||||
|
||||
suite_add_tcase (s, tc_chain);
|
||||
tcase_add_test (tc_chain, test_enc);
|
||||
return s;
|
||||
}
|
||||
|
||||
int
|
||||
main (int argc, char **argv)
|
||||
{
|
||||
int nf;
|
||||
|
||||
Suite *s = amrnbenc_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;
|
||||
}
|
72
tests/check/gst-plugins-ugly.supp
Normal file
72
tests/check/gst-plugins-ugly.supp
Normal file
|
@ -0,0 +1,72 @@
|
|||
### amrnb suppressions
|
||||
### these should/could be submitted to amrnb
|
||||
|
||||
{
|
||||
<amrnb>
|
||||
Memcheck:Cond
|
||||
fun:Encoder_Interface_Encode
|
||||
fun:gst_amrnbenc_chain
|
||||
fun:gst_pad_chain
|
||||
fun:gst_pad_push
|
||||
}
|
||||
|
||||
{
|
||||
<amrnb>
|
||||
Memcheck:Cond
|
||||
fun:Speech_Encode_Frame
|
||||
fun:Encoder_Interface_Encode
|
||||
fun:gst_amrnbenc_chain
|
||||
fun:gst_pad_chain
|
||||
fun:gst_pad_push
|
||||
}
|
||||
|
||||
{
|
||||
<amrnb>
|
||||
Memcheck:Cond
|
||||
obj:/usr/lib/libamrnb.so*
|
||||
fun:Speech_Encode_Frame
|
||||
fun:Encoder_Interface_Encode
|
||||
fun:gst_amrnbenc_chain
|
||||
fun:gst_pad_chain
|
||||
fun:gst_pad_push
|
||||
}
|
||||
|
||||
{
|
||||
<amrnb>
|
||||
Memcheck:Cond
|
||||
obj:/usr/lib/libamrnb.so*
|
||||
obj:/usr/lib/libamrnb.so*
|
||||
fun:Speech_Encode_Frame
|
||||
fun:Encoder_Interface_Encode
|
||||
fun:gst_amrnbenc_chain
|
||||
fun:gst_pad_chain
|
||||
fun:gst_pad_push
|
||||
}
|
||||
|
||||
{
|
||||
<amrnb>
|
||||
Memcheck:Cond
|
||||
obj:/usr/lib/libamrnb.so*
|
||||
obj:/usr/lib/libamrnb.so*
|
||||
obj:/usr/lib/libamrnb.so*
|
||||
fun:Speech_Encode_Frame
|
||||
fun:Encoder_Interface_Encode
|
||||
fun:gst_amrnbenc_chain
|
||||
fun:gst_pad_chain
|
||||
fun:gst_pad_push
|
||||
}
|
||||
|
||||
{
|
||||
<amrnb acos>
|
||||
Memcheck:Cond
|
||||
fun:acos
|
||||
obj:/usr/lib/libamrnb.so*
|
||||
obj:/usr/lib/libamrnb.so*
|
||||
fun:Speech_Encode_Frame
|
||||
fun:Encoder_Interface_Encode
|
||||
fun:gst_amrnbenc_chain
|
||||
fun:gst_pad_chain
|
||||
fun:gst_pad_push
|
||||
}
|
||||
|
||||
|
Loading…
Reference in a new issue