[igt-dev] [PATCH i-g-t 3/5] lib/tests/igt_audio: add test with an extra frequency

Martin Peres martin.peres at linux.intel.com
Mon Jun 3 13:49:12 UTC 2019


On 29/05/2019 16:32, Simon Ser wrote:
> Make sure it fails.
> 
> 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 7b068c255973..0f1c39d93728 100644
> --- a/lib/tests/igt_audio.c
> +++ b/lib/tests/igt_audio.c
> @@ -36,6 +36,8 @@ static const int test_freqs[] = { 300, 700, 5000 };
>  
>  static const size_t test_freqs_len = sizeof(test_freqs) / sizeof(test_freqs[0]);
>  
> +#define TEST_EXTRA_FREQ 500
> +
>  static void test_signal_detect_verbatim(struct audio_signal *signal)
>  {
>  	double buf[BUFFER_LEN];
> @@ -89,6 +91,26 @@ static void test_signal_detect_missing(struct audio_signal *signal)
>  	igt_assert(!ok);
>  }
>  
> +static void test_signal_detect_extra(struct audio_signal *signal)

test_signal_detect_with_unexpected_frequency()

> +{
> +	double buf[BUFFER_LEN];
> +	struct audio_signal *extra;
> +	bool ok;
> +	size_t i;
> +
> +	/* Add an extra, unexpected frequency */
> +	extra = audio_signal_init(CHANNELS, SAMPLING_RATE);
> +	for (i = 0; i < test_freqs_len; i++) {
> +		audio_signal_add_frequency(extra, test_freqs[i], 0);
> +	}
> +	audio_signal_add_frequency(extra, TEST_EXTRA_FREQ, 0);
> +	audio_signal_synthesize(extra);
> +
> +	audio_signal_fill(extra, buf, BUFFER_LEN / CHANNELS);
> +	ok = audio_signal_detect(signal, SAMPLING_RATE, 0, buf, BUFFER_LEN);
> +	igt_assert(!ok);
> +}
> +
>  igt_main
>  {
>  	struct audio_signal *signal;
> @@ -121,6 +143,9 @@ igt_main
>  		igt_subtest("signal-detect-missing")

Sorry, I forgot to check the name during the review of the previous
patch. Would be better-named: test_signal_detect_with_missing_frequency

With the subtest names changed:
Reviewed-by: Martin Peres <martin.peres at linux.intel.com>

>  			test_signal_detect_missing(signal);
>  
> +		igt_subtest("signal-detect-extra")
> +			test_signal_detect_extra(signal);
> +
>  		igt_fixture {
>  			audio_signal_fini(signal);
>  		}
> 


More information about the igt-dev mailing list