Skip to content

test: audio: port buffer CMocka tests to ztest - #11488

Open
tmleman wants to merge 1 commit into
thesofproject:mainfrom
tmleman:topic/upstream/pr/ut/ztest/audio/buffer
Open

tmleman wants to merge 1 commit into
thesofproject:mainfrom
tmleman:topic/upstream/pr/ut/ztest/audio/buffer

Conversation

@tmleman

@tmleman tmleman commented Nov 18, 2026

Copy link
Copy Markdown
Contributor

Add a ztest suite for the component buffer, merging the four CMocka buffer tests into one suite of nine cases: allocation, a write and read back, filling a buffer completely, wrap around on overwrite, and the five copy size and over/underrun cases.

The CMocka builds link twenty one SOF sources and two mock files each. Only eleven sources are actually needed here, so the pipeline, component and IPC3 topology code are dropped along with the notifier mocks. The repeated buffer allocation and empty buffer checks are factored into two helpers.

Buffers allocated with a NULL mod_alloc_ctx come from the SOF heap rather than the module allocator, so the suite needs no allocator hook. With the heap routed to the host malloc(), LSan covers the frees instead.

Assisted-by: Copilot:claude-opus-5

Copilot AI balanced review requested due to automatic review settings November 18, 2026 15:13

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.

🟡 Changes recommended

The audio buffer test target is missing ${SOF_ROOT}/src/platform/posix/include, causing compilation to fail before tests run when CONFIG_SOF_FULL_ZEPHYR_APPLICATION=n.

1 open issue
What changed in this PR

Adds a native_sim ztest suite for SOF component buffers, consolidating coverage from four CMocka test files with fewer linked dependencies.

Changes:

  • Adds nine cases covering allocation, read/write behavior, full buffers, overwrite wrapping, and copy limits.
  • Shares allocation and empty-buffer assertion helpers and links eleven SOF sources.
  • Routes buffer allocations through the host heap for sanitizer visibility.
File Description
test/​ztest/​unit/​audio/​buffer/​testcase.yaml Registers the buffer suite for native_sim.
test/​ztest/​unit/​audio/​buffer/​test_buffer_ztest.c Implements nine buffer tests and shared helpers.
test/​ztest/​unit/​audio/​buffer/​prj.conf Enables ztest and host-heap allocation.
test/​ztest/​unit/​audio/​buffer/​CMakeLists.txt Defines the test target, source dependencies, and sanitizer stack options.

Review effort: Balanced

target_include_directories(app PRIVATE
${SOF_ROOT}/zephyr/include
${SOF_ROOT}/src/include
${SOF_ROOT}/src/kernel/platform/posix/include
@intel-sofci

Copy link
Copy Markdown

PR 11488: test results

Run date: 2026-11-18 15:44 UTC

Tested commit: fe585630d7721f18da92da4e0c12cb30acd2df5e

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

Add a ztest suite for the component buffer, merging the four CMocka
buffer tests into one suite of nine cases: allocation, a write and read
back, filling a buffer completely, wrap around on overwrite, and the five
copy size and over/underrun cases.

The CMocka builds link twenty one SOF sources and two mock files each.
Only eleven sources are actually needed here, so the pipeline, component
and IPC3 topology code are dropped along with the notifier mocks. The
repeated buffer allocation and empty buffer checks are factored into two
helpers.

Buffers allocated with a NULL mod_alloc_ctx come from the SOF heap rather
than the module allocator, so the suite needs no allocator hook. With the
heap routed to the host malloc(), LSan covers the frees instead.

Assisted-by: Copilot:claude-opus-5
Signed-off-by: Tomasz Leman <[email protected]>
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