[igt-dev] [PATCH i-g-t v2 2/3] lib/tests/igt_audio: add a pop test
Martin Peres
martin.peres at linux.intel.com
Tue Jun 4 12:54:35 UTC 2019
On 04/06/2019 14:48, Simon Ser wrote:
> Make sure adding a pop in the input signal makes audio_signal_detect fail.
>
> Signed-off-by: Simon Ser <simon.ser at 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 47e61adf74fe..821813bae47a 100644
> --- a/lib/tests/igt_audio.c
> +++ b/lib/tests/igt_audio.c
> @@ -116,6 +116,26 @@ static void test_signal_detect_with_unexpected_freq(struct audio_signal *signal)
> igt_assert(!ok);
> }
>
> +static void test_signal_detect_pop(struct audio_signal *signal)
I would prefer you repeating/holding the sample for multiple samples as
opposed to forcing 0.9.
How about naming the test "test_signal_detect_held_sample"?
> +{
> + 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;
> @@ -151,6 +171,9 @@ igt_main
> igt_subtest("signal-detect-with-unexpected-freq")
> test_signal_detect_with_unexpected_freq(signal);
>
> + igt_subtest("signal-detect-pop")
> + test_signal_detect_pop(signal);
> +
> igt_fixture {
> audio_signal_fini(signal);
> }
>
More information about the igt-dev
mailing list