Skip to content

Conversation

@tmleman
Copy link
Contributor

@tmleman tmleman commented Sep 11, 2025

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:

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.

Copilot AI review requested due to automatic review settings September 11, 2025 13:05
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR converts 9 existing math trigonometry unit tests from CMock/Unity to Zephyr's Ztest framework, maintaining the same test coverage and functionality while establishing the foundation for math/basic/trigonometry tests in the new SOF Ztest directory structure.

  • Conversion of trigonometric function tests (sin, cos, asin, acos) for both 16-bit and 32-bit fixed-point implementations
  • Addition of sine lookup table test for 16-bit fixed-point
  • Preservation of original reference tables and tolerance values to maintain identical test accuracy

Reviewed Changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
test/ztest/unit/math/basic/trigonometry/trig_test.c Main test file with 9 converted trigonometry tests using Ztest framework
test/ztest/unit/math/basic/trigonometry/trig_tables.h Reference data tables and tolerance constants for trigonometry tests
test/ztest/unit/math/basic/trigonometry/testcase.yaml Test configuration file defining test metadata and platform requirements
test/ztest/unit/math/basic/trigonometry/prj.conf Zephyr project configuration enabling Ztest framework
test/ztest/unit/math/basic/trigonometry/CMakeLists.txt CMake build configuration linking SOF math libraries and test sources

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

@tmleman tmleman force-pushed the topic/upstream/pr/unit_test/ztest/math/trigonometry branch from f216226 to 40b6a9d Compare September 11, 2025 13:13
@tmleman tmleman requested a review from Copilot September 11, 2025 13:14
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

Copilot reviewed 5 out of 5 changed files in this pull request and generated 12 comments.


Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

@tmleman tmleman force-pushed the topic/upstream/pr/unit_test/ztest/math/trigonometry branch 2 times, most recently from 448fabb to 385485a Compare September 11, 2025 14:17
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>
Copy link
Member

@lgirdwood lgirdwood left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, but also needs @singalsu to approve.

Copy link
Collaborator

@softwarecki softwarecki left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice cleanup! Migrating these tests to Ztest keeps coverage intact and moves us closer to a unified testing framework.

@kv2019i kv2019i merged commit 5bd5a4b into thesofproject:main Oct 6, 2025
37 of 45 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants