From da8a3c9b075134ceb9e89b6e946b9bfa8e37e23d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tim-Philipp=20M=C3=BCller?= Date: Thu, 18 May 2006 19:21:53 +0000 Subject: [PATCH] tests/check/: Add simple test that runs a device property probe on alsasrc, alsasink and alsamixer. Disable valgrind ... Original commit message from CVS: * tests/check/Makefile.am: * tests/check/elements/alsa.c: (test_device_property_probe), (alsa_suite), (main): Add simple test that runs a device property probe on alsasrc, alsasink and alsamixer. Disable valgrind check for now (too many leaks in libasound, and valgrind ignored my suppressions additions). --- ChangeLog | 10 ++++ tests/check/Makefile.am | 19 +++++++- tests/check/elements/alsa.c | 94 +++++++++++++++++++++++++++++++++++++ 3 files changed, 122 insertions(+), 1 deletion(-) create mode 100644 tests/check/elements/alsa.c diff --git a/ChangeLog b/ChangeLog index 0b1c785968..9c305ab148 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,13 @@ +2006-05-18 Tim-Philipp Müller + + * tests/check/Makefile.am: + * tests/check/elements/alsa.c: (test_device_property_probe), + (alsa_suite), (main): + Add simple test that runs a device property probe on alsasrc, + alsasink and alsamixer. Disable valgrind check for now (too + many leaks in libasound, and valgrind ignored my suppressions + additions). + 2006-05-18 Tim-Philipp Müller * ext/alsa/gstalsadeviceprobe.c: (gst_alsa_get_device_list), diff --git a/tests/check/Makefile.am b/tests/check/Makefile.am index 9950280fea..f66689f5f0 100644 --- a/tests/check/Makefile.am +++ b/tests/check/Makefile.am @@ -21,6 +21,12 @@ $(CHECK_REGISTRY): TESTS = $(check_PROGRAMS) +if USE_ALSA +check_alsa = elements/alsa +else +check_alsa = +endif + if USE_VORBIS check_vorbis = elements/vorbisdec pipelines/vorbisenc else @@ -33,7 +39,9 @@ else check_theora = endif -check_PROGRAMS = $(check_vorbis) \ +check_PROGRAMS = \ + $(check_alsa) \ + $(check_vorbis) \ $(check_theora) \ elements/audioconvert \ elements/audioresample \ @@ -52,6 +60,7 @@ check_PROGRAMS = $(check_vorbis) \ # elements/adder VALGRIND_TO_FIX = \ + elements/alsa \ elements/audioresample \ generic/states \ libs/cddabasesrc \ @@ -77,6 +86,14 @@ libs_cddabasesrc_CFLAGS = \ -I$(top_srcdir)/gst-libs \ $(CFLAGS) $(AM_CFLAGS) +elements_alsa_LDADD = \ + $(top_builddir)/gst-libs/gst/interfaces/libgstinterfaces-@GST_MAJORMINOR@.la \ + $(LDADD) + +elements_alsa_CFLAGS = \ + -I$(top_srcdir)/gst-libs \ + $(CFLAGS) $(AM_CFLAGS) + elements_audioconvert_LDADD = \ $(top_builddir)/gst-libs/gst/audio/libgstaudio-@GST_MAJORMINOR@.la \ $(LDADD) diff --git a/tests/check/elements/alsa.c b/tests/check/elements/alsa.c new file mode 100644 index 0000000000..92ec86b3ac --- /dev/null +++ b/tests/check/elements/alsa.c @@ -0,0 +1,94 @@ +/* GStreamer + * + * unit test for alsa elements + * + * Copyright (C) 2006 Tim-Philipp Müller + * + * 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 + +#include +#include + +/* just a simple test that runs device probing on + * an alsasrc, alsasink and alsamixer instance */ + +GST_START_TEST (test_device_property_probe) +{ + const gchar *elements[] = { "alsasink", "alsasrc", "alsamixer" }; + gint n; + + for (n = 0; n < G_N_ELEMENTS (elements); ++n) { + GstPropertyProbe *probe; + GValueArray *arr; + GstElement *element; + gint i; + + element = gst_element_factory_make (elements[n], elements[n]); + fail_unless (element != NULL); + + probe = GST_PROPERTY_PROBE (element); + fail_unless (probe != NULL); + + arr = gst_property_probe_probe_and_get_values_name (probe, "device"); + + for (i = 0; arr != NULL && i < arr->n_values; ++i) { + GValue *val; + + val = g_value_array_get_nth (arr, i); + fail_unless (val != NULL); + fail_unless (G_VALUE_HOLDS_STRING (val)); + + GST_LOG_OBJECT (element, "device[%d] = %s", i, g_value_get_string (val)); + } + g_value_array_free (arr); + + gst_object_unref (element); + } +} + +GST_END_TEST; + +Suite * +alsa_suite (void) +{ + Suite *s = suite_create ("alsa"); + TCase *tc_chain = tcase_create ("general"); + + suite_add_tcase (s, tc_chain); + tcase_add_test (tc_chain, test_device_property_probe); + + return s; +} + +int +main (int argc, char **argv) +{ + int nf; + + Suite *s = alsa_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; +}