[igt-dev] [PATCH i-g-t 5/5] lib/tests/igt_audio: add a pop test

Simon Ser
2019-05-29T13:32:47Z

Make sure adding a pop in the input signal makes audio_signal_detect fail.

Signed-off-by: Simon Ser <simon.ser@intel.com>
---
lib/tests/igt_audio.c | 23 +++++++++++++++++++++++
1 file changed, 23 insertions(+)

diff --git a/lib/tests/igt_audio.c b/lib/tests/igt_audio.c
index 0f1c39d93728..214dcea73efc 100644
--- a/lib/tests/igt_audio.c
+++ b/lib/tests/igt_audio.c
@@ -111,6 +111,26 @@ static void test_signal_detect_extra(struct audio_signal *signal)
igt_assert(!ok);
}

+static void test_signal_detect_pop(struct audio_signal *signal)
+{
+ double *buf;
+ bool ok;
+ size_t i;
+
+ buf = malloc(BUFFER_LEN * sizeof(double));
+ audio_signal_fill(signal, buf, BUFFER_LEN / CHANNELS);
+
+ /* Add a discontinuity in the signal */
+ for (i = 0; i < 5; i++)
+ buf[BUFFER_LEN / 3 + i] = 0.9;
+
+ ok = audio_signal_detect(signal, SAMPLING_RATE, 0, buf, BUFFER_LEN);
+
+ free(buf);
+
+ igt_assert(!ok);
+}
+
igt_main
{
struct audio_signal *signal;
@@ -146,6 +166,9 @@ igt_main
igt_subtest("signal-detect-extra")
test_signal_detect_extra(signal);

+ igt_subtest("signal-detect-pop")
+ test_signal_detect_pop(signal);
+
igt_fixture {
audio_signal_fini(signal);
}
--
2.21.0