Skip to content

Audio Module UTs using ztest.#10751

Open
lgirdwood wants to merge 23 commits intothesofproject:mainfrom
lgirdwood:topic/audioztest2
Open

Audio Module UTs using ztest.#10751
lgirdwood wants to merge 23 commits intothesofproject:mainfrom
lgirdwood:topic/audioztest2

Conversation

@lgirdwood
Copy link
Copy Markdown
Member

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.

lrgirdwo added 23 commits May 6, 2026 20:11
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>
Copilot AI review requested due to automatic review settings May 7, 2026 19:38
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

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.

Comment on lines +72 to +85

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;
Comment on lines +34 to +51
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);
}
Comment on lines +61 to +67
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;
Comment on lines +125 to +128
params.channels = 2;
params.rate = 48000;
params.sample_container_bytes = 4;
params.sample_valid_bytes = 4;
Comment on lines +58 to +64
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;
Comment on lines +13 to +29
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

Comment on lines +13 to +29
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

Comment on lines +35 to +37
#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();
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