Conversation
tmleman
requested review from
dbaluta,
kv2019i,
lbetlej,
lgirdwood,
mmaka1 and
plbossart
as code owners
September 25, 2026 15:16
Contributor
There was a problem hiding this comment.
Copilot review overview
🟢 Approval recommended
No unresolved review issues were identified.
Review effort: Lite
Findings: None
What changed in this PR
Ports A-law and μ-law codec unit tests from CMocka to Zephyr Ztest.
Changes:
- Adds encode/decode Ztest coverage for both codecs.
- Adds native_sim metadata and configurations.
- Reuses shared codec reference vectors.
| File | Description |
|---|---|
test/ztest/unit/math/mu_law/testcase.yaml |
μ-law test registration |
test/ztest/unit/math/mu_law/test_mu_law_codec_ztest.c |
μ-law Ztest cases |
test/ztest/unit/math/mu_law/prj.conf |
μ-law Ztest configuration |
test/ztest/unit/math/mu_law/CMakeLists.txt |
μ-law build setup |
test/ztest/unit/math/a_law/testcase.yaml |
A-law test registration |
test/ztest/unit/math/a_law/test_a_law_codec_ztest.c |
A-law Ztest cases |
test/ztest/unit/math/a_law/prj.conf |
A-law Ztest configuration |
test/ztest/unit/math/a_law/CMakeLists.txt |
A-law build setup |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Convert the legacy CMocka a_law_codec unit test to a Zephyr ztest suite
under test/ztest/unit/math/a_law, running on native_sim via twister as
scenario sof.unit.math.a_law.
The two ported cases keep identical intent, test data and fixed-point
semantics: test_a_law_encode encodes every s16 chirp sample with
sofm_a_law_encode() and test_a_law_decode expands every reference code
word with sofm_a_law_decode(), both compared against the same
pre-computed reference vectors. The reference-data headers
(ref_chirp_mono_8k_s16.h, a_law_codec.h) are #included in place from the
CMocka tree rather than copied, so both frameworks share the exact same
data.
Coverage of src/math/a_law.c (lcov hit/total; CMocka unit_test_defconfig
gcc vs ztest native_sim clang):
src/math/a_law.c
CMocka: lines 32/32 functions 2/2 branches 8/8
ztest: lines 28/29 functions 2/2 branches 9/10
Functions match 2/2 and ztest covers one extra branch (9/10 vs 8/8).
Every line gcc executes is also executed by ztest, the differing line
totals are pure gcc/clang bucketing. The only line clang marks unhit
(the saturation clamp sample = SOFM_ALAW_MAX) is unreachable with the
shared chirp data, so gcc emits no counter for it either, there is no
real coverage regression.
Signed-off-by: Tomasz Leman <tomasz.m.leman@intel.com>
Port both mu-law codec cases to native_sim ztest. Encode every s16 chirp sample and decode every reference code word. Keep the original fixed-point comparisons and share the legacy vectors in place. Coverage of src/math/mu_law.c (gcc CMocka vs clang ztest): CMocka: lines 31/31 functions 2/2 branches 6/6 ztest: lines 26/26 functions 2/2 branches 6/6 Both have full source coverage; totals differ by instrumentation. Signed-off-by: Tomasz Leman <tomasz.m.leman@intel.com> Assisted-by: GitHub Copilot CLI:gpt-6-sol
kv2019i
approved these changes
Sep 25, 2026
lgirdwood
approved these changes
Sep 25, 2026
2 tasks
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.
No description provided.