Skip to content

ut: cmock: Removing legacy tests ported to ztest - #11475

Open
tmleman wants to merge 8 commits into
thesofproject:mainfrom
tmleman:topic/upstream/pr/unit_test/cmocka/remove/phase_3p1
Open

tmleman wants to merge 8 commits into
thesofproject:mainfrom
tmleman:topic/upstream/pr/unit_test/cmocka/remove/phase_3p1

Conversation

@tmleman

@tmleman tmleman commented Nov 17, 2026

Copy link
Copy Markdown
Contributor

This PR removes legacy tests that have already been ported to the Zephyr ztest framework.

Copilot AI balanced review requested due to automatic review settings November 17, 2026 10:02
@tmleman
tmleman force-pushed the topic/upstream/pr/unit_test/cmocka/remove/phase_3p1 branch from 9678179 to 2411143 Compare November 17, 2026 10:04

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.

🔵 Needs a closer look

Relocated vector generators use broken helper paths, and codec outputs still target the old directory, preventing regeneration from updating the headers used by the tests.

No open issues 🎉

What changed in this PR

This PR continues SOF’s migration to Zephyr ztest by removing legacy CMocka math tests that already have ztest replacements and relocating their reference assets.

Changes:

  • Removes redundant CMocka tests and build registrations, while retaining the DFT3 test.
  • Moves reference vectors and MATLAB generation helpers into the ztest tree.
  • Updates ztest include paths and comments to reflect the new asset locations.
