Skip to content

Commit 3e2fe17

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

File tree

10 files changed

+115
-295
lines changed

10 files changed

+115
-295
lines changed

tests/lib/cmsis_dsp/support/CMakeLists.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ target_sources(app PRIVATE
1010
src/q31.c
1111
src/f32.c
1212
src/barycenter_f32.c
13-
src/main.c
1413
)
1514

1615
target_sources_ifdef(CONFIG_CMSIS_DSP_FLOAT16 app PRIVATE
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_SUPPORT=y

tests/lib/cmsis_dsp/support/src/barycenter_f16.c

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515

1616
#define ABS_ERROR_THRESH (1e-3)
1717

18-
void test_arm_barycenter_f16(void)
18+
ZTEST(support_barycenter_f16, test_arm_barycenter_f16)
1919
{
2020
int test_index;
2121
const size_t length = ARRAY_SIZE(ref_barycenter);
@@ -58,11 +58,4 @@ void test_arm_barycenter_f16(void)
5858
free(output_buf);
5959
}
6060

61-
void test_support_barycenter_f16(void)
62-
{
63-
ztest_test_suite(support_barycenter_f16,
64-
ztest_unit_test(test_arm_barycenter_f16)
65-
);
66-
67-
ztest_run_test_suite(support_barycenter_f16);
68-
}
61+
ZTEST_SUITE(support_barycenter_f16, NULL, NULL, NULL, NULL, NULL);

tests/lib/cmsis_dsp/support/src/barycenter_f32.c

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515

1616
#define ABS_ERROR_THRESH (1e-3)
1717

18-
void test_arm_barycenter_f32(void)
18+
ZTEST(support_barycenter_f32, test_arm_barycenter_f32)
1919
{
2020
int test_index;
2121
const size_t length = ARRAY_SIZE(ref_barycenter);
@@ -58,11 +58,4 @@ void test_arm_barycenter_f32(void)
5858
free(output_buf);
5959
}
6060

61-
void test_support_barycenter_f32(void)
62-
{
63-
ztest_test_suite(support_barycenter_f32,
64-
ztest_unit_test(test_arm_barycenter_f32)
65-
);
66-
67-
ztest_run_test_suite(support_barycenter_f32);
68-
}
61+
ZTEST_SUITE(support_barycenter_f32, NULL, NULL, NULL, NULL, NULL);

tests/lib/cmsis_dsp/support/src/f16.c

Lines changed: 22 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -48,9 +48,9 @@ static void test_arm_copy_f16(const uint16_t *input1, size_t length)
4848
free(output);
4949
}
5050

51-
DEFINE_TEST_VARIANT2(arm_copy_f16, 7, ref_f16, 7);
52-
DEFINE_TEST_VARIANT2(arm_copy_f16, 16, ref_f16, 16);
53-
DEFINE_TEST_VARIANT2(arm_copy_f16, 23, ref_f16, 23);
51+
DEFINE_TEST_VARIANT2(support_f16, arm_copy_f16, 7, ref_f16, 7);
52+
DEFINE_TEST_VARIANT2(support_f16, arm_copy_f16, 16, ref_f16, 16);
53+
DEFINE_TEST_VARIANT2(support_f16, arm_copy_f16, 23, ref_f16, 23);
5454

5555
static void test_arm_fill_f16(size_t length)
5656
{
@@ -75,9 +75,9 @@ static void test_arm_fill_f16(size_t length)
7575
free(output);
7676
}
7777

78-
DEFINE_TEST_VARIANT1(arm_fill_f16, 7, 7);
79-
DEFINE_TEST_VARIANT1(arm_fill_f16, 16, 16);
80-
DEFINE_TEST_VARIANT1(arm_fill_f16, 23, 23);
78+
DEFINE_TEST_VARIANT1(support_f16, arm_fill_f16, 7, 7);
79+
DEFINE_TEST_VARIANT1(support_f16, arm_fill_f16, 16, 16);
80+
DEFINE_TEST_VARIANT1(support_f16, arm_fill_f16, 23, 23);
8181

8282
static void test_arm_f16_to_q15(
8383
const uint16_t *input1, const q15_t *ref, size_t length)
@@ -100,9 +100,9 @@ static void test_arm_f16_to_q15(
100100
free(output);
101101
}
102102

103-
DEFINE_TEST_VARIANT3(arm_f16_to_q15, 7, ref_f16, ref_q15, 7);
104-
DEFINE_TEST_VARIANT3(arm_f16_to_q15, 16, ref_f16, ref_q15, 16);
105-
DEFINE_TEST_VARIANT3(arm_f16_to_q15, 23, ref_f16, ref_q15, 23);
103+
DEFINE_TEST_VARIANT3(support_f16, arm_f16_to_q15, 7, ref_f16, ref_q15, 7);
104+
DEFINE_TEST_VARIANT3(support_f16, arm_f16_to_q15, 16, ref_f16, ref_q15, 16);
105+
DEFINE_TEST_VARIANT3(support_f16, arm_f16_to_q15, 23, ref_f16, ref_q15, 23);
106106

107107
static void test_arm_f16_to_float(
108108
const uint16_t *input1, const uint32_t *ref, size_t length)
@@ -126,9 +126,9 @@ static void test_arm_f16_to_float(
126126
free(output);
127127
}
128128

129-
DEFINE_TEST_VARIANT3(arm_f16_to_float, 7, ref_f16, ref_f32, 7);
130-
DEFINE_TEST_VARIANT3(arm_f16_to_float, 16, ref_f16, ref_f32, 16);
131-
DEFINE_TEST_VARIANT3(arm_f16_to_float, 23, ref_f16, ref_f32, 23);
129+
DEFINE_TEST_VARIANT3(support_f16, arm_f16_to_float, 7, ref_f16, ref_f32, 7);
130+
DEFINE_TEST_VARIANT3(support_f16, arm_f16_to_float, 16, ref_f16, ref_f32, 16);
131+
DEFINE_TEST_VARIANT3(support_f16, arm_f16_to_float, 23, ref_f16, ref_f32, 23);
132132

133133
static void test_arm_q15_to_f16(
134134
const q15_t *input1, const uint16_t *ref, size_t length)
@@ -152,9 +152,9 @@ static void test_arm_q15_to_f16(
152152
free(output);
153153
}
154154

155-
DEFINE_TEST_VARIANT3(arm_q15_to_f16, 7, ref_q15, ref_f16, 7);
156-
DEFINE_TEST_VARIANT3(arm_q15_to_f16, 16, ref_q15, ref_f16, 16);
157-
DEFINE_TEST_VARIANT3(arm_q15_to_f16, 23, ref_q15, ref_f16, 23);
155+
DEFINE_TEST_VARIANT3(support_f16, arm_q15_to_f16, 7, ref_q15, ref_f16, 7);
156+
DEFINE_TEST_VARIANT3(support_f16, arm_q15_to_f16, 16, ref_q15, ref_f16, 16);
157+
DEFINE_TEST_VARIANT3(support_f16, arm_q15_to_f16, 23, ref_q15, ref_f16, 23);
158158

159159
static void test_arm_float_to_f16(
160160
const uint32_t *input1, const uint16_t *ref, size_t length)
@@ -178,9 +178,9 @@ static void test_arm_float_to_f16(
178178
free(output);
179179
}
180180

181-
DEFINE_TEST_VARIANT3(arm_float_to_f16, 7, ref_f32, ref_f16, 7);
182-
DEFINE_TEST_VARIANT3(arm_float_to_f16, 16, ref_f32, ref_f16, 16);
183-
DEFINE_TEST_VARIANT3(arm_float_to_f16, 23, ref_f32, ref_f16, 23);
181+
DEFINE_TEST_VARIANT3(support_f16, arm_float_to_f16, 7, ref_f32, ref_f16, 7);
182+
DEFINE_TEST_VARIANT3(support_f16, arm_float_to_f16, 16, ref_f32, ref_f16, 16);
183+
DEFINE_TEST_VARIANT3(support_f16, arm_float_to_f16, 23, ref_f32, ref_f16, 23);
184184

185185
static void test_arm_weighted_sum_f16(
186186
int ref_offset, size_t length)
@@ -207,35 +207,8 @@ static void test_arm_weighted_sum_f16(
207207
free(output);
208208
}
209209

210-
DEFINE_TEST_VARIANT2(arm_weighted_sum_f16, 7, 0, 7);
211-
DEFINE_TEST_VARIANT2(arm_weighted_sum_f16, 16, 1, 16);
212-
DEFINE_TEST_VARIANT2(arm_weighted_sum_f16, 23, 2, 23);
210+
DEFINE_TEST_VARIANT2(support_f16, arm_weighted_sum_f16, 7, 0, 7);
211+
DEFINE_TEST_VARIANT2(support_f16, arm_weighted_sum_f16, 16, 1, 16);
212+
DEFINE_TEST_VARIANT2(support_f16, arm_weighted_sum_f16, 23, 2, 23);
213213

214-
void test_support_f16(void)
215-
{
216-
ztest_test_suite(support_f16,
217-
ztest_unit_test(test_arm_copy_f16_7),
218-
ztest_unit_test(test_arm_copy_f16_16),
219-
ztest_unit_test(test_arm_copy_f16_23),
220-
ztest_unit_test(test_arm_fill_f16_7),
221-
ztest_unit_test(test_arm_fill_f16_16),
222-
ztest_unit_test(test_arm_fill_f16_23),
223-
ztest_unit_test(test_arm_f16_to_q15_7),
224-
ztest_unit_test(test_arm_f16_to_q15_16),
225-
ztest_unit_test(test_arm_f16_to_q15_23),
226-
ztest_unit_test(test_arm_f16_to_float_7),
227-
ztest_unit_test(test_arm_f16_to_float_16),
228-
ztest_unit_test(test_arm_f16_to_float_23),
229-
ztest_unit_test(test_arm_q15_to_f16_7),
230-
ztest_unit_test(test_arm_q15_to_f16_16),
231-
ztest_unit_test(test_arm_q15_to_f16_23),
232-
ztest_unit_test(test_arm_float_to_f16_7),
233-
ztest_unit_test(test_arm_float_to_f16_16),
234-
ztest_unit_test(test_arm_float_to_f16_23),
235-
ztest_unit_test(test_arm_weighted_sum_f16_7),
236-
ztest_unit_test(test_arm_weighted_sum_f16_16),
237-
ztest_unit_test(test_arm_weighted_sum_f16_23)
238-
);
239-
240-
ztest_run_test_suite(support_f16);
241-
}
214+
ZTEST_SUITE(support_f16, NULL, NULL, NULL, NULL, NULL);

0 commit comments

Comments
 (0)