Audio Module UTs using ztest. - #10751
Conversation
Add common test helper header with module lifecycle utilities for audio component ZTests. Include Octave/MATLAB scripts for generating passthrough configuration blobs. Signed-off-by: Liam Girdwood <liam.r.girdwood@linux.intel.com>
Add ZTest unit test validating module creation, configuration, prepare, copy, and teardown lifecycle for the aria component. Signed-off-by: Liam Girdwood <liam.r.girdwood@linux.intel.com>
Add ZTest unit test validating module creation, configuration, prepare, copy, and teardown lifecycle for the asrc component. Signed-off-by: Liam Girdwood <liam.r.girdwood@linux.intel.com>
Add ZTest unit test validating module creation, configuration, prepare, copy, and teardown lifecycle for the codec component. Signed-off-by: Liam Girdwood <liam.r.girdwood@linux.intel.com>
Add ZTest unit test validating module creation, configuration, prepare, copy, and teardown lifecycle for the copier component. Signed-off-by: Liam Girdwood <liam.r.girdwood@linux.intel.com>
Add ZTest unit test validating module creation, configuration, prepare, copy, and teardown lifecycle for the crossover component. Signed-off-by: Liam Girdwood <liam.r.girdwood@linux.intel.com>
Add ZTest unit test validating module creation, configuration, prepare, copy, and teardown lifecycle for the dcblock component. Signed-off-by: Liam Girdwood <liam.r.girdwood@linux.intel.com>
Add ZTest unit test validating module creation, configuration, prepare, copy, and teardown lifecycle for the google component. Signed-off-by: Liam Girdwood <liam.r.girdwood@linux.intel.com>
Add ZTest unit test validating module creation, configuration, prepare, copy, and teardown lifecycle for the igo_nr component. Signed-off-by: Liam Girdwood <liam.r.girdwood@linux.intel.com>
Add ZTest unit test validating module creation, configuration, prepare, copy, and teardown lifecycle for the level_multiplier component. Signed-off-by: Liam Girdwood <liam.r.girdwood@linux.intel.com>
Add ZTest unit test validating module creation, configuration, prepare, copy, and teardown lifecycle for the mfcc component. Signed-off-by: Liam Girdwood <liam.r.girdwood@linux.intel.com>
Add ZTest unit test validating module creation, configuration, prepare, copy, and teardown lifecycle for the mic_privacy_manager component. Signed-off-by: Liam Girdwood <liam.r.girdwood@linux.intel.com>
Add ZTest unit test validating module creation, configuration, prepare, copy, and teardown lifecycle for the mixin_mixout component. Signed-off-by: Liam Girdwood <liam.r.girdwood@linux.intel.com>
Add ZTest unit test validating module creation, configuration, prepare, copy, and teardown lifecycle for the nxp component. Signed-off-by: Liam Girdwood <liam.r.girdwood@linux.intel.com>
Add ZTest unit test validating module creation, configuration, prepare, copy, and teardown lifecycle for the rtnr component. Signed-off-by: Liam Girdwood <liam.r.girdwood@linux.intel.com>
Add ZTest unit test validating module creation, configuration, prepare, copy, and teardown lifecycle for the smart_amp component. Signed-off-by: Liam Girdwood <liam.r.girdwood@linux.intel.com>
Add ZTest unit test validating module creation, configuration, prepare, copy, and teardown lifecycle for the sound_dose component. Signed-off-by: Liam Girdwood <liam.r.girdwood@linux.intel.com>
Add ZTest unit test validating module creation, configuration, prepare, copy, and teardown lifecycle for the src component. Signed-off-by: Liam Girdwood <liam.r.girdwood@linux.intel.com>
Add ZTest unit test validating module creation, configuration, prepare, copy, and teardown lifecycle for the stft_process component. Signed-off-by: Liam Girdwood <liam.r.girdwood@linux.intel.com>
Add ZTest unit test validating module creation, configuration, prepare, copy, and teardown lifecycle for the tensorflow component. Signed-off-by: Liam Girdwood <liam.r.girdwood@linux.intel.com>
Add ZTest unit test validating module creation, configuration, prepare, copy, and teardown lifecycle for the tone component. Signed-off-by: Liam Girdwood <liam.r.girdwood@linux.intel.com>
Add ZTest unit test validating module creation, configuration, prepare, copy, and teardown lifecycle for the up_down_mixer component. Signed-off-by: Liam Girdwood <liam.r.girdwood@linux.intel.com>
Add ZTest unit test validating module creation, configuration, prepare, copy, and teardown lifecycle for the eq_fir component. Includes passthrough configuration blob for 2-channel operation. Signed-off-by: Liam Girdwood <liam.r.girdwood@linux.intel.com>
There was a problem hiding this comment.
Pull request overview
Note
Copilot was unable to run its full agentic suite in this review.
Adds Zephyr ztest-based unit tests for a range of SOF audio modules, exercising basic lifecycle (create/free) and light configuration/processing paths, plus helper utilities and generated coefficient “blob” infrastructure for modules that require real config payloads.
Changes:
- Added per-module ZTests covering create/free, optional config, and basic processing using a shared buffer helper.
- Added Octave tooling (and shims) to generate and include coefficient/config blobs for blob-dependent modules.
- Added one generated blob header used by EQ FIR tests.
Reviewed changes
Copilot reviewed 28 out of 28 changed files in this pull request and generated 16 comments.
Show a summary per file
| File | Description |
|---|---|
| zephyr/test/audio/test_up_down_mixer.c | Adds ZTests for up/down mixer module create/config/process. |
| zephyr/test/audio/test_tone.c | Adds ZTests for tone module create/config/process/params. |
| zephyr/test/audio/test_tensorflow.c | Adds ZTests for TensorFlow module (guarded by Kconfig). |
| zephyr/test/audio/test_stft_process.c | Adds ZTests for STFT process module create/config/process. |
| zephyr/test/audio/test_src.c | Adds ZTests for SRC module create/config/process/params. |
| zephyr/test/audio/test_sound_dose.c | Adds ZTests for sound dose module (guarded by Kconfig). |
| zephyr/test/audio/test_smart_amp.c | Adds ZTests for smart amp module create/config/process. |
| zephyr/test/audio/test_rtnr.c | Adds ZTests for RTNR module create/config/process. |
| zephyr/test/audio/test_nxp.c | Adds ZTests for NXP EAP module (guarded by Kconfig). |
| zephyr/test/audio/test_mixin_mixout.c | Adds ZTests for mixin/mixout modules; includes note about topology constraints. |
| zephyr/test/audio/test_mic_privacy_manager.c | Adds a placeholder/skip-only test for mic privacy manager feature flag. |
| zephyr/test/audio/test_mfcc.c | Adds ZTests for MFCC module with “real” config struct layout mapping and set_large_config use. |
| zephyr/test/audio/test_level_multiplier.c | Adds ZTests for level multiplier module create/config/process. |
| zephyr/test/audio/test_igo_nr.c | Adds ZTests for IGO NR module (guarded by Kconfig). |
| zephyr/test/audio/test_google.c | Adds ZTests for Google RTC/CTC audio processing modules (guarded by Kconfig). |
| zephyr/test/audio/test_eq_fir.c | Adds ZTests for EQ FIR module including applying a generated passthrough config blob. |
| zephyr/test/audio/test_dcblock.c | Adds ZTests for dcblock module including coeff initialization. |
| zephyr/test/audio/test_crossover.c | Adds ZTests for crossover module with extended base/pin config struct. |
| zephyr/test/audio/test_copier.c | Adds ZTests for copier module create/config/process/params. |
| zephyr/test/audio/test_codec.c | Adds ZTests for passthrough (“codec”) module create/config/process. |
| zephyr/test/audio/test_audio_helper.h | Adds a shared helper for buffer setup, processing, and cleanup in tests. |
| zephyr/test/audio/pkg.m | Adds Octave shim to ignore missing control package. |
| zephyr/test/audio/mag2db.m | Adds mag2db fallback implementation for Octave without control package. |
| zephyr/test/audio/gen_ztest_blobs.m | Adds Octave generator for module config blobs and C header export. |
| zephyr/test/audio/db2mag.m | Adds db2mag fallback implementation for Octave without control package. |
| zephyr/test/audio/blobs/eq_fir_passthrough_2ch.h | Adds generated EQ FIR passthrough blob header used by tests. |
|
|
||
| comp->state = COMP_STATE_PREPARE; | ||
| if (comp->drv->ops.prepare) { | ||
| ret = comp->drv->ops.prepare(comp); | ||
| zassert_equal(ret, 0, "prepare failed: %d", ret); | ||
| } | ||
| comp->state = COMP_STATE_ACTIVE; | ||
|
|
||
| if (comp->drv->ops.copy) { | ||
| ret = comp->drv->ops.copy(comp); | ||
| zassert_true(ret >= 0, "copy failed: %d", ret); | ||
| } | ||
|
|
||
| comp->state = COMP_STATE_READY; |
| if (comp->drv->ops.bind) { | ||
| uint32_t dummy_ipc4_data[8] = {0}; | ||
| struct bind_info binfo; | ||
| memset(&binfo, 0, sizeof(binfo)); | ||
| binfo.ipc4_data = (void *)dummy_ipc4_data; | ||
|
|
||
| binfo.bind_type = COMP_BIND_TYPE_SOURCE; | ||
| binfo.source = audio_buffer_get_source(&source_buf->audio_buffer); | ||
| comp->drv->ops.bind(comp, &binfo); | ||
|
|
||
| binfo.bind_type = COMP_BIND_TYPE_SINK; | ||
| binfo.sink = audio_buffer_get_sink(&sink_buf->audio_buffer); | ||
| comp->drv->ops.bind(comp, &binfo); | ||
| } | ||
|
|
||
| if (comp->drv->ops.params) { | ||
| comp->drv->ops.params(comp, params); | ||
| } |
| init_data.base.audio_fmt.channels_count = 1; | ||
| init_data.base.audio_fmt.sampling_frequency = 16000; | ||
| init_data.base.audio_fmt.depth = 16; | ||
| init_data.base.audio_fmt.valid_bit_depth = 16; | ||
| init_data.base.audio_fmt.interleaving_style = IPC4_CHANNELS_INTERLEAVED; | ||
| init_data.base.ibs = 1024; | ||
| init_data.base.obs = 1024; |
| params.channels = 2; | ||
| params.rate = 48000; | ||
| params.sample_container_bytes = 4; | ||
| params.sample_valid_bytes = 4; |
| init_data.base.audio_fmt.channels_count = 1; | ||
| init_data.base.audio_fmt.sampling_frequency = 16000; | ||
| init_data.base.audio_fmt.depth = 16; | ||
| init_data.base.audio_fmt.valid_bit_depth = 16; | ||
| init_data.base.audio_fmt.interleaving_style = IPC4_CHANNELS_INTERLEAVED; | ||
| init_data.base.ibs = 1024; | ||
| init_data.base.obs = 1024; |
| function gen_ztest_blobs() | ||
|
|
||
| fprintf(1, 'Generating ZTest configuration blobs...\n'); | ||
|
|
||
| blobs_dir = 'blobs'; | ||
| if ~exist(blobs_dir, 'dir') | ||
| mkdir(blobs_dir); | ||
| end | ||
|
|
||
| gen_eq_iir_blob(blobs_dir); | ||
| gen_eq_fir_blob(blobs_dir); | ||
| gen_multiband_drc_blob(blobs_dir); | ||
| gen_tdfb_blob(blobs_dir); | ||
|
|
||
| fprintf(1, 'Done. All blob headers generated in %s/\n', blobs_dir); | ||
| end | ||
|
|
| function gen_ztest_blobs() | ||
|
|
||
| fprintf(1, 'Generating ZTest configuration blobs...\n'); | ||
|
|
||
| blobs_dir = 'blobs'; | ||
| if ~exist(blobs_dir, 'dir') | ||
| mkdir(blobs_dir); | ||
| end | ||
|
|
||
| gen_eq_iir_blob(blobs_dir); | ||
| gen_eq_fir_blob(blobs_dir); | ||
| gen_multiband_drc_blob(blobs_dir); | ||
| gen_tdfb_blob(blobs_dir); | ||
|
|
||
| fprintf(1, 'Done. All blob headers generated in %s/\n', blobs_dir); | ||
| end | ||
|
|
| #if defined(CONFIG_COMP_NXP_EAP) || defined(CONFIG_COMP_NXP_EAP_STUB) | ||
| sys_comp_module_nxp_eap_interface_init(); | ||
| #endif |
|
|
||
| static struct comp_dev *test_nxp_eap_create(void) | ||
| { | ||
| #ifndef CONFIG_COMP_NXP_EAP |
| ZTEST(audio_mic_privacy_manager, test_mic_privacy_manager_init) | ||
| { | ||
| #ifndef CONFIG_INTEL_ADSP_MIC_PRIVACY | ||
| ztest_test_skip(); |
tmleman
left a comment
There was a problem hiding this comment.
I would suggest to focus on porting existing tests as (at least it seemed to me) we agreed in #10110
Personally I think this PR is too big to do a sensible review.
In which workflow can I review the execution results?
Is there any reason why these tests are being added in a different directory than the existing UTs?
softwarecki
left a comment
There was a problem hiding this comment.
In my opinion, this PR exceeds the reasonable review size and has reached a critical mass of changes, making it too large to review
…vars - Match test stream parameters with component creation configurations (16k vs 48k, 16b vs 32b) in sound_dose, rtnr, and tensorflow. - Check return codes of ops.bind and ops.params in test_audio_helper.h. - Add NULL check for sof->ipc in test_tone.c setup and verify set_large_config return code. Signed-off-by: Liam Girdwood <liam.r.girdwood@linux.intel.com>
|
Closing PR to split into smaller, focused PRs per module. |
Very simple UTs for most audio modules that create, destroy, configure and process for each module. Real blobs are used to configure modules that need blobs.