File Description
test/​ztest/​unit/​math/​window/​test_window_ztest.c Updates the reference-data location comment.
test/​ztest/​unit/​math/​window/​ref_window.m Relocates the window-vector generator.
test/​ztest/​unit/​math/​window/​ref_window_rectangular.h Relocates rectangular-window references.
test/​ztest/​unit/​math/​window/​ref_window_povey.h Relocates Povey-window references.
test/​ztest/​unit/​math/​window/​ref_window_hamming.h Relocates Hamming-window references.
test/​ztest/​unit/​math/​window/​ref_window_blackman.h Relocates Blackman-window references.
test/​ztest/​unit/​math/​window/​mfcc_povey.m Relocates the Povey-window helper.
test/​ztest/​unit/​math/​window/​mfcc_blackman.m Relocates the Blackman-window helper.
test/​ztest/​unit/​math/​window/​CMakeLists.txt Removes the legacy reference include path.
test/​ztest/​unit/​math/​mu_law/​test_mu_law_codec_ztest.c Documents relocated codec references.
test/​ztest/​unit/​math/​mu_law/​CMakeLists.txt Uses the shared ztest arithmetic include path.
test/​ztest/​unit/​math/​matrix/​test_matrix_ztest.c Updates the reference-data location comment.
test/​ztest/​unit/​math/​matrix/​ref_matrix.m Relocates the matrix-vector generator.
test/​ztest/​unit/​math/​matrix/​ref_matrix_mult_16_test4.h Relocates matrix test 4 references.
test/​ztest/​unit/​math/​matrix/​ref_matrix_mult_16_test3.h Relocates matrix test 3 references.
test/​ztest/​unit/​math/​matrix/​ref_matrix_mult_16_test2.h Relocates matrix test 2 references.
test/​ztest/​unit/​math/​matrix/​ref_matrix_mult_16_test1.h Relocates matrix test 1 references.
test/​ztest/​unit/​math/​matrix/​CMakeLists.txt Removes the legacy reference include path.
test/​ztest/​unit/​math/​fft/​test_fft_ztest.c Documents the relocated FFT input header.
test/​ztest/​unit/​math/​fft/​CMakeLists.txt Removes the legacy FFT reference include path.
test/​ztest/​unit/​math/​fft_multi/​test_fft_multi_ztest.c Updates the reference-data location comment.
test/​ztest/​unit/​math/​fft_multi/​ref_ifft_multi_256_32.h Relocates 256-point inverse FFT references.
test/​ztest/​unit/​math/​fft_multi/​ref_ifft_multi_24_32.h Relocates 24-point inverse FFT references.
test/​ztest/​unit/​math/​fft_multi/​ref_fft_multi.m Relocates the FFT-vector generator.
test/​ztest/​unit/​math/​fft_multi/​ref_fft_multi_96_32.h Relocates 96-point FFT references.
test/​ztest/​unit/​math/​fft_multi/​CMakeLists.txt Removes the legacy reference include path.
test/​ztest/​unit/​math/​dct/​test_dct_ztest.c Updates the reference-matrix location comment.
test/​ztest/​unit/​math/​dct/​ref_dct.m Relocates the DCT reference generator.
test/​ztest/​unit/​math/​dct/​ref_dct_matrix_16_test1.h Relocates DCT test 1 references.
test/​ztest/​unit/​math/​dct/​mfcc_get_dct_matrix.m Relocates the DCT-matrix helper.
test/​ztest/​unit/​math/​dct/​CMakeLists.txt Removes the legacy reference include path.
test/​ztest/​unit/​math/​auditory/​test_auditory_ztest.c Updates the reference-data location comment.
test/​ztest/​unit/​math/​auditory/​ref_mel_filterbank_32_test4.h Relocates 32-bit filterbank test 4 vectors.
test/​ztest/​unit/​math/​auditory/​ref_mel_filterbank_32_test3.h Relocates 32-bit filterbank test 3 vectors.
test/​ztest/​unit/​math/​auditory/​ref_mel_filterbank_32_test2.h Relocates 32-bit filterbank test 2 vectors.
test/​ztest/​unit/​math/​auditory/​ref_mel_filterbank_32_test1.h Relocates 32-bit filterbank test 1 vectors.
test/​ztest/​unit/​math/​auditory/​ref_mel_filterbank_16_test4.h Relocates 16-bit filterbank test 4 vectors.
test/​ztest/​unit/​math/​auditory/​ref_mel_filterbank_16_test3.h Relocates 16-bit filterbank test 3 vectors.
test/​ztest/​unit/​math/​auditory/​ref_mel_filterbank_16_test2.h Relocates 16-bit filterbank test 2 vectors.
test/​ztest/​unit/​math/​auditory/​ref_mel_filterbank_16_test1.h Relocates 16-bit filterbank test 1 vectors.
test/​ztest/​unit/​math/​auditory/​ref_hz_to_mel.h Relocates frequency-conversion references.
test/​ztest/​unit/​math/​auditory/​ref_auditory.m Relocates the auditory-vector generator.
test/​ztest/​unit/​math/​auditory/​plot_filterbank_test.m Relocates the filterbank plotting helper.
test/​ztest/​unit/​math/​auditory/​mfcc_power_to_mel_log.m Relocates the logarithmic Mel-power helper.
test/​ztest/​unit/​math/​auditory/​mfcc_mel_to_hz.m Relocates the Mel-to-Hz helper.
test/​ztest/​unit/​math/​auditory/​mfcc_hz_to_mel.m Relocates the Hz-to-Mel helper.
test/​ztest/​unit/​math/​auditory/​mfcc_get_mel_filterbank.m Relocates the Mel-filterbank helper.
test/​ztest/​unit/​math/​auditory/​CMakeLists.txt Removes the legacy reference include path.
test/​ztest/​unit/​math/​arithmetic/​a_law_mu_law_test_vectors.m Relocates the shared codec-vector generator.
test/​ztest/​unit/​math/​a_law/​test_a_law_codec_ztest.c Documents relocated codec references.
test/​ztest/​unit/​math/​a_law/​CMakeLists.txt Uses the shared ztest arithmetic include path.
test/​cmocka/​src/​math/​window/​window.c Removes the legacy window tests.
test/​cmocka/​src/​math/​window/​CMakeLists.txt Removes the window test target.
test/​cmocka/​src/​math/​matrix/​matrix.c Removes the legacy matrix tests.
test/​cmocka/​src/​math/​matrix/​CMakeLists.txt Removes the matrix test target.
test/​cmocka/​src/​math/​fft/​fft_multi.c Removes the legacy multi-size FFT tests.
test/​cmocka/​src/​math/​fft/​CMakeLists.txt Removes FFT targets while retaining DFT3.
test/​cmocka/​src/​math/​dct/​dct.c Removes the legacy DCT tests.
test/​cmocka/​src/​math/​dct/​CMakeLists.txt Removes the DCT test target.
test/​cmocka/​src/​math/​CMakeLists.txt Stops registering migrated test directories.
test/​cmocka/​src/​math/​auditory/​CMakeLists.txt Removes the auditory test target.
test/​cmocka/​src/​math/​auditory/​auditory.c Removes the legacy auditory tests.
test/​cmocka/​src/​math/​arithmetic/​mu_law_codec.c Removes the legacy mu-law tests.
test/​cmocka/​src/​math/​arithmetic/​CMakeLists.txt Removes both legacy codec targets.
test/​cmocka/​src/​math/​arithmetic/​a_law_codec.c Removes the legacy A-law tests.

