Uh oh!
There was an error while loading. Please reload this page.
test: ztest: Add scalar power function support and unit test - #10364
Conversation
There was a problem hiding this comment.
Pull Request Overview
This PR converts the scalar power function unit test from CMock to Zephyr's ztest framework and adds conditional Zephyr logging support to the implementation.
Key Changes:
- Added Zephyr-compatible logging infrastructure to
power.cusing conditional compilation - Created new ztest-based unit test file (
test_scalar_power_ztest.c) with 384 test cases (64 base values × 6 exponents)
Reviewed Changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| test/ztest/unit/math/advanced/functions/test_scalar_power_ztest.c | New ztest implementation of scalar power unit tests with MATLAB reference validation |
| test/ztest/unit/math/advanced/functions/CMakeLists.txt | Build configuration for the new ztest suite with SOF-specific compiler flags |
| src/math/power.c | Added conditional compilation to support both traditional SOF trace logging and Zephyr logging |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| float delta = fabsf((float)(power_table[i][j] - (double)p / (1 << 15))); | ||
| zassert_true(delta <= CMP_TOLERANCE); |
There was a problem hiding this comment.
The magic number 1 << 15 represents the Q16.15 fixed-point scaling factor. Consider defining it as a named constant (e.g., Q16_15_SCALE) to improve code clarity and match the documented format in the function documentation.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
0bac709 to
13bb7bcCompareThis patch converts 1 existing math advanced function unit test from CMock/Unity to Zephyr's Ztest framework, maintaining the same test coverage and functionality: - test_math_arithmetic_power_fixed: Fixed-point scalar power function Original test converted from sof/test/cmocka/src/math/arithmetic/scalar_power.c authored by: - Shriram Shastry <malladi.sastry@linux.intel.com> The converted test validates the same power_int32() function from src/math/power.c as the original CMock test, 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. Test validates 384 combinations (64 base values × 6 exponent values) using MATLAB-generated reference data with fixed-point arithmetic: - Base values: Q6.25 format (range -1.0 to 1.0) - Exponent values: Q2.29 format - Results: Q16.15 format - Tolerance: max error 0.000034912111005, THD+N -96.457180359025074 This is part of the broader SOF unit test migration from CMock to Zephyr Ztest framework, establishing the foundation for math/advanced/functions tests in the new directory structure. Signed-off-by: Tomasz Leman <tomasz.m.leman@intel.com>
Uh oh!
There was an error while loading. Please reload this page.
This patch removes the scalar power test that has been successfully converted from cmocka to ztest. The ztest equivalent is in test/ztest/unit/math/advanced/functions/ test_scalar_power_ztest.c and was merged in PR #10364. Ztest coverage for power.c: - lines: 92.9% (13/14) - funcs: 100% (1/1) Code coverage testing did not reveal any regression. Signed-off-by: Tomasz Leman <tomasz.m.leman@intel.com>
Add Zephyr ztest framework support for scalar power function and convert existing CMock unit test to ztest.
Changes
math/power.c: Add conditional Zephyr logging for ztest compatibility