Skip to content

Commit 608b501

Browse files
committed
qemu: maths: make the maths APIs available for native sim
Make the maths tests available on native sim target. Signed-off-by: Liam Girdwood <liam.r.girdwood@linux.intel.com>
1 parent dd8486f commit 608b501

3 files changed

Lines changed: 27 additions & 4 deletions

File tree

src/math/CMakeLists.txt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,12 @@ if(zephyr) ### Zephyr ###
106106
${base_files}
107107
)
108108

109+
if(CONFIG_ZTEST)
110+
set_source_files_properties(${CMAKE_CURRENT_SOURCE_DIR}/numbers.c
111+
PROPERTIES COMPILE_DEFINITIONS "CONFIG_NUMBERS_VECTOR_FIND=1;CONFIG_NUMBERS_NORM=1"
112+
)
113+
endif()
114+
109115
else() ### library, e.g. testbench or plugin ###
110116

111117
add_local_sources(sof ${base_files})

src/math/numbers.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ int gcd(int a, int b)
7979
EXPORT_SYMBOL(gcd);
8080
#endif /* USE_SOF_GCD */
8181

82-
#if CONFIG_NUMBERS_VECTOR_FIND
82+
#if CONFIG_NUMBERS_VECTOR_FIND || CONFIG_ZTEST
8383

8484
/* This function searches from vec[] (of length vec_length) integer values
8585
* of n. The indexes to equal values is returned in idx[]. The function
@@ -133,9 +133,9 @@ int32_t find_max_abs_int32(int32_t vec[], int vec_length)
133133
return SATP_INT32(amax); /* Amax is always a positive value */
134134
}
135135

136-
#endif /* CONFIG_VECTOR_FIND */
136+
#endif /* CONFIG_VECTOR_FIND || CONFIG_ZTEST */
137137

138-
#if CONFIG_NUMBERS_NORM
138+
#if CONFIG_NUMBERS_NORM || CONFIG_ZTEST
139139

140140
/* Count the left shift amount to normalize a 32 bit signed integer value
141141
* without causing overflow. Input value 0 will result to 31.
@@ -155,7 +155,7 @@ int norm_int32(int32_t val)
155155
}
156156
EXPORT_SYMBOL(norm_int32);
157157

158-
#endif /* CONFIG_NORM */
158+
#endif /* CONFIG_NORM || CONFIG_ZTEST */
159159

160160
/**
161161
* Basic CRC-32 implementation, based on pseudo-code from

zephyr/test/CMakeLists.txt

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,3 +23,20 @@ endif()
2323
if(CONFIG_SOF_BOOT_TEST_STANDALONE AND CONFIG_SOF_USERSPACE_LL)
2424
zephyr_library_sources(userspace/test_ll_task.c)
2525
endif()
26+
27+
if(CONFIG_SOF_BOOT_TEST_STANDALONE AND CONFIG_ZTEST)
28+
set(MATH_ZTEST_SOURCES
29+
../../test/ztest/unit/math/basic/arithmetic/test_crc32_ztest.c
30+
../../test/ztest/unit/math/basic/arithmetic/test_find_equal_int16_ztest.c
31+
../../test/ztest/unit/math/basic/arithmetic/test_find_max_abs_int32_ztest.c
32+
../../test/ztest/unit/math/basic/arithmetic/test_find_min_int16_ztest.c
33+
../../test/ztest/unit/math/basic/arithmetic/test_gcd_ztest.c
34+
../../test/ztest/unit/math/basic/arithmetic/test_norm_int32_ztest.c
35+
)
36+
37+
zephyr_library_sources(${MATH_ZTEST_SOURCES})
38+
39+
set_source_files_properties(${MATH_ZTEST_SOURCES}
40+
PROPERTIES COMPILE_DEFINITIONS "CONFIG_NUMBERS_VECTOR_FIND=1;CONFIG_NUMBERS_NORM=1;UNIT_TEST=1"
41+
)
42+
endif()

0 commit comments

Comments
 (0)