Repository navigation
test: math: port window CMocka test to ztest - #11371
Merged
lgirdwood merged 1 commit intoOct 29, 2026
Merged
Conversation
tmleman
requested review from
dbaluta,
kv2019i,
lbetlej,
lgirdwood,
mmaka1 and
plbossart
as code owners
October 28, 2026 15:14
Contributor
There was a problem hiding this comment.
🟢 Approval recommended
The window-function test migration has no active review issues.
No open issues 🎉
What changed in this PR
Ports the legacy CMocka window-function tests to Zephyr ztest while keeping the existing CMocka suite unchanged.
Changes:
- Adds four tests for 16-bit rectangular, Blackman, Hamming, and Povey windows, sharing the existing reference vectors and RMS error threshold.
- Uses a statically allocated scratch buffer with compile-time size checks.
- Adds native_sim test configuration, math dependencies, and floating-point diagnostic support.
| File | Description |
|---|---|
test/ztest/unit/math/window/testcase.yaml |
Registers the window test suite for native_sim. |
test/ztest/unit/math/window/test_window_ztest.c |
Implements four window checks with shared RMS validation. |
test/ztest/unit/math/window/prj.conf |
Enables ztest and floating-point message formatting. |
test/ztest/unit/math/window/CMakeLists.txt |
Links window math sources and includes shared reference vectors. |
Review effort: Balanced
2 tasks
lgirdwood
approved these changes
Oct 28, 2026
PR 11371: test resultsRun date: 2026-10-29 17:36 UTC Tested commit: ef83ef416323c3e0f19c0df12e993b540a1d6fe1 |
Member
|
@tmleman can you check CI thanks ! |
tmleman
force-pushed
the
topic/upstream/pr/ut/ztest/math/window
branch
from
October 29, 2026 08:30
026f5fc to
ef83ef4
Compare
Port the legacy CMocka unit test test/cmocka/src/math/window/window.c to a
Zephyr ztest suite under test/ztest/unit/math/window/.
sof.unit.math.window mirrors window.c: it links src/math/window.c and its
trig/log/decibels dependencies, matching the legacy CMakeLists.txt, and
converts the 4 window checks (rectangular, Blackman, Hamming, Povey) into
one ZTEST case each, all against the same 1.0 LSB RMS error limit, computed
by the same float math. The reference windows (ref_window_*.h) are
#included in place from the CMocka tree via the include path, shared
verbatim between both frameworks, as test/ztest/unit/math/{a_law,mu_law,fft}
already do. The CMocka test keeps running unchanged.
Each ZTEST case now calls its window function directly, so the strcmp()
dispatch on a window name string of the original test_window() is dropped,
along with the #ifdef DEBUG_FILES dump, which was an unused diagnostic.
The scratch window is a static array sized by the longest reference vector
rather than a malloc() per call, with BUILD_ASSERTs tying it to the
reference lengths, so the suite needs no allocator at all.
Two build differences against CMocka, neither of which changes the error
math: Zephyr compiles with -Wdouble-promotion, so the RMS uses sqrtf() and
casts its float arguments to double explicitly at the printk() varargs call
sites, and CONFIG_CBPRINTF_FP_SUPPORT=y is needed because printk()
otherwise emits the %f conversions of the log and of the failure message
literally.
Verified with:
west twister -T sof/test/ztest/unit/math/window/ --platform native_sim
-> sof.unit.math.window: 4/4 cases PASSED
-> whole unit tree: 15/15 configurations, 122/122 cases PASSED, with
and without --enable-asan --enable-lsan
The reported RMS errors are identical to the ones the CMocka test computes
from the same references, in LSB:
window CMocka ztest limit
rectangular 0.00 0.00 1.00
blackman 0.67 0.67 1.00
hamming 0.00 0.00 1.00
povey 0.29 0.29 1.00
Like the CMocka test, the suite covers only the 16-bit windows that have
reference vectors. win_rectangular_32b(), win_blackman_32b(),
win_hann_16b(), win_hann_32b() and win_hamming_32b() stay uncovered.
Assisted-by: Copilot:claude-opus-5
Signed-off-by: Tomasz Leman <tomasz.m.leman@intel.com>
Contributor
Author
Not related to my PR. |
softwarecki
approved these changes
Oct 29, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Port the legacy CMocka unit test test/cmocka/src/math/window/window.c to a Zephyr ztest suite under test/ztest/unit/math/window/.
sof.unit.math.window mirrors window.c: it links src/math/window.c and its trig/log/decibels dependencies, matching the legacy CMakeLists.txt, and converts the 4 window checks (rectangular, Blackman, Hamming, Povey) into one ZTEST case each, all against the same 1.0 LSB RMS error limit, computed by the same float math. The reference windows (ref_window_*.h) are #included in place from the CMocka tree via the include path, shared verbatim between both frameworks, as test/ztest/unit/math/{a_law,mu_law,fft} already do. The CMocka test keeps running unchanged.
Each ZTEST case now calls its window function directly, so the strcmp() dispatch on a window name string of the original test_window() is dropped, along with the #ifdef DEBUG_FILES dump, which was an unused diagnostic. The scratch window is a static array sized by the longest reference vector rather than a malloc() per call, with BUILD_ASSERTs tying it to the reference lengths, so the suite needs no allocator at all.
Two build differences against CMocka, neither of which changes the error math: Zephyr compiles with -Wdouble-promotion, so the RMS uses sqrtf() and casts its float arguments to double explicitly at the printk() varargs call sites, and CONFIG_CBPRINTF_FP_SUPPORT=y is needed because printk() otherwise emits the %f conversions of the log and of the failure message literally.
Verified with:
west twister -T sof/test/ztest/unit/math/window/ --platform native_sim
-> sof.unit.math.window: 4/4 cases PASSED
-> whole unit tree: 15/15 configurations, 122/122 cases PASSED, with
and without --enable-asan --enable-lsan
The reported RMS errors are identical to the ones the CMocka test computes from the same references, in LSB:
window CMocka ztest limit
rectangular 0.00 0.00 1.00
blackman 0.67 0.67 1.00
hamming 0.00 0.00 1.00
povey 0.29 0.29 1.00
Like the CMocka test, the suite covers only the 16-bit windows that have reference vectors. win_rectangular_32b(), win_blackman_32b(), win_hann_16b(), win_hann_32b() and win_hamming_32b() stay uncovered.
Assisted-by: Copilot:claude-opus-5