File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff 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+
109115else () ### library, e.g. testbench or plugin ###
110116
111117 add_local_sources (sof ${base_files} )
Original file line number Diff line number Diff line change @@ -79,7 +79,7 @@ int gcd(int a, int b)
7979EXPORT_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}
156156EXPORT_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
Original file line number Diff line number Diff line change @@ -23,3 +23,20 @@ endif()
2323if (CONFIG_SOF_BOOT_TEST_STANDALONE AND CONFIG_SOF_USERSPACE_LL)
2424 zephyr_library_sources (userspace/test_ll_task.c )
2525endif ()
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 ()
You can’t perform that action at this time.
0 commit comments