[Intel-gfx] [PATCH i-g-t v2] lib/tests: Add audio selftest
Paul Kocialkowski
paul.kocialkowski at linux.intel.com
Thu Aug 31 08:02:16 UTC 2017
This introduces a selftest for the audio library.
It consists of generating a signal from a list of frequencies and
ensuring that the integrity checking function does detect these
frequencies (and only these frequencies).
Signed-off-by: Paul Kocialkowski <paul.kocialkowski at linux.intel.com>
---
lib/tests/.gitignore | 1 +
lib/tests/Makefile.am | 4 ++--
lib/tests/Makefile.sources | 5 +++++
lib/tests/igt_audio.c | 55 ++++++++++++++++++++++++++++++++++++++++++++++
4 files changed, 63 insertions(+), 2 deletions(-)
create mode 100644 lib/tests/igt_audio.c
diff --git a/lib/tests/.gitignore b/lib/tests/.gitignore
index ae11dd47..49bd5b01 100644
--- a/lib/tests/.gitignore
+++ b/lib/tests/.gitignore
@@ -1,5 +1,6 @@
# Please keep sorted alphabetically
igt_assert
+igt_audio
igt_fork_helper
igt_exit_handler
igt_invalid_subtest_name
diff --git a/lib/tests/Makefile.am b/lib/tests/Makefile.am
index 5d14194a..36c16124 100644
--- a/lib/tests/Makefile.am
+++ b/lib/tests/Makefile.am
@@ -16,5 +16,5 @@ AM_CFLAGS = $(DRM_CFLAGS) $(CWARNFLAGS) $(DEBUG_CFLAGS) \
LDADD = ../libintel_tools.la $(PCIACCESS_LIBS) $(DRM_LIBS) $(LIBUNWIND_LIBS) $(TIMER_LIBS)
-LDADD += $(CAIRO_LIBS) $(LIBUDEV_LIBS) $(GLIB_LIBS) -lm
-AM_CFLAGS += $(CAIRO_CFLAGS) $(LIBUDEV_CFLAGS) $(GLIB_CFLAGS)
+LDADD += $(CAIRO_LIBS) $(LIBUDEV_LIBS) $(GLIB_LIBS) $(GSL_LIBS) -lm
+AM_CFLAGS += $(CAIRO_CFLAGS) $(LIBUDEV_CFLAGS) $(GLIB_CFLAGS) $(GSL_CFLAGS)
diff --git a/lib/tests/Makefile.sources b/lib/tests/Makefile.sources
index 8d1a8dea..eb702844 100644
--- a/lib/tests/Makefile.sources
+++ b/lib/tests/Makefile.sources
@@ -18,6 +18,11 @@ check_prog_list = \
igt_can_fail_simple \
$(NULL)
+#if HAVE_GSL
+check_prog_list += \
+ igt_audio
+#endif
+
TESTS = \
$(check_prog_list) \
$(check_script_list) \
diff --git a/lib/tests/igt_audio.c b/lib/tests/igt_audio.c
new file mode 100644
index 00000000..2f9d0492
--- /dev/null
+++ b/lib/tests/igt_audio.c
@@ -0,0 +1,55 @@
+/*
+ * Copyright © 2017 Intel Corporation
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the next
+ * paragraph) shall be included in all copies or substantial portions of the
+ * Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
+ * IN THE SOFTWARE.
+ *
+ */
+
+#include "igt_core.h"
+#include "igt_audio.h"
+
+static int test_frequencies[] = {
+ 300,
+ 600,
+ 1200,
+ 80000,
+ 10000,
+};
+
+igt_simple_main
+{
+ short buffer[2048];
+ struct audio_signal *signal;
+ int i;
+
+ signal = audio_signal_init(2, 44800);
+ igt_assert(signal);
+
+ for (i = 0; i < ARRAY_SIZE(test_frequencies); i++)
+ audio_signal_add_frequency(signal, test_frequencies[i]);
+
+ audio_signal_synthesize(signal);
+ audio_signal_fill(signal, buffer, 1024);
+
+ igt_assert(audio_signal_detect(signal, 2, 44800, buffer, 1024));
+
+ audio_signal_clean(signal);
+ free(signal);
+}
--
2.14.0
More information about the Intel-gfx
mailing list