Review effort: Balanced

@intel-sofci

intel-sofci commented Nov 17, 2026 •

Copy link
Copy Markdown

PR 11475: test results

Run date: 2026-11-17 11:33 UTC

Tested commit: 2411143280366c59e45bae614ccf4397f737e8f6

mtl pass rate lnl pass rate ptl pass rate wcl pass rate nvl pass rate

This patch removes the a_law_codec test that has been successfully
converted to the new framework (from cmock to ztest). a_law_codec.h is
moved with git mv into the ztest suite's own directory, since it is only
needed by this test. ref_chirp_mono_8k_s16.h stays #included in place
from the CMocka tree for now: it is still shared with the CMocka mu_law
test, and will move once that test is removed too.

Code coverage testing did not reveal any regression.

CMock stats for a_law.c
- lines: 100.0 % (32/32)
- branches: 100.0 % (8/8)

Ztest stats for a_law.c
- lines: 96.6 % (28/29)
- branches: 90.0 % (9/10)

The denominators differ because gcc and clang instrument the same source
at different line/branch granularity; both frameworks exercise the same
chirp reference vectors end to end.

Assisted-by: Copilot:claude-sonnet-5
Signed-off-by: Tomasz Leman <tomasz.m.leman@intel.com>
This patch removes the mu_law_codec test that has been successfully
converted to the new framework (from cmock to ztest). mu_law_codec.h is
moved with git mv into the ztest suite's own directory. This was the last
CMocka consumer of ref_chirp_mono_8k_s16.h and a_law_mu_law_test_vectors.m,
which also move with git mv into a new shared test/ztest/unit/math/
arithmetic directory; the a_law suite (already ported and ref_chirp
consumer) now points its include path there instead of the CMocka tree.

With both arithmetic tests gone, test/cmocka/src/math/arithmetic/ is now
empty and is removed along with its add_subdirectory() call.

Code coverage testing did not reveal any regression.

CMock stats for mu_law.c
- lines: 100.0 % (31/31)
- branches: 100.0 % (6/6)

Ztest stats for mu_law.c
- lines: 100.0 % (26/26)
- branches: 100.0 % (6/6)

Assisted-by: Copilot:claude-sonnet-5
Signed-off-by: Tomasz Leman <tomasz.m.leman@intel.com>
This patch removes the fft test that has been successfully converted to
the new framework (from cmock to ztest). input.h is moved with git mv
into the ztest suite's own directory, since it was only needed by this
test; the dft3 and fft_multi targets in the same CMocka directory use
their own separate reference headers and are unaffected.

Code coverage testing did not reveal any regression.

CMock stats for fft_common.c, fft_32.c, fft_16.c
- lines: 87.9 % (124/141)
- branches: 64.0 % (57/89)

Ztest stats for fft_common.c, fft_32.c, fft_16.c
- lines: 84.5 % (109/129)
- branches: 74.7 % (56/75)

Both suites exercise mod_fft_plan_new()/mod_fft_plan_free() and
fft_execute_16()/fft_execute_32() identically; the fft_16_hifi3.c and
fft_32_hifi3.c sources remain linked but inert on native_sim/host (gated
by FFT_HIFI3, only active under __XCC__).

Assisted-by: Copilot:claude-sonnet-5
Signed-off-by: Tomasz Leman <tomasz.m.leman@intel.com>
This patch removes the fft_multi test that has been successfully
converted to the new framework (from cmock to ztest). The eleven
ref_fft_multi_*_32.h / ref_ifft_multi_*_32.h reference vectors and the
ref_fft_multi.m generation script are moved with git mv into the ztest
suite's own directory. The dft3 target in the same CMocka directory uses
its own separate ref_dft3_32.h and is unaffected.

Code coverage testing did not reveal any regression.

CMock stats for fft_multi_generic.c
- lines: 100.0 % (62/62)
- branches: 75.0 % (36/48)

Ztest stats for fft_multi_generic.c
- lines: 100.0 % (66/66)
- branches: 100.0 % (24/24)

Assisted-by: Copilot:claude-sonnet-5
Signed-off-by: Tomasz Leman <tomasz.m.leman@intel.com>
The matrix math component is already fully covered by the ztest port
at test/ztest/unit/math/matrix/. Remove the now-redundant CMocka test
and its CMakeLists.txt stanza, along with the whole matrix/
subdirectory (it was the last remaining test there).

