Skip to content

Commit ccb3927

Browse files
enjiamainashif
authored andcommitted
tests: lib: move the cmsis_dsp matrix test to new ztest API
Migrate the testsuite tests/lib/cmsis_dsp/matrix to the new ztest API. Signed-off-by: Enjia Mai <[email protected]>
1 parent 26b816c commit ccb3927

File tree

16 files changed

+97
-248
lines changed

16 files changed

+97
-248
lines changed

tests/lib/cmsis_dsp/matrix/prj.conf

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
CONFIG_ZTEST=y
2+
CONFIG_ZTEST_NEW_API=y
23
CONFIG_NEWLIB_LIBC=y
34
CONFIG_CMSIS_DSP=y
45
CONFIG_CMSIS_DSP_MATRIX=y
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
CONFIG_ZTEST=y
2+
CONFIG_ZTEST_NEW_API=y
23
CONFIG_NEWLIB_LIBC=y
34
CONFIG_CMSIS_DSP=y
45
CONFIG_CMSIS_DSP_MATRIX=y

tests/lib/cmsis_dsp/matrix/src/binary_f16.c

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ static void test_op2(int op, const uint16_t *input1, const uint16_t *input2,
109109
free(output);
110110
}
111111

112-
DEFINE_TEST_VARIANT5(
112+
DEFINE_TEST_VARIANT5(matrix_binary_f16,
113113
op2, arm_mat_mult_f16, OP2_MULT,
114114
in_mult1, in_mult2, ref_mult,
115115
ARRAY_SIZE(ref_mult));
@@ -200,17 +200,9 @@ static void test_op2c(int op, const uint16_t *input1, const uint16_t *input2,
200200
free(output);
201201
}
202202

203-
DEFINE_TEST_VARIANT5(
203+
DEFINE_TEST_VARIANT5(matrix_binary_f16,
204204
op2c, arm_mat_cmplx_mult_f16, OP2C_CMPLX_MULT,
205205
in_cmplx_mult1, in_cmplx_mult2, ref_cmplx_mult,
206206
ARRAY_SIZE(ref_cmplx_mult) / 2);
207207

208-
void test_matrix_binary_f16(void)
209-
{
210-
ztest_test_suite(matrix_binary_f16,
211-
ztest_unit_test(test_op2_arm_mat_mult_f16),
212-
ztest_unit_test(test_op2c_arm_mat_cmplx_mult_f16)
213-
);
214-
215-
ztest_run_test_suite(matrix_binary_f16);
216-
}
208+
ZTEST_SUITE(matrix_binary_f16, NULL, NULL, NULL, NULL, NULL);

tests/lib/cmsis_dsp/matrix/src/binary_f32.c

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ static void test_op2(int op, const uint32_t *input1, const uint32_t *input2,
109109
free(output);
110110
}
111111

112-
DEFINE_TEST_VARIANT5(
112+
DEFINE_TEST_VARIANT5(matrix_binary_f32,
113113
op2, arm_mat_mult_f32, OP2_MULT,
114114
in_mult1, in_mult2, ref_mult,
115115
ARRAY_SIZE(ref_mult));
@@ -200,17 +200,9 @@ static void test_op2c(int op, const uint32_t *input1, const uint32_t *input2,
200200
free(output);
201201
}
202202

203-
DEFINE_TEST_VARIANT5(
203+
DEFINE_TEST_VARIANT5(matrix_binary_f32,
204204
op2c, arm_mat_cmplx_mult_f32, OP2C_CMPLX_MULT,
205205
in_cmplx_mult1, in_cmplx_mult2, ref_cmplx_mult,
206206
ARRAY_SIZE(ref_cmplx_mult) / 2);
207207

208-
void test_matrix_binary_f32(void)
209-
{
210-
ztest_test_suite(matrix_binary_f32,
211-
ztest_unit_test(test_op2_arm_mat_mult_f32),
212-
ztest_unit_test(test_op2c_arm_mat_cmplx_mult_f32)
213-
);
214-
215-
ztest_run_test_suite(matrix_binary_f32);
216-
}
208+
ZTEST_SUITE(matrix_binary_f32, NULL, NULL, NULL, NULL, NULL);

tests/lib/cmsis_dsp/matrix/src/binary_f64.c

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ static void test_op2(int op, const uint64_t *input1, const uint64_t *input2,
109109
free(output);
110110
}
111111

112-
DEFINE_TEST_VARIANT5(
112+
DEFINE_TEST_VARIANT5(matrix_binary_f64,
113113
op2, arm_mat_mult_f64, OP2_MULT,
114114
in_mult1, in_mult2, ref_mult,
115115
ARRAY_SIZE(ref_mult));
@@ -205,18 +205,10 @@ static void test_op2c(int op, const uint64_t *input1, const uint64_t *input2,
205205
free(output);
206206
}
207207

208-
DEFINE_TEST_VARIANT5(
208+
DEFINE_TEST_VARIANT5(matrix_binary_f64,
209209
op2c, arm_mat_cmplx_mult_f64, OP2C_CMPLX_MULT,
210210
in_cmplx_mult1, in_cmplx_mult2, ref_cmplx_mult,
211211
ARRAY_SIZE(ref_cmplx_mult) / 2);
212212
#endif
213213

214-
void test_matrix_binary_f64(void)
215-
{
216-
ztest_test_suite(matrix_binary_f64,
217-
ztest_unit_test(test_op2_arm_mat_mult_f64)
218-
/* ztest_unit_test(test_op2c_arm_mat_cmplx_mult_f64) */
219-
);
220-
221-
ztest_run_test_suite(matrix_binary_f64);
222-
}
214+
ZTEST_SUITE(matrix_binary_f64, NULL, NULL, NULL, NULL, NULL);

tests/lib/cmsis_dsp/matrix/src/binary_q15.c

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ static void test_op2(int op, const q15_t *input1, const q15_t *input2,
115115
free(output);
116116
}
117117

118-
DEFINE_TEST_VARIANT5(
118+
DEFINE_TEST_VARIANT5(matrix_binary_q15,
119119
op2, arm_mat_mult_q15, OP2_MULT,
120120
in_mult1, in_mult2, ref_mult,
121121
ARRAY_SIZE(ref_mult));
@@ -210,17 +210,9 @@ static void test_op2c(int op, const q15_t *input1, const q15_t *input2,
210210
free(output);
211211
}
212212

213-
DEFINE_TEST_VARIANT5(
213+
DEFINE_TEST_VARIANT5(matrix_binary_q15,
214214
op2c, arm_mat_cmplx_mult_q15, OP2C_CMPLX_MULT,
215215
in_cmplx_mult1, in_cmplx_mult2, ref_cmplx_mult,
216216
ARRAY_SIZE(ref_cmplx_mult) / 2);
217217

218-
void test_matrix_binary_q15(void)
219-
{
220-
ztest_test_suite(matrix_binary_q15,
221-
ztest_unit_test(test_op2c_arm_mat_cmplx_mult_q15),
222-
ztest_unit_test(test_op2_arm_mat_mult_q15)
223-
);
224-
225-
ztest_run_test_suite(matrix_binary_q15);
226-
}
218+
ZTEST_SUITE(matrix_binary_q15, NULL, NULL, NULL, NULL, NULL);

tests/lib/cmsis_dsp/matrix/src/binary_q31.c

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ static void test_op2(int op, const q31_t *input1, const q31_t *input2,
107107
free(output);
108108
}
109109

110-
DEFINE_TEST_VARIANT5(
110+
DEFINE_TEST_VARIANT5(matrix_binary_q31,
111111
op2, arm_mat_mult_q31, OP2_MULT,
112112
in_mult1, in_mult2, ref_mult,
113113
ARRAY_SIZE(ref_mult));
@@ -197,17 +197,9 @@ static void test_op2c(int op, const q31_t *input1, const q31_t *input2,
197197
free(output);
198198
}
199199

200-
DEFINE_TEST_VARIANT5(
200+
DEFINE_TEST_VARIANT5(matrix_binary_q31,
201201
op2c, arm_mat_cmplx_mult_q31, OP2C_CMPLX_MULT,
202202
in_cmplx_mult1, in_cmplx_mult2, ref_cmplx_mult,
203203
ARRAY_SIZE(ref_cmplx_mult) / 2);
204204

205-
void test_matrix_binary_q31(void)
206-
{
207-
ztest_test_suite(matrix_binary_q31,
208-
ztest_unit_test(test_op2_arm_mat_mult_q31),
209-
ztest_unit_test(test_op2c_arm_mat_cmplx_mult_q31)
210-
);
211-
212-
ztest_run_test_suite(matrix_binary_q31);
213-
}
205+
ZTEST_SUITE(matrix_binary_q31, NULL, NULL, NULL, NULL, NULL);

tests/lib/cmsis_dsp/matrix/src/binary_q7.c

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -111,16 +111,9 @@ static void test_op2(int op, const q7_t *input1, const q7_t *input2,
111111
free(output);
112112
}
113113

114-
DEFINE_TEST_VARIANT5(
114+
DEFINE_TEST_VARIANT5(matrix_binary_q7,
115115
op2, arm_mat_mult_q7, OP2_MULT,
116116
in_mult1, in_mult2, ref_mult,
117117
ARRAY_SIZE(ref_mult));
118118

119-
void test_matrix_binary_q7(void)
120-
{
121-
ztest_test_suite(matrix_binary_q7,
122-
ztest_unit_test(test_op2_arm_mat_mult_q7)
123-
);
124-
125-
ztest_run_test_suite(matrix_binary_q7);
126-
}
119+
ZTEST_SUITE(matrix_binary_q7, NULL, NULL, NULL, NULL, NULL);

tests/lib/cmsis_dsp/matrix/src/main.c

Lines changed: 0 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -3,61 +3,3 @@
33
*
44
* SPDX-License-Identifier: Apache-2.0
55
*/
6-
7-
#include <zephyr/ztest.h>
8-
#include <zephyr/kernel.h>
9-
10-
extern void test_matrix_unary_q7(void);
11-
extern void test_matrix_unary_q15(void);
12-
extern void test_matrix_unary_q31(void);
13-
extern void test_matrix_unary_f16(void);
14-
extern void test_matrix_unary_f32(void);
15-
extern void test_matrix_unary_f64(void);
16-
17-
extern void test_matrix_binary_q7(void);
18-
extern void test_matrix_binary_q15(void);
19-
extern void test_matrix_binary_q31(void);
20-
extern void test_matrix_binary_f16(void);
21-
extern void test_matrix_binary_f32(void);
22-
extern void test_matrix_binary_f64(void);
23-
24-
void test_main(void)
25-
{
26-
#ifdef CONFIG_CMSIS_DSP_TEST_MATRIX_UNARY_Q7
27-
test_matrix_unary_q7();
28-
#endif
29-
#ifdef CONFIG_CMSIS_DSP_TEST_MATRIX_UNARY_Q15
30-
test_matrix_unary_q15();
31-
#endif
32-
#ifdef CONFIG_CMSIS_DSP_TEST_MATRIX_UNARY_Q31
33-
test_matrix_unary_q31();
34-
#endif
35-
#ifdef CONFIG_CMSIS_DSP_TEST_MATRIX_UNARY_F16
36-
test_matrix_unary_f16();
37-
#endif
38-
#ifdef CONFIG_CMSIS_DSP_TEST_MATRIX_UNARY_F32
39-
test_matrix_unary_f32();
40-
#endif
41-
#ifdef CONFIG_CMSIS_DSP_TEST_MATRIX_UNARY_F64
42-
test_matrix_unary_f64();
43-
#endif
44-
45-
#ifdef CONFIG_CMSIS_DSP_TEST_MATRIX_BINARY_Q7
46-
test_matrix_binary_q7();
47-
#endif
48-
#ifdef CONFIG_CMSIS_DSP_TEST_MATRIX_BINARY_Q15
49-
test_matrix_binary_q15();
50-
#endif
51-
#ifdef CONFIG_CMSIS_DSP_TEST_MATRIX_BINARY_Q31
52-
test_matrix_binary_q31();
53-
#endif
54-
#ifdef CONFIG_CMSIS_DSP_TEST_MATRIX_BINARY_F16
55-
test_matrix_binary_f16();
56-
#endif
57-
#ifdef CONFIG_CMSIS_DSP_TEST_MATRIX_BINARY_F32
58-
test_matrix_binary_f32();
59-
#endif
60-
#ifdef CONFIG_CMSIS_DSP_TEST_MATRIX_BINARY_F64
61-
test_matrix_binary_f64();
62-
#endif
63-
}

tests/lib/cmsis_dsp/matrix/src/unary_f16.c

Lines changed: 17 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -121,9 +121,11 @@ static void test_op2(int op, const uint16_t *ref, size_t length)
121121
free(output);
122122
}
123123

124-
DEFINE_TEST_VARIANT3(op2, arm_mat_add_f16, OP2_ADD,
124+
DEFINE_TEST_VARIANT3(matrix_unary_f16,
125+
op2, arm_mat_add_f16, OP2_ADD,
125126
ref_add, ARRAY_SIZE(ref_add));
126-
DEFINE_TEST_VARIANT3(op2, arm_mat_sub_f16, OP2_SUB,
127+
DEFINE_TEST_VARIANT3(matrix_unary_f16,
128+
op2, arm_mat_sub_f16, OP2_SUB,
127129
ref_sub, ARRAY_SIZE(ref_sub));
128130

129131
static void test_op1(int op, const uint16_t *ref, size_t length,
@@ -200,12 +202,14 @@ static void test_op1(int op, const uint16_t *ref, size_t length,
200202
free(output);
201203
}
202204

203-
DEFINE_TEST_VARIANT4(op1, arm_mat_scale_f16, OP1_SCALE,
205+
DEFINE_TEST_VARIANT4(matrix_unary_f16,
206+
op1, arm_mat_scale_f16, OP1_SCALE,
204207
ref_scale, ARRAY_SIZE(ref_scale), false);
205-
DEFINE_TEST_VARIANT4(op1, arm_mat_trans_f16, OP1_TRANS,
208+
DEFINE_TEST_VARIANT4(matrix_unary_f16,
209+
op1, arm_mat_trans_f16, OP1_TRANS,
206210
ref_trans, ARRAY_SIZE(ref_trans), true);
207211

208-
static void test_arm_mat_inverse_f16(void)
212+
ZTEST(matrix_unary_f16, test_arm_mat_inverse_f16)
209213
{
210214
size_t index;
211215
size_t length = ARRAY_SIZE(ref_inv);
@@ -335,7 +339,8 @@ static void test_op2v(int op, const uint16_t *ref, size_t length)
335339
free(output_buf);
336340
}
337341

338-
DEFINE_TEST_VARIANT3(op2v, arm_mat_vec_mult_f16, OP2V_VEC_MULT,
342+
DEFINE_TEST_VARIANT3(matrix_unary_f16,
343+
op2v, arm_mat_vec_mult_f16, OP2V_VEC_MULT,
339344
ref_vec_mult, ARRAY_SIZE(ref_vec_mult));
340345

341346
static void test_op1c(int op, const uint16_t *ref, size_t length, bool transpose)
@@ -408,10 +413,11 @@ static void test_op1c(int op, const uint16_t *ref, size_t length, bool transpose
408413
free(output);
409414
}
410415

411-
DEFINE_TEST_VARIANT4(op1c, arm_mat_cmplx_trans_f16, OP1C_CMPLX_TRANS,
416+
DEFINE_TEST_VARIANT4(matrix_unary_f16,
417+
op1c, arm_mat_cmplx_trans_f16, OP1C_CMPLX_TRANS,
412418
ref_cmplx_trans, ARRAY_SIZE(ref_cmplx_trans) / 2, true);
413419

414-
static void test_arm_mat_cholesky_f16(void)
420+
ZTEST(matrix_unary_f16, test_arm_mat_cholesky_f16)
415421
{
416422
size_t index;
417423
size_t length = ARRAY_SIZE(ref_cholesky_dpo);
@@ -474,7 +480,7 @@ static void test_arm_mat_cholesky_f16(void)
474480
free(output);
475481
}
476482

477-
static void test_arm_mat_solve_upper_triangular_f16(void)
483+
ZTEST(matrix_unary_f16, test_arm_mat_solve_upper_triangular_f16)
478484
{
479485
size_t index;
480486
size_t length = ARRAY_SIZE(ref_uptriangular_dpo);
@@ -551,7 +557,7 @@ static void test_arm_mat_solve_upper_triangular_f16(void)
551557
free(output);
552558
}
553559

554-
static void test_arm_mat_solve_lower_triangular_f16(void)
560+
ZTEST(matrix_unary_f16, test_arm_mat_solve_lower_triangular_f16)
555561
{
556562
size_t index;
557563
size_t length = ARRAY_SIZE(ref_lotriangular_dpo);
@@ -628,20 +634,4 @@ static void test_arm_mat_solve_lower_triangular_f16(void)
628634
free(output);
629635
}
630636

631-
void test_matrix_unary_f16(void)
632-
{
633-
ztest_test_suite(matrix_unary_f16,
634-
ztest_unit_test(test_op2_arm_mat_add_f16),
635-
ztest_unit_test(test_op2_arm_mat_sub_f16),
636-
ztest_unit_test(test_op1_arm_mat_scale_f16),
637-
ztest_unit_test(test_op1_arm_mat_trans_f16),
638-
ztest_unit_test(test_arm_mat_inverse_f16),
639-
ztest_unit_test(test_op2v_arm_mat_vec_mult_f16),
640-
ztest_unit_test(test_op1c_arm_mat_cmplx_trans_f16),
641-
ztest_unit_test(test_arm_mat_cholesky_f16),
642-
ztest_unit_test(test_arm_mat_solve_upper_triangular_f16),
643-
ztest_unit_test(test_arm_mat_solve_lower_triangular_f16)
644-
);
645-
646-
ztest_run_test_suite(matrix_unary_f16);
647-
}
637+
ZTEST_SUITE(matrix_unary_f16, NULL, NULL, NULL, NULL, NULL);

0 commit comments

Comments
 (0)