1 /*
2  * Copyright (c) 2021 Stephanos Ioannidis <root@stephanos.io>
3  * Copyright (C) 2010-2021 ARM Limited or its affiliates. All rights reserved.
4  *
5  * SPDX-License-Identifier: Apache-2.0
6  */
7 
8 #include <zephyr/dsp/dsp.h>
9 #include <zephyr/ztest.h>
10 #include <zephyr/kernel.h>
11 #include <stdlib.h>
12 #include "common/test_common.h"
13 
14 #include "q7.pat"
15 
16 #define SNR_ERROR_THRESH	((float32_t)20)
17 #define ABS_ERROR_THRESH_Q7	((q7_t)2)
18 #define ABS_ERROR_THRESH_Q31	((q31_t)(1 << 15))
19 
test_zdsp_add_q7(const DSP_DATA q7_t * input1,const DSP_DATA q7_t * input2,const q7_t * ref,size_t length)20 static void test_zdsp_add_q7(const DSP_DATA q7_t *input1, const DSP_DATA q7_t *input2,
21 				const q7_t *ref, size_t length)
22 {
23 	DSP_DATA q7_t *output;
24 
25 	/* Allocate output buffer */
26 	output = (DSP_DATA q7_t *)(DSP_DATA q7_t *)malloc(length * sizeof(q7_t));
27 	zassert_not_null(output, ASSERT_MSG_BUFFER_ALLOC_FAILED);
28 
29 	/* Run test function */
30 	zdsp_add_q7(input1, input2, output, length);
31 
32 	/* Validate output */
33 	zassert_true(
34 		test_snr_error_q7(length, output, ref, SNR_ERROR_THRESH),
35 		ASSERT_MSG_SNR_LIMIT_EXCEED);
36 
37 	zassert_true(
38 		test_near_equal_q7(length, output, ref, ABS_ERROR_THRESH_Q7),
39 		ASSERT_MSG_ABS_ERROR_LIMIT_EXCEED);
40 
41 	/* Free output buffer */
42 	free(output);
43 }
44 
45 DEFINE_TEST_VARIANT4(basic_math_q7, zdsp_add_q7, 15, in_com1, in_com2, ref_add, 15);
46 DEFINE_TEST_VARIANT4(basic_math_q7, zdsp_add_q7, 32, in_com1, in_com2, ref_add, 32);
47 DEFINE_TEST_VARIANT4(basic_math_q7, zdsp_add_q7, 47, in_com1, in_com2, ref_add, 47);
48 DEFINE_TEST_VARIANT4(basic_math_q7, zdsp_add_q7, possat, in_maxpos, in_maxpos, ref_add_possat, 33);
49 DEFINE_TEST_VARIANT4(basic_math_q7, zdsp_add_q7, negsat, in_maxneg, in_maxneg, ref_add_negsat, 33);
50 DEFINE_TEST_VARIANT4(basic_math_q7, zdsp_add_q7, long, in_com1, in_com2, ref_add,
51 		     ARRAY_SIZE(in_com1));
52 
test_zdsp_add_q7_in_place(const DSP_DATA q7_t * input1,const DSP_DATA q7_t * input2,const q7_t * ref,size_t length)53 static void test_zdsp_add_q7_in_place(const DSP_DATA q7_t *input1, const DSP_DATA q7_t *input2,
54 				const q7_t *ref, size_t length)
55 {
56 	DSP_DATA q7_t *output;
57 
58 	/* Allocate output buffer */
59 	output = (DSP_DATA q7_t *)(DSP_DATA q7_t *)malloc(length * sizeof(q7_t));
60 	zassert_not_null(output, ASSERT_MSG_BUFFER_ALLOC_FAILED);
61 
62 	/* Copy input data to output*/
63 	memcpy(output, input1, length * sizeof(q7_t));
64 
65 	/* Run test function */
66 	zdsp_add_q7(output, input2, output, length);
67 
68 	/* Validate output */
69 	zassert_true(test_snr_error_q7(length, output, ref, SNR_ERROR_THRESH),
70 		     ASSERT_MSG_SNR_LIMIT_EXCEED);
71 
72 	zassert_true(test_near_equal_q7(length, output, ref, ABS_ERROR_THRESH_Q7),
73 		     ASSERT_MSG_ABS_ERROR_LIMIT_EXCEED);
74 
75 	/* Free output buffer */
76 	free(output);
77 }
78 
79 DEFINE_TEST_VARIANT4(basic_math_q7, zdsp_add_q7_in_place, 15, in_com1, in_com2, ref_add, 15);
80 DEFINE_TEST_VARIANT4(basic_math_q7, zdsp_add_q7_in_place, 32, in_com1, in_com2, ref_add, 32);
81 DEFINE_TEST_VARIANT4(basic_math_q7, zdsp_add_q7_in_place, 47, in_com1, in_com2, ref_add, 47);
82 DEFINE_TEST_VARIANT4(basic_math_q7, zdsp_add_q7_in_place, possat, in_maxpos, in_maxpos,
83 		     ref_add_possat, 33);
84 DEFINE_TEST_VARIANT4(basic_math_q7, zdsp_add_q7_in_place, negsat, in_maxneg, in_maxneg,
85 		     ref_add_negsat, 33);
86 DEFINE_TEST_VARIANT4(basic_math_q7, zdsp_add_q7_in_place, long, in_com1, in_com2, ref_add,
87 		     ARRAY_SIZE(in_com1));
88 
test_zdsp_sub_q7(const DSP_DATA q7_t * input1,const DSP_DATA q7_t * input2,const q7_t * ref,size_t length)89 static void test_zdsp_sub_q7(const DSP_DATA q7_t *input1, const DSP_DATA q7_t *input2,
90 				const q7_t *ref, size_t length)
91 {
92 	DSP_DATA q7_t *output;
93 
94 	/* Allocate output buffer */
95 	output = (DSP_DATA q7_t *)(DSP_DATA q7_t *)malloc(length * sizeof(q7_t));
96 	zassert_not_null(output, ASSERT_MSG_BUFFER_ALLOC_FAILED);
97 
98 	/* Run test function */
99 	zdsp_sub_q7(input1, input2, output, length);
100 
101 	/* Validate output */
102 	zassert_true(
103 		test_snr_error_q7(length, output, ref, SNR_ERROR_THRESH),
104 		ASSERT_MSG_SNR_LIMIT_EXCEED);
105 
106 	zassert_true(
107 		test_near_equal_q7(length, output, ref, ABS_ERROR_THRESH_Q7),
108 		ASSERT_MSG_ABS_ERROR_LIMIT_EXCEED);
109 
110 	/* Free output buffer */
111 	free(output);
112 }
113 
114 DEFINE_TEST_VARIANT4(basic_math_q7, zdsp_sub_q7, 15, in_com1, in_com2, ref_sub, 15);
115 DEFINE_TEST_VARIANT4(basic_math_q7, zdsp_sub_q7, 32, in_com1, in_com2, ref_sub, 32);
116 DEFINE_TEST_VARIANT4(basic_math_q7, zdsp_sub_q7, 47, in_com1, in_com2, ref_sub, 47);
117 DEFINE_TEST_VARIANT4(basic_math_q7, zdsp_sub_q7, possat, in_maxpos, in_maxneg, ref_sub_possat, 33);
118 DEFINE_TEST_VARIANT4(basic_math_q7, zdsp_sub_q7, negsat, in_maxneg, in_maxpos, ref_sub_negsat, 33);
119 DEFINE_TEST_VARIANT4(basic_math_q7, zdsp_sub_q7, long, in_com1, in_com2, ref_sub,
120 		     ARRAY_SIZE(in_com1));
121 
test_zdsp_sub_q7_in_place(const DSP_DATA q7_t * input1,const DSP_DATA q7_t * input2,const q7_t * ref,size_t length)122 static void test_zdsp_sub_q7_in_place(const DSP_DATA q7_t *input1, const DSP_DATA q7_t *input2,
123 				const q7_t *ref, size_t length)
124 {
125 	DSP_DATA q7_t *output;
126 
127 	/* Allocate output buffer */
128 	output = (DSP_DATA q7_t *)(DSP_DATA q7_t *)malloc(length * sizeof(q7_t));
129 	zassert_not_null(output, ASSERT_MSG_BUFFER_ALLOC_FAILED);
130 
131 	/* Copy input data to output*/
132 	memcpy(output, input1, length * sizeof(q7_t));
133 
134 	/* Run test function */
135 	zdsp_sub_q7(output, input2, output, length);
136 
137 	/* Validate output */
138 	zassert_true(test_snr_error_q7(length, output, ref, SNR_ERROR_THRESH),
139 		     ASSERT_MSG_SNR_LIMIT_EXCEED);
140 
141 	zassert_true(test_near_equal_q7(length, output, ref, ABS_ERROR_THRESH_Q7),
142 		     ASSERT_MSG_ABS_ERROR_LIMIT_EXCEED);
143 
144 	/* Free output buffer */
145 	free(output);
146 }
147 
148 DEFINE_TEST_VARIANT4(basic_math_q7, zdsp_sub_q7_in_place, 15, in_com1, in_com2, ref_sub, 15);
149 DEFINE_TEST_VARIANT4(basic_math_q7, zdsp_sub_q7_in_place, 32, in_com1, in_com2, ref_sub, 32);
150 DEFINE_TEST_VARIANT4(basic_math_q7, zdsp_sub_q7_in_place, 47, in_com1, in_com2, ref_sub, 47);
151 DEFINE_TEST_VARIANT4(basic_math_q7, zdsp_sub_q7_in_place, possat, in_maxpos, in_maxneg,
152 		     ref_sub_possat, 33);
153 DEFINE_TEST_VARIANT4(basic_math_q7, zdsp_sub_q7_in_place, negsat, in_maxneg, in_maxpos,
154 		     ref_sub_negsat, 33);
155 DEFINE_TEST_VARIANT4(basic_math_q7, zdsp_sub_q7_in_place, long, in_com1, in_com2, ref_sub,
156 		     ARRAY_SIZE(in_com1));
157 
test_zdsp_mult_q7(const DSP_DATA q7_t * input1,const DSP_DATA q7_t * input2,const q7_t * ref,size_t length)158 static void test_zdsp_mult_q7(const DSP_DATA q7_t *input1, const DSP_DATA q7_t *input2,
159 				const q7_t *ref, size_t length)
160 {
161 	DSP_DATA q7_t *output;
162 
163 	/* Allocate output buffer */
164 	output = (DSP_DATA q7_t *)malloc(length * sizeof(q7_t));
165 	zassert_not_null(output, ASSERT_MSG_BUFFER_ALLOC_FAILED);
166 
167 	/* Run test function */
168 	zdsp_mult_q7(input1, input2, output, length);
169 
170 	/* Validate output */
171 	zassert_true(
172 		test_snr_error_q7(length, output, ref, SNR_ERROR_THRESH),
173 		ASSERT_MSG_SNR_LIMIT_EXCEED);
174 
175 	zassert_true(
176 		test_near_equal_q7(length, output, ref, ABS_ERROR_THRESH_Q7),
177 		ASSERT_MSG_ABS_ERROR_LIMIT_EXCEED);
178 
179 	/* Free output buffer */
180 	free(output);
181 }
182 
183 DEFINE_TEST_VARIANT4(basic_math_q7, zdsp_mult_q7, 15, in_com1, in_com2, ref_mult, 15);
184 DEFINE_TEST_VARIANT4(basic_math_q7, zdsp_mult_q7, 32, in_com1, in_com2, ref_mult, 32);
185 DEFINE_TEST_VARIANT4(basic_math_q7, zdsp_mult_q7, 47, in_com1, in_com2, ref_mult, 47);
186 DEFINE_TEST_VARIANT4(basic_math_q7, zdsp_mult_q7, possat, in_maxneg2, in_maxneg2, ref_mult_possat,
187 		     33);
188 DEFINE_TEST_VARIANT4(basic_math_q7, zdsp_mult_q7, long, in_com1, in_com2, ref_mult,
189 		     ARRAY_SIZE(in_com1));
190 
test_zdsp_mult_q7_in_place(const DSP_DATA q7_t * input1,const DSP_DATA q7_t * input2,const q7_t * ref,size_t length)191 static void test_zdsp_mult_q7_in_place(const DSP_DATA q7_t *input1, const DSP_DATA q7_t *input2,
192 				const q7_t *ref, size_t length)
193 {
194 	DSP_DATA q7_t *output;
195 
196 	/* Allocate output buffer */
197 	output = (DSP_DATA q7_t *)malloc(length * sizeof(q7_t));
198 	zassert_not_null(output, ASSERT_MSG_BUFFER_ALLOC_FAILED);
199 
200 	/* Copy input data to output*/
201 	memcpy(output, input1, length * sizeof(q7_t));
202 
203 	/* Run test function */
204 	zdsp_mult_q7(output, input2, output, length);
205 
206 	/* Validate output */
207 	zassert_true(test_snr_error_q7(length, output, ref, SNR_ERROR_THRESH),
208 		     ASSERT_MSG_SNR_LIMIT_EXCEED);
209 
210 	zassert_true(test_near_equal_q7(length, output, ref, ABS_ERROR_THRESH_Q7),
211 		     ASSERT_MSG_ABS_ERROR_LIMIT_EXCEED);
212 
213 	/* Free output buffer */
214 	free(output);
215 }
216 
217 DEFINE_TEST_VARIANT4(basic_math_q7, zdsp_mult_q7_in_place, 15, in_com1, in_com2, ref_mult, 15);
218 DEFINE_TEST_VARIANT4(basic_math_q7, zdsp_mult_q7_in_place, 32, in_com1, in_com2, ref_mult, 32);
219 DEFINE_TEST_VARIANT4(basic_math_q7, zdsp_mult_q7_in_place, 47, in_com1, in_com2, ref_mult, 47);
220 DEFINE_TEST_VARIANT4(basic_math_q7, zdsp_mult_q7_in_place, possat, in_maxneg2, in_maxneg2,
221 		     ref_mult_possat, 33);
222 DEFINE_TEST_VARIANT4(basic_math_q7, zdsp_mult_q7_in_place, long, in_com1, in_com2, ref_mult,
223 		     ARRAY_SIZE(in_com1));
224 
test_zdsp_negate_q7(const DSP_DATA q7_t * input1,const q7_t * ref,size_t length)225 static void test_zdsp_negate_q7(const DSP_DATA q7_t *input1, const q7_t *ref, size_t length)
226 {
227 	DSP_DATA q7_t *output;
228 
229 	/* Allocate output buffer */
230 	output = (DSP_DATA q7_t *)malloc(length * sizeof(q7_t));
231 	zassert_not_null(output, ASSERT_MSG_BUFFER_ALLOC_FAILED);
232 
233 	/* Run test function */
234 	zdsp_negate_q7(input1, output, length);
235 
236 	/* Validate output */
237 	zassert_true(
238 		test_snr_error_q7(length, output, ref, SNR_ERROR_THRESH),
239 		ASSERT_MSG_SNR_LIMIT_EXCEED);
240 
241 	zassert_true(
242 		test_near_equal_q7(length, output, ref, ABS_ERROR_THRESH_Q7),
243 		ASSERT_MSG_ABS_ERROR_LIMIT_EXCEED);
244 
245 	/* Free output buffer */
246 	free(output);
247 }
248 
249 DEFINE_TEST_VARIANT3(basic_math_q7, zdsp_negate_q7, 15, in_com1, ref_negate, 15);
250 DEFINE_TEST_VARIANT3(basic_math_q7, zdsp_negate_q7, 32, in_com1, ref_negate, 32);
251 DEFINE_TEST_VARIANT3(basic_math_q7, zdsp_negate_q7, 47, in_com1, ref_negate, 47);
252 DEFINE_TEST_VARIANT3(basic_math_q7, zdsp_negate_q7, possat, in_maxneg2, ref_negate_possat, 33);
253 DEFINE_TEST_VARIANT3(basic_math_q7, zdsp_negate_q7, long, in_com1, ref_negate, ARRAY_SIZE(in_com1));
254 
test_zdsp_negate_q7_in_place(const DSP_DATA q7_t * input1,const q7_t * ref,size_t length)255 static void test_zdsp_negate_q7_in_place(const DSP_DATA q7_t *input1, const q7_t *ref,
256 				size_t length)
257 {
258 	DSP_DATA q7_t *output;
259 
260 	/* Allocate output buffer */
261 	output = (DSP_DATA q7_t *)malloc(length * sizeof(q7_t));
262 	zassert_not_null(output, ASSERT_MSG_BUFFER_ALLOC_FAILED);
263 
264 	/* Copy input data to output*/
265 	memcpy(output, input1, length * sizeof(q7_t));
266 
267 	/* Run test function */
268 	zdsp_negate_q7(output, output, length);
269 
270 	/* Validate output */
271 	zassert_true(test_snr_error_q7(length, output, ref, SNR_ERROR_THRESH),
272 		     ASSERT_MSG_SNR_LIMIT_EXCEED);
273 
274 	zassert_true(test_near_equal_q7(length, output, ref, ABS_ERROR_THRESH_Q7),
275 		     ASSERT_MSG_ABS_ERROR_LIMIT_EXCEED);
276 
277 	/* Free output buffer */
278 	free(output);
279 }
280 
281 DEFINE_TEST_VARIANT3(basic_math_q7, zdsp_negate_q7_in_place, 15, in_com1, ref_negate, 15);
282 DEFINE_TEST_VARIANT3(basic_math_q7, zdsp_negate_q7_in_place, 32, in_com1, ref_negate, 32);
283 DEFINE_TEST_VARIANT3(basic_math_q7, zdsp_negate_q7_in_place, 47, in_com1, ref_negate, 47);
284 DEFINE_TEST_VARIANT3(basic_math_q7, zdsp_negate_q7_in_place, possat, in_maxneg2, ref_negate_possat,
285 		     33);
286 DEFINE_TEST_VARIANT3(basic_math_q7, zdsp_negate_q7_in_place, long, in_com1, ref_negate,
287 		     ARRAY_SIZE(in_com1));
288 
test_zdsp_offset_q7(const DSP_DATA q7_t * input1,q7_t scalar,const q7_t * ref,size_t length)289 static void test_zdsp_offset_q7(const DSP_DATA q7_t *input1, q7_t scalar, const q7_t *ref,
290 				size_t length)
291 {
292 	DSP_DATA q7_t *output;
293 
294 	/* Allocate output buffer */
295 	output = (DSP_DATA q7_t *)malloc(length * sizeof(q7_t));
296 	zassert_not_null(output, ASSERT_MSG_BUFFER_ALLOC_FAILED);
297 
298 	/* Run test function */
299 	zdsp_offset_q7(input1, scalar, output, length);
300 
301 	/* Validate output */
302 	zassert_true(
303 		test_snr_error_q7(length, output, ref, SNR_ERROR_THRESH),
304 		ASSERT_MSG_SNR_LIMIT_EXCEED);
305 
306 	zassert_true(
307 		test_near_equal_q7(length, output, ref, ABS_ERROR_THRESH_Q7),
308 		ASSERT_MSG_ABS_ERROR_LIMIT_EXCEED);
309 
310 	/* Free output buffer */
311 	free(output);
312 }
313 
314 DEFINE_TEST_VARIANT4(basic_math_q7, zdsp_offset_q7, 0p5_15, in_com1, 0x40, ref_offset, 15);
315 DEFINE_TEST_VARIANT4(basic_math_q7, zdsp_offset_q7, 0p5_32, in_com1, 0x40, ref_offset, 32);
316 DEFINE_TEST_VARIANT4(basic_math_q7, zdsp_offset_q7, 0p5_47, in_com1, 0x40, ref_offset, 47);
317 DEFINE_TEST_VARIANT4(basic_math_q7, zdsp_offset_q7, possat, in_maxpos, 0x73, ref_offset_possat, 33);
318 DEFINE_TEST_VARIANT4(basic_math_q7, zdsp_offset_q7, negsat, in_maxneg, 0x8d, ref_offset_negsat, 33);
319 DEFINE_TEST_VARIANT4(basic_math_q7, zdsp_offset_q7, long, in_com1, 0x40, ref_offset,
320 		     ARRAY_SIZE(in_com1));
321 
test_zdsp_offset_q7_in_place(const DSP_DATA q7_t * input1,q7_t scalar,const q7_t * ref,size_t length)322 static void test_zdsp_offset_q7_in_place(const DSP_DATA q7_t *input1, q7_t scalar, const q7_t *ref,
323 				size_t length)
324 {
325 	DSP_DATA q7_t *output;
326 
327 	/* Allocate output buffer */
328 	output = (DSP_DATA q7_t *)malloc(length * sizeof(q7_t));
329 	zassert_not_null(output, ASSERT_MSG_BUFFER_ALLOC_FAILED);
330 
331 	/* Copy input data to output*/
332 	memcpy(output, input1, length * sizeof(q7_t));
333 
334 	/* Run test function */
335 	zdsp_offset_q7(output, scalar, output, length);
336 
337 	/* Validate output */
338 	zassert_true(test_snr_error_q7(length, output, ref, SNR_ERROR_THRESH),
339 		     ASSERT_MSG_SNR_LIMIT_EXCEED);
340 
341 	zassert_true(test_near_equal_q7(length, output, ref, ABS_ERROR_THRESH_Q7),
342 		     ASSERT_MSG_ABS_ERROR_LIMIT_EXCEED);
343 
344 	/* Free output buffer */
345 	free(output);
346 }
347 
348 DEFINE_TEST_VARIANT4(basic_math_q7, zdsp_offset_q7_in_place, 0p5_15, in_com1, 0x40, ref_offset, 15);
349 DEFINE_TEST_VARIANT4(basic_math_q7, zdsp_offset_q7_in_place, 0p5_32, in_com1, 0x40, ref_offset, 32);
350 DEFINE_TEST_VARIANT4(basic_math_q7, zdsp_offset_q7_in_place, 0p5_47, in_com1, 0x40, ref_offset, 47);
351 DEFINE_TEST_VARIANT4(basic_math_q7, zdsp_offset_q7_in_place, possat, in_maxpos, 0x73,
352 		     ref_offset_possat, 33);
353 DEFINE_TEST_VARIANT4(basic_math_q7, zdsp_offset_q7_in_place, negsat, in_maxneg, 0x8d,
354 		     ref_offset_negsat, 33);
355 DEFINE_TEST_VARIANT4(basic_math_q7, zdsp_offset_q7_in_place, long, in_com1, 0x40, ref_offset,
356 		     ARRAY_SIZE(in_com1));
357 
test_zdsp_scale_q7(const DSP_DATA q7_t * input1,q7_t scalar,const q7_t * ref,size_t length)358 static void test_zdsp_scale_q7(const DSP_DATA q7_t *input1, q7_t scalar, const q7_t *ref,
359 				size_t length)
360 {
361 	DSP_DATA q7_t *output;
362 
363 	/* Allocate output buffer */
364 	output = (DSP_DATA q7_t *)malloc(length * sizeof(q7_t));
365 	zassert_not_null(output, ASSERT_MSG_BUFFER_ALLOC_FAILED);
366 
367 	/* Run test function */
368 	zdsp_scale_q7(input1, scalar, 0, output, length);
369 
370 	/* Validate output */
371 	zassert_true(
372 		test_snr_error_q7(length, output, ref, SNR_ERROR_THRESH),
373 		ASSERT_MSG_SNR_LIMIT_EXCEED);
374 
375 	zassert_true(
376 		test_near_equal_q7(length, output, ref, ABS_ERROR_THRESH_Q7),
377 		ASSERT_MSG_ABS_ERROR_LIMIT_EXCEED);
378 
379 	/* Free output buffer */
380 	free(output);
381 }
382 
383 DEFINE_TEST_VARIANT4(basic_math_q7, zdsp_scale_q7, 0p5_15, in_com1, 0x40, ref_scale, 15);
384 DEFINE_TEST_VARIANT4(basic_math_q7, zdsp_scale_q7, 0p5_32, in_com1, 0x40, ref_scale, 32);
385 DEFINE_TEST_VARIANT4(basic_math_q7, zdsp_scale_q7, 0p5_47, in_com1, 0x40, ref_scale, 47);
386 DEFINE_TEST_VARIANT4(basic_math_q7, zdsp_scale_q7, possat, in_maxneg2, 0x80, ref_scale_possat, 33);
387 DEFINE_TEST_VARIANT4(basic_math_q7, zdsp_scale_q7, long, in_com1, 0x40, ref_scale,
388 		     ARRAY_SIZE(in_com1));
389 
test_zdsp_scale_q7_in_place(const DSP_DATA q7_t * input1,q7_t scalar,const q7_t * ref,size_t length)390 static void test_zdsp_scale_q7_in_place(const DSP_DATA q7_t *input1, q7_t scalar, const q7_t *ref,
391 				size_t length)
392 {
393 	DSP_DATA q7_t *output;
394 
395 	/* Allocate output buffer */
396 	output = (DSP_DATA q7_t *)malloc(length * sizeof(q7_t));
397 	zassert_not_null(output, ASSERT_MSG_BUFFER_ALLOC_FAILED);
398 
399 	/* Copy input data to output*/
400 	memcpy(output, input1, length * sizeof(q7_t));
401 
402 	/* Run test function */
403 	zdsp_scale_q7(output, scalar, 0, output, length);
404 
405 	/* Validate output */
406 	zassert_true(test_snr_error_q7(length, output, ref, SNR_ERROR_THRESH),
407 		     ASSERT_MSG_SNR_LIMIT_EXCEED);
408 
409 	zassert_true(test_near_equal_q7(length, output, ref, ABS_ERROR_THRESH_Q7),
410 		     ASSERT_MSG_ABS_ERROR_LIMIT_EXCEED);
411 
412 	/* Free output buffer */
413 	free(output);
414 }
415 
416 DEFINE_TEST_VARIANT4(basic_math_q7, zdsp_scale_q7_in_place, 0p5_15, in_com1, 0x40, ref_scale, 15);
417 DEFINE_TEST_VARIANT4(basic_math_q7, zdsp_scale_q7_in_place, 0p5_32, in_com1, 0x40, ref_scale, 32);
418 DEFINE_TEST_VARIANT4(basic_math_q7, zdsp_scale_q7_in_place, 0p5_47, in_com1, 0x40, ref_scale, 47);
419 DEFINE_TEST_VARIANT4(basic_math_q7, zdsp_scale_q7_in_place, possat, in_maxneg2, 0x80,
420 		     ref_scale_possat, 33);
421 DEFINE_TEST_VARIANT4(basic_math_q7, zdsp_scale_q7_in_place, long, in_com1, 0x40, ref_scale,
422 		     ARRAY_SIZE(in_com1));
423 
test_zdsp_dot_prod_q7(const DSP_DATA q7_t * input1,const DSP_DATA q7_t * input2,const q31_t * ref,size_t length)424 static void test_zdsp_dot_prod_q7(const DSP_DATA q7_t *input1, const DSP_DATA q7_t *input2,
425 				const q31_t *ref, size_t length)
426 {
427 	DSP_DATA q31_t *output;
428 
429 	/* Allocate output buffer */
430 	output = (DSP_DATA q31_t *)malloc(1 * sizeof(q31_t));
431 	zassert_not_null(output, ASSERT_MSG_BUFFER_ALLOC_FAILED);
432 
433 	/* Run test function */
434 	zdsp_dot_prod_q7(input1, input2, length, &output[0]);
435 
436 	/* Validate output */
437 	zassert_true(
438 		test_snr_error_q31(1, output, ref, SNR_ERROR_THRESH),
439 		ASSERT_MSG_SNR_LIMIT_EXCEED);
440 
441 	zassert_true(
442 		test_near_equal_q31(1, output, ref, ABS_ERROR_THRESH_Q31),
443 		ASSERT_MSG_ABS_ERROR_LIMIT_EXCEED);
444 
445 	/* Free output buffer */
446 	free(output);
447 }
448 
449 DEFINE_TEST_VARIANT4(basic_math_q7, zdsp_dot_prod_q7, 15, in_com1, in_com2, ref_dot_prod_3, 15);
450 DEFINE_TEST_VARIANT4(basic_math_q7, zdsp_dot_prod_q7, 32, in_com1, in_com2, ref_dot_prod_4, 32);
451 DEFINE_TEST_VARIANT4(basic_math_q7, zdsp_dot_prod_q7, 47, in_com1, in_com2, ref_dot_prod_4n1, 47);
452 DEFINE_TEST_VARIANT4(basic_math_q7, zdsp_dot_prod_q7, long, in_com1, in_com2, ref_dot_prod_long,
453 		     ARRAY_SIZE(in_com1));
454 
test_zdsp_abs_q7(const DSP_DATA q7_t * input1,const q7_t * ref,size_t length)455 static void test_zdsp_abs_q7(const DSP_DATA q7_t *input1, const q7_t *ref, size_t length)
456 {
457 	DSP_DATA q7_t *output;
458 
459 	/* Allocate output buffer */
460 	output = (DSP_DATA q7_t *)malloc(length * sizeof(q7_t));
461 	zassert_not_null(output, ASSERT_MSG_BUFFER_ALLOC_FAILED);
462 
463 	/* Run test function */
464 	zdsp_abs_q7(input1, output, length);
465 
466 	/* Validate output */
467 	zassert_true(
468 		test_snr_error_q7(length, output, ref, SNR_ERROR_THRESH),
469 		ASSERT_MSG_SNR_LIMIT_EXCEED);
470 
471 	zassert_true(
472 		test_near_equal_q7(length, output, ref, ABS_ERROR_THRESH_Q7),
473 		ASSERT_MSG_ABS_ERROR_LIMIT_EXCEED);
474 
475 	/* Free output buffer */
476 	free(output);
477 }
478 
479 DEFINE_TEST_VARIANT3(basic_math_q7, zdsp_abs_q7, 15, in_com1, ref_abs, 15);
480 DEFINE_TEST_VARIANT3(basic_math_q7, zdsp_abs_q7, 32, in_com1, ref_abs, 32);
481 DEFINE_TEST_VARIANT3(basic_math_q7, zdsp_abs_q7, 47, in_com1, ref_abs, 47);
482 DEFINE_TEST_VARIANT3(basic_math_q7, zdsp_abs_q7, long, in_com1, ref_abs, ARRAY_SIZE(ref_abs));
483 
test_zdsp_abs_q7_in_place(const DSP_DATA q7_t * input1,const q7_t * ref,size_t length)484 static void test_zdsp_abs_q7_in_place(const DSP_DATA q7_t *input1, const q7_t *ref, size_t length)
485 {
486 	DSP_DATA q7_t *output;
487 
488 	/* Allocate output buffer */
489 	output = (DSP_DATA q7_t *)malloc(length * sizeof(q7_t));
490 	zassert_not_null(output, ASSERT_MSG_BUFFER_ALLOC_FAILED);
491 
492 	/* Copy input data to output*/
493 	memcpy(output, input1, length * sizeof(q7_t));
494 
495 	/* Run test function */
496 	zdsp_abs_q7(output, output, length);
497 
498 	/* Validate output */
499 	zassert_true(test_snr_error_q7(length, output, ref, SNR_ERROR_THRESH),
500 		     ASSERT_MSG_SNR_LIMIT_EXCEED);
501 
502 	zassert_true(test_near_equal_q7(length, output, ref, ABS_ERROR_THRESH_Q7),
503 		     ASSERT_MSG_ABS_ERROR_LIMIT_EXCEED);
504 
505 	/* Free output buffer */
506 	free(output);
507 }
508 
509 DEFINE_TEST_VARIANT3(basic_math_q7, zdsp_abs_q7_in_place, 15, in_com1, ref_abs, 15);
510 DEFINE_TEST_VARIANT3(basic_math_q7, zdsp_abs_q7_in_place, 32, in_com1, ref_abs, 32);
511 DEFINE_TEST_VARIANT3(basic_math_q7, zdsp_abs_q7_in_place, 47, in_com1, ref_abs, 47);
512 DEFINE_TEST_VARIANT3(basic_math_q7, zdsp_abs_q7_in_place, long, in_com1, ref_abs,
513 		     ARRAY_SIZE(ref_abs));
514 
test_zdsp_shift_q7(const DSP_DATA q7_t * input1,const q7_t * ref,size_t length)515 static void test_zdsp_shift_q7(const DSP_DATA q7_t *input1, const q7_t *ref, size_t length)
516 {
517 	DSP_DATA q7_t *output;
518 
519 	/* Allocate output buffer */
520 	output = (DSP_DATA q7_t *)malloc(length * sizeof(q7_t));
521 	zassert_not_null(output, ASSERT_MSG_BUFFER_ALLOC_FAILED);
522 
523 	/* Run test function */
524 	zdsp_shift_q7(input1, 1, output, length);
525 
526 	/* Validate output */
527 	zassert_true(
528 		test_snr_error_q7(length, output, ref, SNR_ERROR_THRESH),
529 		ASSERT_MSG_SNR_LIMIT_EXCEED);
530 
531 	zassert_true(
532 		test_near_equal_q7(length, output, ref, ABS_ERROR_THRESH_Q7),
533 		ASSERT_MSG_ABS_ERROR_LIMIT_EXCEED);
534 
535 	/* Free output buffer */
536 	free(output);
537 }
538 
539 DEFINE_TEST_VARIANT3(basic_math_q7, zdsp_shift_q7, rand, in_rand, ref_shift, 33);
540 DEFINE_TEST_VARIANT3(basic_math_q7, zdsp_shift_q7, possat, in_maxpos, ref_shift_possat, 33);
541 DEFINE_TEST_VARIANT3(basic_math_q7, zdsp_shift_q7, negsat, in_maxneg, ref_shift_negsat, 33);
542 
test_zdsp_shift_q7_in_place(const DSP_DATA q7_t * input1,const q7_t * ref,size_t length)543 static void test_zdsp_shift_q7_in_place(const DSP_DATA q7_t *input1, const q7_t *ref, size_t length)
544 {
545 	DSP_DATA q7_t *output;
546 
547 	/* Allocate output buffer */
548 	output = (DSP_DATA q7_t *)malloc(length * sizeof(q7_t));
549 	zassert_not_null(output, ASSERT_MSG_BUFFER_ALLOC_FAILED);
550 
551 	/* Copy input data to output*/
552 	memcpy(output, input1, length * sizeof(q7_t));
553 
554 	/* Run test function */
555 	zdsp_shift_q7(output, 1, output, length);
556 
557 	/* Validate output */
558 	zassert_true(test_snr_error_q7(length, output, ref, SNR_ERROR_THRESH),
559 		     ASSERT_MSG_SNR_LIMIT_EXCEED);
560 
561 	zassert_true(test_near_equal_q7(length, output, ref, ABS_ERROR_THRESH_Q7),
562 		     ASSERT_MSG_ABS_ERROR_LIMIT_EXCEED);
563 
564 	/* Free output buffer */
565 	free(output);
566 }
567 
568 DEFINE_TEST_VARIANT3(basic_math_q7, zdsp_shift_q7_in_place, rand, in_rand, ref_shift, 33);
569 DEFINE_TEST_VARIANT3(basic_math_q7, zdsp_shift_q7_in_place, possat, in_maxpos, ref_shift_possat,
570 		     33);
571 DEFINE_TEST_VARIANT3(basic_math_q7, zdsp_shift_q7_in_place, negsat, in_maxneg, ref_shift_negsat,
572 		     33);
573 
test_zdsp_and_u8(const DSP_DATA uint8_t * input1,const DSP_DATA uint8_t * input2,const uint8_t * ref,size_t length)574 static void test_zdsp_and_u8(const DSP_DATA uint8_t *input1, const DSP_DATA uint8_t *input2,
575 				const uint8_t *ref, size_t length)
576 {
577 	DSP_DATA uint8_t *output;
578 
579 	/* Allocate output buffer */
580 	output = (DSP_DATA q7_t *)malloc(length * sizeof(uint8_t));
581 	zassert_not_null(output, ASSERT_MSG_BUFFER_ALLOC_FAILED);
582 
583 	/* Run test function */
584 	zdsp_and_u8(input1, input2, output, length);
585 
586 	/* Validate output */
587 	zassert_true(
588 		test_equal_q7(length, output, ref),
589 		ASSERT_MSG_INCORRECT_COMP_RESULT);
590 
591 	/* Free output buffer */
592 	free(output);
593 }
594 
595 DEFINE_TEST_VARIANT4(basic_math_q7, zdsp_and_u8, 15, in_bitwise1, in_bitwise2, ref_and, 15);
596 DEFINE_TEST_VARIANT4(basic_math_q7, zdsp_and_u8, 32, in_bitwise1, in_bitwise2, ref_and, 32);
597 DEFINE_TEST_VARIANT4(basic_math_q7, zdsp_and_u8, 47, in_bitwise1, in_bitwise2, ref_and, 47);
598 
test_zdsp_and_u8_in_place(const DSP_DATA uint8_t * input1,const DSP_DATA uint8_t * input2,const uint8_t * ref,size_t length)599 static void test_zdsp_and_u8_in_place(const DSP_DATA uint8_t *input1,
600 				const DSP_DATA uint8_t *input2, const uint8_t *ref, size_t length)
601 {
602 	DSP_DATA uint8_t *output;
603 
604 	/* Allocate output buffer */
605 	output = (DSP_DATA q7_t *)malloc(length * sizeof(uint8_t));
606 	zassert_not_null(output, ASSERT_MSG_BUFFER_ALLOC_FAILED);
607 
608 	/* Copy input data to output*/
609 	memcpy(output, input1, length * sizeof(q7_t));
610 
611 	/* Run test function */
612 	zdsp_and_u8(output, input2, output, length);
613 
614 	/* Validate output */
615 	zassert_true(test_equal_q7(length, output, ref), ASSERT_MSG_INCORRECT_COMP_RESULT);
616 
617 	/* Free output buffer */
618 	free(output);
619 }
620 
621 DEFINE_TEST_VARIANT4(basic_math_q7, zdsp_and_u8_in_place, 15, in_bitwise1, in_bitwise2, ref_and,
622 		     15);
623 DEFINE_TEST_VARIANT4(basic_math_q7, zdsp_and_u8_in_place, 32, in_bitwise1, in_bitwise2, ref_and,
624 		     32);
625 DEFINE_TEST_VARIANT4(basic_math_q7, zdsp_and_u8_in_place, 47, in_bitwise1, in_bitwise2, ref_and,
626 		     47);
627 
test_zdsp_or_u8(const DSP_DATA uint8_t * input1,const DSP_DATA uint8_t * input2,const uint8_t * ref,size_t length)628 static void test_zdsp_or_u8(const DSP_DATA uint8_t *input1, const DSP_DATA uint8_t *input2,
629 				const uint8_t *ref, size_t length)
630 {
631 	DSP_DATA uint8_t *output;
632 
633 	/* Allocate output buffer */
634 	output = (DSP_DATA q7_t *)malloc(length * sizeof(uint8_t));
635 	zassert_not_null(output, ASSERT_MSG_BUFFER_ALLOC_FAILED);
636 
637 	/* Run test function */
638 	zdsp_or_u8(input1, input2, output, length);
639 
640 	/* Validate output */
641 	zassert_true(
642 		test_equal_q7(length, output, ref),
643 		ASSERT_MSG_INCORRECT_COMP_RESULT);
644 
645 	/* Free output buffer */
646 	free(output);
647 }
648 
649 DEFINE_TEST_VARIANT4(basic_math_q7, zdsp_or_u8, 15, in_bitwise1, in_bitwise2, ref_or, 15);
650 DEFINE_TEST_VARIANT4(basic_math_q7, zdsp_or_u8, 32, in_bitwise1, in_bitwise2, ref_or, 32);
651 DEFINE_TEST_VARIANT4(basic_math_q7, zdsp_or_u8, 47, in_bitwise1, in_bitwise2, ref_or, 47);
652 
test_zdsp_or_u8_in_place(const DSP_DATA uint8_t * input1,const DSP_DATA uint8_t * input2,const uint8_t * ref,size_t length)653 static void test_zdsp_or_u8_in_place(const DSP_DATA uint8_t *input1, const DSP_DATA uint8_t *input2,
654 				const uint8_t *ref, size_t length)
655 {
656 	DSP_DATA uint8_t *output;
657 
658 	/* Allocate output buffer */
659 	output = (DSP_DATA q7_t *)malloc(length * sizeof(uint8_t));
660 	zassert_not_null(output, ASSERT_MSG_BUFFER_ALLOC_FAILED);
661 
662 	/* Copy input data to output*/
663 	memcpy(output, input1, length * sizeof(q7_t));
664 
665 	/* Run test function */
666 	zdsp_or_u8(output, input2, output, length);
667 
668 	/* Validate output */
669 	zassert_true(test_equal_q7(length, output, ref), ASSERT_MSG_INCORRECT_COMP_RESULT);
670 
671 	/* Free output buffer */
672 	free(output);
673 }
674 
675 DEFINE_TEST_VARIANT4(basic_math_q7, zdsp_or_u8_in_place, 15, in_bitwise1, in_bitwise2, ref_or, 15);
676 DEFINE_TEST_VARIANT4(basic_math_q7, zdsp_or_u8_in_place, 32, in_bitwise1, in_bitwise2, ref_or, 32);
677 DEFINE_TEST_VARIANT4(basic_math_q7, zdsp_or_u8_in_place, 47, in_bitwise1, in_bitwise2, ref_or, 47);
678 
test_zdsp_not_u8(const DSP_DATA uint8_t * input1,const uint8_t * ref,size_t length)679 static void test_zdsp_not_u8(const DSP_DATA uint8_t *input1, const uint8_t *ref, size_t length)
680 {
681 	DSP_DATA uint8_t *output;
682 
683 	/* Allocate output buffer */
684 	output = (DSP_DATA q7_t *)malloc(length * sizeof(uint8_t));
685 	zassert_not_null(output, ASSERT_MSG_BUFFER_ALLOC_FAILED);
686 
687 	/* Run test function */
688 	zdsp_not_u8(input1, output, length);
689 
690 	/* Validate output */
691 	zassert_true(
692 		test_equal_q7(length, output, ref),
693 		ASSERT_MSG_INCORRECT_COMP_RESULT);
694 
695 	/* Free output buffer */
696 	free(output);
697 }
698 
699 DEFINE_TEST_VARIANT3(basic_math_q7, zdsp_not_u8, 15, in_bitwise1, ref_not, 15);
700 DEFINE_TEST_VARIANT3(basic_math_q7, zdsp_not_u8, 32, in_bitwise1, ref_not, 32);
701 DEFINE_TEST_VARIANT3(basic_math_q7, zdsp_not_u8, 47, in_bitwise1, ref_not, 47);
702 
test_zdsp_not_u8_in_place(const DSP_DATA uint8_t * input1,const uint8_t * ref,size_t length)703 static void test_zdsp_not_u8_in_place(const DSP_DATA uint8_t *input1, const uint8_t *ref,
704 				size_t length)
705 {
706 	DSP_DATA uint8_t *output;
707 
708 	/* Allocate output buffer */
709 	output = (DSP_DATA q7_t *)malloc(length * sizeof(uint8_t));
710 	zassert_not_null(output, ASSERT_MSG_BUFFER_ALLOC_FAILED);
711 
712 	/* Copy input data to output*/
713 	memcpy(output, input1, length * sizeof(q7_t));
714 
715 	/* Run test function */
716 	zdsp_not_u8(output, output, length);
717 
718 	/* Validate output */
719 	zassert_true(test_equal_q7(length, output, ref), ASSERT_MSG_INCORRECT_COMP_RESULT);
720 
721 	/* Free output buffer */
722 	free(output);
723 }
724 
725 DEFINE_TEST_VARIANT3(basic_math_q7, zdsp_not_u8_in_place, 15, in_bitwise1, ref_not, 15);
726 DEFINE_TEST_VARIANT3(basic_math_q7, zdsp_not_u8_in_place, 32, in_bitwise1, ref_not, 32);
727 DEFINE_TEST_VARIANT3(basic_math_q7, zdsp_not_u8_in_place, 47, in_bitwise1, ref_not, 47);
728 
test_zdsp_xor_u8(const DSP_DATA uint8_t * input1,const DSP_DATA uint8_t * input2,const uint8_t * ref,size_t length)729 static void test_zdsp_xor_u8(const DSP_DATA uint8_t *input1, const DSP_DATA uint8_t *input2,
730 				const uint8_t *ref, size_t length)
731 {
732 	DSP_DATA uint8_t *output;
733 
734 	/* Allocate output buffer */
735 	output = (DSP_DATA q7_t *)malloc(length * sizeof(uint8_t));
736 	zassert_not_null(output, ASSERT_MSG_BUFFER_ALLOC_FAILED);
737 
738 	/* Run test function */
739 	zdsp_xor_u8(input1, input2, output, length);
740 
741 	/* Validate output */
742 	zassert_true(
743 		test_equal_q7(length, output, ref),
744 		ASSERT_MSG_INCORRECT_COMP_RESULT);
745 
746 	/* Free output buffer */
747 	free(output);
748 }
749 
750 DEFINE_TEST_VARIANT4(basic_math_q7, zdsp_xor_u8, 15, in_bitwise1, in_bitwise2, ref_xor, 15);
751 DEFINE_TEST_VARIANT4(basic_math_q7, zdsp_xor_u8, 32, in_bitwise1, in_bitwise2, ref_xor, 32);
752 DEFINE_TEST_VARIANT4(basic_math_q7, zdsp_xor_u8, 47, in_bitwise1, in_bitwise2, ref_xor, 47);
753 
test_zdsp_xor_u8_in_place(const DSP_DATA uint8_t * input1,const DSP_DATA uint8_t * input2,const uint8_t * ref,size_t length)754 static void test_zdsp_xor_u8_in_place(const DSP_DATA uint8_t *input1,
755 				const DSP_DATA uint8_t *input2, const uint8_t *ref, size_t length)
756 {
757 	DSP_DATA uint8_t *output;
758 
759 	/* Allocate output buffer */
760 	output = (DSP_DATA q7_t *)malloc(length * sizeof(uint8_t));
761 	zassert_not_null(output, ASSERT_MSG_BUFFER_ALLOC_FAILED);
762 
763 	/* Copy input data to output*/
764 	memcpy(output, input1, length * sizeof(q7_t));
765 
766 	/* Run test function */
767 	zdsp_xor_u8(output, input2, output, length);
768 
769 	/* Validate output */
770 	zassert_true(test_equal_q7(length, output, ref), ASSERT_MSG_INCORRECT_COMP_RESULT);
771 
772 	/* Free output buffer */
773 	free(output);
774 }
775 
776 DEFINE_TEST_VARIANT4(basic_math_q7, zdsp_xor_u8_in_place, 15, in_bitwise1, in_bitwise2, ref_xor,
777 		     15);
778 DEFINE_TEST_VARIANT4(basic_math_q7, zdsp_xor_u8_in_place, 32, in_bitwise1, in_bitwise2, ref_xor,
779 		     32);
780 DEFINE_TEST_VARIANT4(basic_math_q7, zdsp_xor_u8_in_place, 47, in_bitwise1, in_bitwise2, ref_xor,
781 		     47);
782 
test_zdsp_clip_q7(const DSP_DATA q7_t * input,const q7_t * ref,q7_t min,q7_t max,size_t length)783 static void test_zdsp_clip_q7(const DSP_DATA q7_t *input, const q7_t *ref, q7_t min, q7_t max,
784 			      size_t length)
785 {
786 	DSP_DATA q7_t *output;
787 
788 	/* Allocate output buffer */
789 	output = (DSP_DATA q7_t *)(DSP_DATA q7_t *)malloc(length * sizeof(q7_t));
790 	zassert_not_null(output, ASSERT_MSG_BUFFER_ALLOC_FAILED);
791 
792 	/* Run test function */
793 	zdsp_clip_q7(input, output, min, max, length);
794 
795 	/* Validate output */
796 	zassert_true(
797 		test_equal_q7(length, output, ref),
798 		ASSERT_MSG_INCORRECT_COMP_RESULT);
799 
800 	/* Free output buffer */
801 	free(output);
802 }
803 
804 DEFINE_TEST_VARIANT5(basic_math_q7, zdsp_clip_q7, c0_f3, in_clip, ref_clip1, 0xc0, 0xf3,
805 		     ARRAY_SIZE(ref_clip1));
806 DEFINE_TEST_VARIANT5(basic_math_q7, zdsp_clip_q7, c0_40, in_clip, ref_clip2, 0xc0, 0x40,
807 		     ARRAY_SIZE(ref_clip2));
808 DEFINE_TEST_VARIANT5(basic_math_q7, zdsp_clip_q7, 0d_40, in_clip, ref_clip3, 0x0d, 0x40,
809 		     ARRAY_SIZE(ref_clip3));
810 
test_zdsp_clip_q7_in_place(const DSP_DATA q7_t * input,const q7_t * ref,q7_t min,q7_t max,size_t length)811 static void test_zdsp_clip_q7_in_place(const DSP_DATA q7_t *input, const q7_t *ref, q7_t min,
812 				q7_t max, size_t length)
813 {
814 	DSP_DATA q7_t *output;
815 
816 	/* Allocate output buffer */
817 	output = (DSP_DATA q7_t *)(DSP_DATA q7_t *)malloc(length * sizeof(q7_t));
818 	zassert_not_null(output, ASSERT_MSG_BUFFER_ALLOC_FAILED);
819 
820 	/* Copy input data to output*/
821 	memcpy(output, input, length * sizeof(q7_t));
822 
823 	/* Run test function */
824 	zdsp_clip_q7(output, output, min, max, length);
825 
826 	/* Validate output */
827 	zassert_true(test_equal_q7(length, output, ref), ASSERT_MSG_INCORRECT_COMP_RESULT);
828 
829 	/* Free output buffer */
830 	free(output);
831 }
832 
833 DEFINE_TEST_VARIANT5(basic_math_q7, zdsp_clip_q7_in_place, c0_f3, in_clip, ref_clip1, 0xc0, 0xf3,
834 		     ARRAY_SIZE(ref_clip1));
835 DEFINE_TEST_VARIANT5(basic_math_q7, zdsp_clip_q7_in_place, c0_40, in_clip, ref_clip2, 0xc0, 0x40,
836 		     ARRAY_SIZE(ref_clip2));
837 DEFINE_TEST_VARIANT5(basic_math_q7, zdsp_clip_q7_in_place, 0d_40, in_clip, ref_clip3, 0x0d, 0x40,
838 		     ARRAY_SIZE(ref_clip3));
839 
840 ZTEST_SUITE(basic_math_q7, NULL, NULL, NULL, NULL, NULL);
841