-
Notifications
You must be signed in to change notification settings - Fork 349
Description
Feature Request
Problem Description
The current SOF unit test infrastructure uses CMock/CMocka framework, which creates problems:
- Framework Mismatch: SOF is transitioning to Zephyr RTOS, but unit tests still use CMock instead of Zephyr's native testing framework
- Integration Challenges: CMock tests don't integrate well with Zephyr's development workflow and Twister test runner
- Platform Fragmentation: 15 different platform configurations with varying test counts (48-56 tests)
- Developer Experience: Context-switching between different testing frameworks
Proposed Solution
Migrate all 56 existing CMock-based unit tests to Zephyr's native ztest framework:
Goals:
- Complete framework migration from CMock to ztest
- Unified testing experience aligned with Zephyr ecosystem
- Enhanced CI/CD integration with Twister test runner
- Maintain functional equivalence of all existing tests
Key Features:
- All 56 tests migrated (18 audio components, 10 library functions, 28 mathematical functions)
- Platform consistency across all 15 configurations
- Split architecture: basic unit tests (native_sim only) vs integration tests (multi-platform)
Current State
- 56 tests across 15 platform configurations using CMock
- Proof of Concept: Working ztest implementation in development branch (
not yet integrated)
Platform Configurations
| Platform Configuration | Test Count | Primary Target |
|---|---|---|
unit_test_defconfig |
56 tests | Generic UT framework |
acp_6_3_defconfig |
50 tests | AMD ACP 6.3 |
acp_7_0_defconfig |
50 tests | AMD ACP 7.0 |
imx8_defconfig |
48 tests | NXP i.MX8 |
imx8m_defconfig |
48 tests | NXP i.MX8M |
imx8ulp_defconfig |
48 tests | NXP i.MX8ULP |
imx8x_defconfig |
48 tests | NXP i.MX8X |
mt8186_defconfig |
48 tests | MediaTek MT8186 |
mt8188_defconfig |
48 tests | MediaTek MT8188 |
mt8195_defconfig |
48 tests | MediaTek MT8195 |
mt8196_defconfig |
48 tests | MediaTek MT8196 |
mt8365_defconfig |
48 tests | MediaTek MT8365 |
rembrandt_defconfig |
48 tests | AMD Rembrandt |
renoir_defconfig |
48 tests | AMD Renoir |
vangogh_defconfig |
48 tests | AMD Van Gogh |
Note: All platform configurations are built in CI using native host compilers (not cross-compilation). The tests executed across different platform configurations are largely identical, with minimal platform-specific differences. This results in significant redundancy in CI builds, where the same test logic is compiled and executed multiple times with only minor configuration variations. The proposed ztest architecture aims to eliminate this redundancy by distinguishing between basic unit tests (native_sim only) and platform-specific integration tests.
Complete Test Migration Status
Audio Components (18 tests)
| Test Name | Status | PR Link | Notes |
|---|---|---|---|
buffer_copy |
⏳ Pending | - | Buffer management |
buffer_new |
⏳ Pending | - | Buffer creation |
buffer_wrap |
⏳ Pending | - | Buffer wrapping |
buffer_write |
⏳ Pending | - | Buffer write operations |
comp_set_state |
⏳ Pending | - | Component state management |
pcm_float_generic |
⏳ Pending | - | PCM format conversion |
mixer |
⏳ Pending | - | Audio mixing |
pipeline_new |
⏳ Pending | - | Pipeline creation |
pipeline_connect_upstream |
⏳ Pending | - | Pipeline connection |
pipeline_free |
⏳ Pending | - | Pipeline cleanup |
volume_process |
⏳ Pending | - | Volume processing |
mux_get_processing_function |
⏳ Pending | - | MUX function selection |
mux_copy |
⏳ Pending | - | MUX copy operations |
demux_copy |
⏳ Pending | - | DEMUX copy operations |
selector_test |
⏳ Pending | - | Channel selector |
eq_iir_process |
⏳ Pending | - | IIR equalizer |
eq_fir_process |
⏳ Pending | - | FIR equalizer |
drc_math_test |
⏳ Pending | - | Dynamic range compression |
Library Functions (10 tests)
| Test Name | Status | PR Link | Notes |
|---|---|---|---|
rstrcmp |
❌ Blocked | Comment | String comparison |
rstrlen |
❌ Blocked | Comment | String length |
fast-get-tests |
✅ Complete | #10136 | Fast getter functions |
list_init |
✅ Complete | #10066 | List initialization (PoC exists) |
list_is_empty |
✅ Complete | #10066 | List empty check (PoC exists) |
list_item_append |
✅ Complete | #10066 | List append (PoC exists) |
list_item_del |
✅ Complete | #10066 | List deletion (PoC exists) |
list_item_is_last |
✅ Complete | #10066 | List last item check (PoC exists) |
list_item_prepend |
✅ Complete | #10066 | List prepend (PoC exists) |
list_item |
✅ Complete | #10066 | List item operations (PoC exists) |
Mathematical Functions (28 tests)
Arithmetic Functions (6 tests)
| Test Name | Status | PR Link | Notes |
|---|---|---|---|
gcd |
✅ Complete | #10138 | Greatest common divisor |
ceil_divide |
✅ Complete | #10138 | Ceiling division |
find_equal_int16 |
✅ Complete | #10138 | Find equal int16 values |
find_min_int16 |
✅ Complete | #10138 | Find minimum int16 |
find_max_abs_int32 |
✅ Complete | #10138 | Find max absolute int32 |
norm_int32 |
✅ Complete | #10138 | Normalize int32 |
Trigonometry Functions (9 tests)
| Test Name | Status | PR Link | Notes |
|---|---|---|---|
sin_32b_fixed |
✅ Complete | #10233 | 32-bit fixed sine |
cos_32b_fixed |
✅ Complete | #10233 | 32-bit fixed cosine |
sin_16b_fixed |
✅ Complete | #10233 | 16-bit fixed sine |
cos_16b_fixed |
✅ Complete | #10233 | 16-bit fixed cosine |
asin_32b_fixed |
✅ Complete | #10233 | 32-bit fixed arcsine |
acos_32b_fixed |
✅ Complete | #10233 | 32-bit fixed arccosine |
asin_16b_fixed |
✅ Complete | #10233 | 16-bit fixed arcsine |
acos_16b_fixed |
✅ Complete | #10233 | 16-bit fixed arccosine |
lut_sin_16b_fixed |
✅ Complete | #10233 | 16-bit sine lookup table |
Advanced Math Functions (6 tests)
| Test Name | Status | PR Link | Notes |
|---|---|---|---|
scalar_power |
🔄 In Progress | 10364 | Scalar power operations |
base2_logarithm |
⏳ Pending | - | Base-2 logarithm |
exponential |
⏳ Pending | - | Exponential function |
square_root |
⏳ Pending | - | Square root |
base_10_logarithm |
⏳ Pending | - | Base-10 logarithm |
base_e_logarithm |
⏳ Pending | - | Natural logarithm |
Audio Processing Math (7 tests)
| Test Name | Status | PR Link | Notes |
|---|---|---|---|
a_law_codec |
⏳ Pending | - | A-law codec |
mu_law_codec |
⏳ Pending | - | Mu-law codec |
fft |
⏳ Pending | - | Fast Fourier Transform |
window |
⏳ Pending | - | Window functions |
matrix |
⏳ Pending | - | Matrix operations |
auditory |
⏳ Pending | - | Auditory processing |
dct |
⏳ Pending | - | Discrete Cosine Transform |
Status Legend:
- ⏳ Pending: Not yet started
- 🟡 PoC Ready: Proof of concept exists, ready for integration
- 🔄 In Progress: Currently being migrated
- ✅ Complete: Migration completed and merged
- ❌ Blocked: Migration blocked by dependencies
Implementation Plan
Phase-Based Approach
| Phase | Scope | Key Deliverables |
|---|---|---|
| Phase 2 | Basic Unit Tests | Math, string, library functions (native_sim only) |
| Phase 3 | Advanced Unit Tests | Complex math, audio processing math (native_sim only) |
| Phase 4 | Integration Tests | Pipeline, modules, audio components (multi-platform) |
Test Architecture
-
Basic Unit Tests (
sof/test/ztest/unit/)- Platform:
native_simonly - Scope: Mathematical functions, basic library functions
- Execution: Fast, isolated testing
- Platform:
-
Integration Tests (
sof/test/ztest/integration/)- Platform:
native_simin CI, with additional platforms enabled as needed (subset of current 15 configurations) - Scope: Pipeline management, audio modules, component interaction
- Execution: Complex scenarios, real-world use cases
- Platform:
Migration Approach:
- All tests will initially be ported to run on
native_simplatform and executed in CI - Complex tests identified during migration will additionally be enabled on other platforms, requiring collaboration with specific platform developers
- CI Impact: No change to current CI behavior - tests will continue to run natively on the host, maintaining the same execution model as today's CMock tests
- Platform-specific work: Only complex integration tests will require platform maintainer involvement for multi-platform validation
Success Criteria
- 100% test migration completion (56/56 tests)
- Zero regression in test coverage or functionality
Benefits
- Unified testing framework aligned with SOF's Zephyr transition
- Improved developer productivity and reduced context switching
- Enhanced CI/CD integration through Twister test runner
- Future-proof testing infrastructure