Skip to contentSkip to conversation

lib/igt_audio: add basic audio_signal_detect tests

PATCH New Simon Ser 2 participants 3 messages May 29, 2019 Arm/Amlogic Meson SoC support

lore
Share & tools
lore

Simon Ser

author
#0 lore raw

PATCH 1/1 lib/igt_audio: add basic audio_signal_detect tests

This adds three basic library tests for igt_audio's audio_signal_detect: one that checks that detection works with the generated signal unchanged, and two that check that detection properly fails with a silent/noise input signal.

---
 lib/tests/igt_audio.c | 111 ++++++++++++++++++++++++++++++++++++++++++
 lib/tests/meson.build |   7 +++
 2 files changed, 118 insertions(+)
 create mode 100644 lib/tests/igt_audio.c
lib/tests/igt_audio.c new file +111 -0
new file mode 100644
index 000000000000..1d3d009faea5
@@ -0,0 +1,111 @@
+/*
+ * Copyright © 2019 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.
+ *
+ * Author: Simon Ser <[email protected]>
+ */
+
+#include "config.h"
+
+#include "igt_core.h"
+#include "igt_audio.h"
+
+#define SAMPLING_RATE 44100
+#define CHANNELS 1
+#define BUFFER_LEN 2048
+
+static void test_signal_detect_verbatim(struct audio_signal *signal)
+{
+	double *buf;
+	bool ok;
+
+	buf = malloc(BUFFER_LEN * sizeof(double));
+	audio_signal_fill(signal, buf, BUFFER_LEN / CHANNELS);
+
+	ok = audio_signal_detect(signal, SAMPLING_RATE, 0, buf, BUFFER_LEN);
+
+	free(buf);
+
+	igt_assert(ok);
+}
+
+static void test_signal_detect_silence(struct audio_signal *signal)
+{
+	double *buf;
+	bool ok;
+
+	buf = calloc(BUFFER_LEN, sizeof(double));
+	ok = audio_signal_detect(signal, SAMPLING_RATE, 0, buf, BUFFER_LEN);
+	free(buf);
+
+	igt_assert(!ok);
+}
+
+static void test_signal_detect_noise(struct audio_signal *signal)
+{
+	double *buf;
+	bool ok;
+	size_t i;
+
+	buf = malloc(BUFFER_LEN * sizeof(double));
+	for (i = 0; i < BUFFER_LEN; i++)
+		buf[i] = (double) (i % 10) / 10;
+
+	ok = audio_signal_detect(signal, SAMPLING_RATE, 0, buf, BUFFER_LEN);
+
+	free(buf);
+
+	igt_assert(!ok);
+}
+
+igt_main
+{
+	struct audio_signal *signal;
+	int ret;
+
+	igt_subtest_group {
+		igt_fixture {
+			signal = audio_signal_init(CHANNELS, SAMPLING_RATE);
+
+			ret = audio_signal_add_frequency(signal, 300, 0);
+			igt_assert(ret == 0);
+			ret = audio_signal_add_frequency(signal, 700, 0);
+			igt_assert(ret == 0);
+			ret = audio_signal_add_frequency(signal, 5000, 0);
+			igt_assert(ret == 0);
+
+			audio_signal_synthesize(signal);
+		}
+
+		igt_subtest("signal-detect-verbatim")
+			test_signal_detect_verbatim(signal);
+
+		igt_subtest("signal-detect-silence")
+			test_signal_detect_silence(signal);
+
+		igt_subtest("signal-detect-noise")
+			test_signal_detect_noise(signal);
+
+		igt_fixture {
+			audio_signal_fini(signal);
+		}
+	}
+}
lib/tests/meson.build +7 -0
index 9950bd59c174..eb75cbd571b9 100644
@@ -22,6 +22,13 @@ lib_fail_tests = [
 	'igt_timeout',
 ]
 
+lib_tests_deps = igt_deps
+
+if chamelium.found()
+	lib_deps += chamelium
+	lib_tests += 'igt_audio'
+endif
+
 foreach lib_test : lib_tests
 	exec = executable(lib_test, lib_test + '.c', install : false,
 			dependencies : igt_deps)
Signature · 6 lines
2.21.0

_______________________________________________
igt-dev mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/igt-dev
#1 lore raw

[igt-dev] ✓ Fi.CI.BAT: success for lib/igt_audio: add basic audio_signal_detect tests

== Series Details ==

== Series Details ==

Series: lib/igt_audio: add basic audio_signal_detect tests
URL : https://patchwork.freedesktop.org/series/61319/
State : success

== Summary ==

CI Bug Log - changes from CI_DRM_6161 -> IGTPW_3072
====================================================

