Skip to content

test: math: port dft3 CMocka test to ztest - #11467

Open
tmleman wants to merge 1 commit into
thesofproject:mainfrom
tmleman:topic/upstream/pr/ut/ztest/math/dtf3
Open

tmleman wants to merge 1 commit into
thesofproject:mainfrom
tmleman:topic/upstream/pr/ut/ztest/math/dtf3

Conversation

@tmleman

@tmleman tmleman commented Nov 16, 2026

Copy link
Copy Markdown
Contributor

Add a ztest suite for dft3_32(), the 3-point DFT used by some FFT plan sizes, covering the same single case as the CMocka test. The reference vectors are included in place from the CMocka tree so both frameworks are driven by identical fixed-point data.

dft3_32() is implemented in fft_multi_generic.c (and fft_multi_hifi3.c for Xtensa, gated out on native_sim), so the suite links the same five math sources as the CMocka target. No heap allocation or module-adapter functionality is exercised by this test, so the suite needs no allocator hook.

Code coverage testing did not reveal any regression.

CMock stats for fft_multi_generic.c

  • lines: 32.3 % (20/62)
  • branches: 22.9 % (11/48)

Ztest stats for fft_multi_generic.c

  • lines: 27.3 % (18/66)
  • branches: 8.3 % (2/24)

Both frameworks exercise only dft3_32() in this file; the remaining functions (fft_multi, ifft_multi and their helpers) are covered by the separate fft_multi suite/test, not by dft3. The lower ztest percentage is a smaller denominator effect from clang's finer-grained branch counting for the same source, not a drop in tested behavior: the mutation test below confirms the port's assertions are as strict as the original.

Mutation-tested by tightening SOFM_DFT3_MAX_ERROR_RMS from 1.1 to 0.0001, confirming the suite fails, then reverting. Verified clean under --enable-asan --enable-lsan.

Assisted-by: Copilot:claude-sonnet-5

Copilot AI balanced review requested due to automatic review settings November 16, 2026 12:34

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟢 Approval recommended

No active review issues block the added Zephyr ztest coverage for dft3_32().

No open issues 🎉

What changed in this PR

Adds a Zephyr ztest counterpart to the CMocka test for dft3_32(), preserving reference-data and numerical-tolerance coverage for the 3-point DFT used by FFT plans.

Changes:

  • Reuses the CMocka reference vectors and checks maximum absolute and aggregate RMS error.
  • Adds compile-time checks for reference-vector sizes.
  • Configures a standalone native_sim suite with the required FFT sources and math-library linkage.
File Description
test/​ztest/​unit/​math/​dft3/​testcase.yaml Registers the suite for execution on native_sim.
test/​ztest/​unit/​math/​dft3/​test_dft3_ztest.c Implements the reference-vector test with the original error limits.
test/​ztest/​unit/​math/​dft3/​prj.conf Enables ztest and disables the full SOF application.
test/​ztest/​unit/​math/​dft3/​CMakeLists.txt Configures sources, shared vector includes, compile definitions, and linkage.

Review effort: Balanced

Add a ztest suite for dft3_32(), the 3-point DFT used by some FFT plan
sizes, covering the same single case as the CMocka test. The reference
vectors are included in place from the CMocka tree so both frameworks are
driven by identical fixed-point data.

dft3_32() is implemented in fft_multi_generic.c (and fft_multi_hifi3.c for
Xtensa, gated out on native_sim), so the suite links the same five math
sources as the CMocka target. No heap allocation or module-adapter
functionality is exercised by this test, so the suite needs no allocator
hook.

Code coverage testing did not reveal any regression.

CMock stats for fft_multi_generic.c
- lines: 32.3 % (20/62)
- branches: 22.9 % (11/48)

Ztest stats for fft_multi_generic.c
- lines: 27.3 % (18/66)
- branches: 8.3 % (2/24)

Both frameworks exercise only dft3_32() in this file; the remaining
functions (fft_multi, ifft_multi and their helpers) are covered by the
separate fft_multi suite/test, not by dft3. The lower ztest percentage is
a smaller denominator effect from clang's finer-grained branch counting
for the same source, not a drop in tested behavior: the mutation test
below confirms the port's assertions are as strict as the original.

Mutation-tested by tightening SOFM_DFT3_MAX_ERROR_RMS from 1.1 to 0.0001,
confirming the suite fails, then reverting. Verified clean under
--enable-asan --enable-lsan.

Assisted-by: Copilot:claude-sonnet-5
Signed-off-by: Tomasz Leman <tomasz.m.leman@intel.com>
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.

2 participants