Move the reference test vectors reused by the ztest port
(ref_matrix_mult_16_test{1,2,3,4}.h, ref_matrix.m) with git mv into
test/ztest/unit/math/matrix/ to preserve file history, and drop the
now-unneeded CMocka include path from the ztest CMakeLists.txt.

CMock stats for src/math/matrix.c:
- lines: 90% (48/53)
- branches: 70% (24/34)

Ztest stats for src/math/matrix.c:
- lines: 85% (54/63)
- branches: 70% (24/34)

Branch coverage is identical between the two builds (same uncovered
logic). The small line-coverage percentage difference is due to
gcc vs clang instrumentation granularity (different line-count
denominators for the same source), not a regression.

Assisted-by: Copilot:claude-sonnet-5
Signed-off-by: Tomasz Leman <tomasz.m.leman@intel.com>
The auditory math component (Mel filterbank, Hz<->Mel conversion) is
already fully covered by the ztest port at
test/ztest/unit/math/auditory/. Remove the now-redundant CMocka test
and its CMakeLists.txt stanza, along with the whole auditory/
subdirectory (it was the last remaining test there).

Move the reference test vectors and their Octave/MATLAB generator
scripts reused by the ztest port (ref_hz_to_mel.h,
ref_mel_filterbank_{16,32}_test{1-4}.h, mfcc_*.m,
plot_filterbank_test.m, ref_auditory.m) with git mv into
test/ztest/unit/math/auditory/ to preserve file history, and drop the
now-unneeded CMocka include path from the ztest CMakeLists.txt.

CMock stats for auditory.c + mel_filterbank_{16,32}.c (combined):
- lines: 96% (189/195)
- branches: 67% (51/76)

Ztest stats for auditory.c + mel_filterbank_{16,32}.c (combined):
- lines: 90% (160/176)
- branches: 76% (60/78)

Branch coverage is higher on the ztest side; the slightly lower line
percentage is due to gcc vs clang instrumentation granularity
(different line-count denominators for the same source), not a
regression.

Assisted-by: Copilot:claude-sonnet-5
Signed-off-by: Tomasz Leman <tomasz.m.leman@intel.com>
The DCT (Discrete Cosine Transform) matrix generation code is already
fully covered by the ztest port at test/ztest/unit/math/dct/. Remove
the now-redundant CMocka test and its CMakeLists.txt stanza, along
with the whole dct/ subdirectory (it was the last remaining test
there).

Move the reference DCT matrices and their Octave/MATLAB generator
scripts reused by the ztest port (ref_dct_matrix_16_test{1,2}.h,
mfcc_get_dct_matrix.m, ref_dct.m) with git mv into
test/ztest/unit/math/dct/ to preserve file history, and drop the
now-unneeded CMocka include path from the ztest CMakeLists.txt.

CMock stats for src/math/dct.c:
- lines: 100% (29/29)
- branches: 65% (13/20)

Ztest stats for src/math/dct.c:
- lines: 86% (25/29)
- branches: 65% (13/20)

Branch coverage is identical between the two builds, including the
same missing branches, confirming equivalent test behaviour. The line
percentage difference is a gcc vs clang line-hit accounting artifact
for the same source file, not a regression.

Assisted-by: Copilot:claude-sonnet-5
Signed-off-by: Tomasz Leman <tomasz.m.leman@intel.com>
The window generation code (rectangular, Blackman, Hamming, Povey) is
already fully covered by the ztest port at
test/ztest/unit/math/window/. Remove the now-redundant CMocka test
and its CMakeLists.txt stanza, along with the whole window/
subdirectory (it was the last remaining test there). This also
removes the last non-dft3 subdirectory from test/cmocka/src/math/,
leaving only fft/ (dft3, deferred to a later phase).

Move the reference windows and their Octave/MATLAB generator scripts
reused by the ztest port (ref_window_{rectangular,blackman,hamming,
povey}.h, mfcc_blackman.m, mfcc_povey.m, ref_window.m) with git mv
into test/ztest/unit/math/window/ to preserve file history, and drop
the now-unneeded CMocka include path from the ztest CMakeLists.txt.

CMock stats for src/math/window.c:
- lines: 48% (54/111)
- branches: 34% (11/32)

Ztest stats for src/math/window.c:
- lines: 46% (38/81)
- branches: 44% (8/18)

Every branch missing on the ztest side is also missing on the CMock
side (same untested logic paths), confirming no regression. The
differing line/branch denominators for the identical source file are
a gcc vs clang instrumentation/optimization-level artifact, not a
behavioural difference.

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.

3 participants