Summary
-------

**SUCCESS**

No regressions found.

External URL: https://patchwork.freedesktop.org/api/1.0/series/61319/revisions/1/mbox/

Known issues
------------

Here are the changes found in IGTPW_3072 that come from known issues:

### IGT changes ###

#### Issues hit ####

* igt@i915_selftest@live_contexts:
- fi-hsw-peppy: [PASS][1] -> [DMESG-FAIL][2] ([fdo#110235])
[1]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_6161/fi-hsw-peppy/igt@i915_selftest@live_contexts.html
[2]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_3072/fi-hsw-peppy/igt@i915_selftest@live_contexts.html

* igt@kms_frontbuffer_tracking@basic:
- fi-hsw-peppy: [PASS][3] -> [DMESG-WARN][4] ([fdo#102614])
[3]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_6161/fi-hsw-peppy/igt@[email protected]
[4]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_3072/fi-hsw-peppy/igt@[email protected]

#### Possible fixes ####

* igt@kms_chamelium@dp-crc-fast:
- fi-cml-u2: [FAIL][5] ([fdo#110387]) -> [PASS][6]
[5]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_6161/fi-cml-u2/igt@[email protected]
[6]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_3072/fi-cml-u2/igt@[email protected]

* igt@kms_force_connector_basic@force-connector-state:
- fi-ilk-650: [DMESG-WARN][7] ([fdo#106387]) -> [PASS][8]
[7]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_6161/fi-ilk-650/igt@[email protected]
[8]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_3072/fi-ilk-650/igt@[email protected]

[fdo#102614]: https://bugs.freedesktop.org/show_bug.cgi?id=102614
[fdo#106387]: https://bugs.freedesktop.org/show_bug.cgi?id=106387
[fdo#110235]: https://bugs.freedesktop.org/show_bug.cgi?id=110235
[fdo#110387]: https://bugs.freedesktop.org/show_bug.cgi?id=110387

Participating hosts (46 -> 40)
------------------------------

Missing (6): fi-kbl-soraka fi-hsw-4200u fi-byt-squawks fi-bsw-cyan fi-byt-clapper fi-bdw-samus

Build changes
-------------

* IGT: IGT_5024 -> IGTPW_3072

CI_DRM_6161: 8b2b2b44927fcf8640d5b32009843774bcd034af @ git://anongit.freedesktop.org/gfx-ci/linux
IGTPW_3072: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_3072/
IGT_5024: f414756be2ac57e194919973da7b86644ba61241 @ git://anongit.freedesktop.org/xorg/app/intel-gpu-tools

== Logs ==

For more details see: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_3072/
_______________________________________________
igt-dev mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/igt-dev

#2 lore raw

[igt-dev] ✓ Fi.CI.IGT: success for lib/igt_audio: add basic audio_signal_detect tests

In reply to Simon Ser
== Series Details ==

== Series Details ==

Series: lib/igt_audio: add basic audio_signal_detect tests
URL : https://patchwork.freedesktop.org/series/61319/
State : success

== Summary ==

CI Bug Log - changes from CI_DRM_6161_full -> IGTPW_3072_full
====================================================

Summary
-------

**SUCCESS**

No regressions found.

External URL: https://patchwork.freedesktop.org/api/1.0/series/61319/revisions/1/mbox/

Known issues
------------

Here are the changes found in IGTPW_3072_full that come from known issues:

### IGT changes ###

#### Issues hit ####

* igt@kms_flip@flip-vs-panning-vs-hang:
- shard-hsw: [PASS][1] -> [INCOMPLETE][2] ([fdo#103540])
[1]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_6161/shard-hsw5/igt@[email protected]
[2]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_3072/shard-hsw4/igt@[email protected]

* igt@kms_frontbuffer_tracking@fbc-2p-rte:
- shard-hsw: [PASS][3] -> [SKIP][4] ([fdo#109271]) +23 similar issues
[3]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_6161/shard-hsw2/igt@[email protected]
[4]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_3072/shard-hsw1/igt@[email protected]

* igt@kms_pipe_crc_basic@suspend-read-crc-pipe-b:
- shard-kbl: [PASS][5] -> [INCOMPLETE][6] ([fdo#103665])
[5]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_6161/shard-kbl4/igt@[email protected]
[6]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_3072/shard-kbl4/igt@[email protected]

* igt@kms_setmode@basic:
- shard-kbl: [PASS][7] -> [FAIL][8] ([fdo#99912])
[7]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_6161/shard-kbl2/igt@[email protected]
[8]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_3072/shard-kbl3/igt@[email protected]

* igt@kms_sysfs_edid_timing:
- shard-hsw: [PASS][9] -> [FAIL][10] ([fdo#100047])
[9]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_6161/shard-hsw4/igt@kms_sysfs_edid_timing.html
[10]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_3072/shard-hsw1/igt@kms_sysfs_edid_timing.html

* igt@kms_vblank@pipe-c-ts-continuation-suspend:
- shard-apl: [PASS][11] -> [DMESG-WARN][12] ([fdo#108566]) +7 similar issues
[11]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_6161/shard-apl3/igt@[email protected]
[12]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_3072/shard-apl3/igt@[email protected]

* igt@perf_pmu@rc6-runtime-pm-long:
- shard-apl: [PASS][13] -> [FAIL][14] ([fdo#105010])
[13]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_6161/shard-apl2/igt@[email protected]
[14]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_3072/shard-apl4/igt@[email protected]

#### Possible fixes ####

* igt@i915_pm_rc6_residency@rc6-accuracy:
- shard-kbl: [SKIP][15] ([fdo#109271]) -> [PASS][16]
[15]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_6161/shard-kbl2/igt@[email protected]
[16]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_3072/shard-kbl3/igt@[email protected]

* igt@i915_suspend@debugfs-reader:
- shard-apl: [DMESG-WARN][17] ([fdo#108566]) -> [PASS][18] +3 similar issues
[17]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_6161/shard-apl8/igt@[email protected]
[18]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_3072/shard-apl7/igt@[email protected]

* igt@kms_cursor_legacy@flip-vs-cursor-crc-legacy:
- shard-apl: [FAIL][19] ([fdo#102670]) -> [PASS][20]
[19]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_6161/shard-apl4/igt@[email protected]
[20]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_3072/shard-apl8/igt@[email protected]

* igt@kms_flip@2x-flip-vs-expired-vblank-interruptible:
- shard-hsw: [SKIP][21] ([fdo#109271]) -> [PASS][22] +19 similar issues
[21]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_6161/shard-hsw1/igt@[email protected]
[22]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_3072/shard-hsw4/igt@[email protected]

* igt@kms_flip@dpms-vs-vblank-race-interruptible:
- shard-glk: [FAIL][23] ([fdo#103060]) -> [PASS][24]
[23]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_6161/shard-glk4/igt@[email protected]
[24]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_3072/shard-glk7/igt@[email protected]

* igt@kms_lease@simple_lease:
- shard-hsw: [INCOMPLETE][25] ([fdo#103540]) -> [PASS][26]
[25]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_6161/shard-hsw8/igt@kms_lease@simple_lease.html
[26]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_3072/shard-hsw6/igt@kms_lease@simple_lease.html

* igt@tools_test@tools_test:
- shard-glk: [SKIP][27] ([fdo#109271]) -> [PASS][28]
[27]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_6161/shard-glk2/igt@tools_test@tools_test.html
[28]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_3072/shard-glk5/igt@tools_test@tools_test.html

[fdo#100047]: https://bugs.freedesktop.org/show_bug.cgi?id=100047
[fdo#102670]: https://bugs.freedesktop.org/show_bug.cgi?id=102670
[fdo#103060]: https://bugs.freedesktop.org/show_bug.cgi?id=103060
[fdo#103540]: https://bugs.freedesktop.org/show_bug.cgi?id=103540
[fdo#103665]: https://bugs.freedesktop.org/show_bug.cgi?id=103665
[fdo#105010]: https://bugs.freedesktop.org/show_bug.cgi?id=105010
[fdo#108566]: https://bugs.freedesktop.org/show_bug.cgi?id=108566
[fdo#109271]: https://bugs.freedesktop.org/show_bug.cgi?id=109271
[fdo#99912]: https://bugs.freedesktop.org/show_bug.cgi?id=99912

Participating hosts (9 -> 5)
------------------------------

Missing (4): pig-skl-6260u shard-skl pig-hsw-4770r pig-glk-j5005

Build changes
-------------

* IGT: IGT_5024 -> IGTPW_3072
* Piglit: piglit_4509 -> None

CI_DRM_6161: 8b2b2b44927fcf8640d5b32009843774bcd034af @ git://anongit.freedesktop.org/gfx-ci/linux
IGTPW_3072: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_3072/
IGT_5024: f414756be2ac57e194919973da7b86644ba61241 @ git://anongit.freedesktop.org/xorg/app/intel-gpu-tools
piglit_4509: fdc5a4ca11124ab8413c7988896eec4c97336694 @ git://anongit.freedesktop.org/piglit

== Logs ==

For more details see: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_3072/
_______________________________________________
igt-dev mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/igt-dev