Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
64 changes: 64 additions & 0 deletions test/ztest/unit/audio/selector/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
# SPDX-License-Identifier: BSD-3-Clause
Comment thread
kv2019i marked this conversation as resolved.
Resolved
#
# Copyright(c) 2026 Intel Corporation.

cmake_minimum_required(VERSION 3.20.0)

find_package(Zephyr REQUIRED HINTS $ENV{ZEPHYR_BASE})
project(sof_unit_audio_selector)

set(SOF_ROOT "${PROJECT_SOURCE_DIR}/../../../../../")
set(sof_top_dir ${SOF_ROOT})

include(${SOF_ROOT}/scripts/cmake/misc.cmake)
include(${SOF_ROOT}/scripts/cmake/uuid-registry.cmake)

target_include_directories(app PRIVATE
${SOF_ROOT}/zephyr/include
${SOF_ROOT}/src/include
${SOF_ROOT}/src/kernel/platform/posix/include
${SOF_ROOT}/src/audio
${SOF_ROOT}/tools/rimage/src/include
${PROJECT_BINARY_DIR}/include/generated
)

target_compile_definitions(app PRIVATE
-DCONFIG_ZEPHYR_POSIX=1
-DCONFIG_LIBRARY=1
-DUNIT_TEST=1
)

target_sources(app PRIVATE
selector_ztest.c
selector_test_support.c
${SOF_ROOT}/test/ztest/unit/common/sof_context.c
${SOF_ROOT}/src/audio/selector/selector.c
${SOF_ROOT}/src/audio/selector/selector_generic.c
${SOF_ROOT}/src/audio/module_adapter/module_adapter.c
${SOF_ROOT}/src/audio/module_adapter/module_adapter_ipc4.c
${SOF_ROOT}/src/audio/module_adapter/module/generic.c
${SOF_ROOT}/src/audio/buffers/comp_buffer.c
${SOF_ROOT}/src/audio/buffers/audio_buffer.c
${SOF_ROOT}/src/audio/source_api_helper.c
${SOF_ROOT}/src/audio/sink_api_helper.c
${SOF_ROOT}/src/audio/sink_source_utils.c
${SOF_ROOT}/src/audio/audio_stream.c
${SOF_ROOT}/src/audio/component.c
${SOF_ROOT}/src/audio/data_blob.c
${SOF_ROOT}/src/module/audio/source_api.c
${SOF_ROOT}/src/module/audio/sink_api.c
${SOF_ROOT}/src/ipc/ipc4/helper.c
${SOF_ROOT}/src/ipc/ipc-common.c
${SOF_ROOT}/src/ipc/ipc-helper.c
${SOF_ROOT}/src/lib/objpool.c
${SOF_ROOT}/src/math/numbers.c
)

# The standalone target compiles the full IPC4 helper translation unit while
# linking only its format helpers; other helper paths leave one local ID unused.
set_source_files_properties(
${SOF_ROOT}/src/ipc/ipc4/helper.c
PROPERTIES COMPILE_OPTIONS "-Wno-unused-variable"
)

sof_append_relative_path_definitions(app)
10 changes: 10 additions & 0 deletions test/ztest/unit/audio/selector/prj.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
CONFIG_ZTEST=y
CONFIG_LOG=y
CONFIG_SOF_FULL_ZEPHYR_APPLICATION=n
CONFIG_LIBRARY=y
CONFIG_IPC_MAJOR_4=y
CONFIG_COMP_SEL=y
CONFIG_STATIC_PIPELINE=n
CONFIG_FORMAT_S16LE=y
CONFIG_FORMAT_S24LE=y
CONFIG_FORMAT_S32LE=y
82 changes: 82 additions & 0 deletions test/ztest/unit/audio/selector/selector_test_support.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
// SPDX-License-Identifier: BSD-3-Clause
//
// Copyright(c) 2026 Intel Corporation.

#include <rtos/alloc.h>
#include <stddef.h>
#include <stdint.h>
#include <stdlib.h>

/**
* @brief Allocate aligned runtime memory for the standalone test.
*/
void *rmalloc_align(uint32_t flags, size_t bytes, uint32_t alignment)
{
(void)flags;
(void)alignment;
return malloc(bytes);
}

/**
* @brief Allocate runtime memory for the standalone test.
*/
void *rmalloc(uint32_t flags, size_t bytes)
{
(void)flags;
return malloc(bytes);
}

/**
* @brief Allocate zero-initialized runtime memory for the standalone test.
*/
void *rzalloc(uint32_t flags, size_t bytes)
{
(void)flags;
return calloc(bytes, 1);
}

/**
* @brief Allocate aligned audio-buffer memory for the standalone test.
*/
void *rballoc_align(uint32_t flags, size_t bytes, uint32_t alignment)
{
(void)flags;
(void)alignment;
return malloc(bytes);
}

/**
* @brief Release standalone runtime memory.
*/
void rfree(void *ptr)
{
free(ptr);
}

/**
* @brief Allocate through the test heap abstraction.
*/
void *sof_heap_alloc(struct k_heap *heap, uint32_t flags, size_t bytes, size_t alignment)
{
(void)heap;
(void)flags;
(void)alignment;
return malloc(bytes);
}

/**
* @brief Release memory allocated through the test heap abstraction.
*/
void sof_heap_free(struct k_heap *heap, void *addr)
{
(void)heap;
free(addr);
}

/**
* @brief Return the absent user heap for this standalone test.
*/
struct k_heap *sof_sys_user_heap_get(void)
{
return NULL;
}
Loading
Loading