[igt-dev] [PATCH i-g-t v3] lib/tests/igt_audio: add a test holding a sample

Martin Peres martin.peres at linux.intel.com
Wed Jun 12 10:56:03 UTC 2019


On 05/06/2019 11:03, Simon Ser wrote:
> Make sure holding a sample in the input signal makes audio_signal_detect fail.
> 
> Signed-off-by: Simon Ser <simon.ser at intel.com>
> ---
>  lib/tests/igt_audio.c | 25 +++++++++++++++++++++++++
>  1 file changed, 25 insertions(+)
> 
> diff --git a/lib/tests/igt_audio.c b/lib/tests/igt_audio.c
> index 47e61adf74fe..d18537d66fb7 100644
> --- a/lib/tests/igt_audio.c
> +++ b/lib/tests/igt_audio.c
> @@ -116,6 +116,28 @@ static void test_signal_detect_with_unexpected_freq(struct audio_signal *signal)
>  	igt_assert(!ok);
>  }
> 
> +static void test_signal_detect_held_sample(struct audio_signal *signal)
> +{
> +	double *buf;
> +	bool ok;
> +	size_t i;
> +	double value;
> +
> +	buf = malloc(BUFFER_LEN * sizeof(double));
> +	audio_signal_fill(signal, buf, BUFFER_LEN / CHANNELS);
> +
> +	/* Repeat a sample in the middle of the signal */
> +	value = buf[BUFFER_LEN / 3];
> +	for (i = 0; i < 5; i++)
> +		buf[BUFFER_LEN / 3 + i] = value;
> +
> +	ok = audio_signal_detect(signal, SAMPLING_RATE, 0, buf, BUFFER_LEN);
> +
> +	free(buf);
> +
> +	igt_assert(!ok);

Please add a reason here. With this done, the patch is:
Reviewed-by: Martin Peres <martin.peres at linux.intel.com>

> +}
> +
>  igt_main
>  {
>  	struct audio_signal *signal;
> @@ -151,6 +173,9 @@ igt_main
>  		igt_subtest("signal-detect-with-unexpected-freq")
>  			test_signal_detect_with_unexpected_freq(signal);
> 
> +		igt_subtest("signal-detect-held-sample")
> +			test_signal_detect_held_sample(signal);
> +
>  		igt_fixture {
>  			audio_signal_fini(signal);
>  		}
> --
> 2.21.0
> 


More information about the igt-dev mailing list