Skip to content

Commit 5bd5a4b

Browse files
tmlemankv2019i
authored andcommitted
test: ztest: Add math basic trigonometry unit tests converted from CMock
This patch converts 9 existing math trigonometry unit tests from CMock/Unity to Zephyr's Ztest framework, maintaining the same test coverage and functionality: - test_sin_32b_fixed: 32-bit fixed-point sine function - test_sin_16b_fixed: 16-bit fixed-point sine function - test_cos_32b_fixed: 32-bit fixed-point cosine function - test_cos_16b_fixed: 16-bit fixed-point cosine function - test_asin_32b_fixed: 32-bit fixed-point arcsine function - test_asin_16b_fixed: 16-bit fixed-point arcsine function - test_acos_32b_fixed: 32-bit fixed-point arccosine function - test_acos_16b_fixed: 16-bit fixed-point arccosine function - test_sin_lut_16b_fixed: 16-bit sine lookup table function Original tests converted from sof/test/cmocka/src/math/trig/ authored by: - Slawomir Blauciak <slawomir.blauciak@linux.intel.com> - Shriram Shastry <malladi.sastry@linux.intel.com> - Seppo Ingalsuo <seppo.ingalsuo@linux.intel.com> The converted tests validate the same trigonometric functions from src/math/trig.c and src/math/lut_trig.c as the original CMock tests, ensuring no regression in test coverage during the migration to Ztest framework. Reference tables and tolerance values are preserved to maintain identical test accuracy and validation criteria. This is part of the broader SOF unit test migration from CMock to Zephyr Ztest framework, establishing the foundation for math/basic/trigonometry tests in the new directory structure. Signed-off-by: Tomasz Leman <tomasz.m.leman@intel.com>
1 parent 1117d0b commit 5bd5a4b

File tree

5 files changed

+649
-0
lines changed

5 files changed

+649
-0
lines changed
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
cmake_minimum_required(VERSION 3.20.0)
2+
3+
find_package(Zephyr REQUIRED HINTS $ENV{ZEPHYR_BASE})
4+
project(test_math_trigonometry)
5+
6+
set(SOF_ROOT "${PROJECT_SOURCE_DIR}/../../../../../..")
7+
8+
target_include_directories(app PRIVATE
9+
${SOF_ROOT}/zephyr/include
10+
${SOF_ROOT}/src/include
11+
)
12+
13+
# Define SOF-specific configurations for unit testing
14+
target_compile_definitions(app PRIVATE
15+
-DCONFIG_SOF_LOG_LEVEL=CONFIG_LOG_DEFAULT_LEVEL
16+
-DCONFIG_ZEPHYR_POSIX=1
17+
-DCONFIG_LIBRARY=1
18+
-DUNIT_TEST=1
19+
)
20+
21+
target_sources(app PRIVATE
22+
trig_test.c
23+
${SOF_ROOT}/src/math/trig.c
24+
${SOF_ROOT}/src/math/lut_trig.c
25+
)
26+
27+
# Link math library for standard math functions
28+
target_link_libraries(app PRIVATE m)
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
CONFIG_ZTEST=y
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
# SPDX-License-Identifier: BSD-3-Clause
2+
#
3+
# Copyright(c) 2025 Intel Corporation. All rights reserved.
4+
#
5+
# Math basic trigonometry unit tests converted from CMock to Ztest
6+
#
7+
# These contents may have been developed with support from one or more Intel-operated
8+
# generative artificial intelligence solutions.
9+
#
10+
11+
common:
12+
tags:
13+
- SOF
14+
- unit_test
15+
- math
16+
- trigonometry
17+
integration_platforms:
18+
- native_sim
19+
arch_exclude: xtensa # Test is for host builds only
20+
21+
tests:
22+
sof.unit.math.trigonometry:
23+
platform_allow:
24+
- native_sim

0 commit comments

Comments
 (0)