Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tools: Testbench: Switch testbench to IPC4 mode #9590

Merged
merged 1 commit into from
Oct 28, 2024
Merged
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
11 changes: 8 additions & 3 deletions .github/workflows/testbench.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,16 +37,21 @@ jobs:
- uses: actions/checkout@v4
with: {fetch-depth: 0, filter: 'tree:0'}

- name: docker
run: docker pull thesofproject/sof && docker tag thesofproject/sof sof

- name: apt get
run: sudo apt-get update &&
sudo apt-get -y install valgrind alsa-utils libasound2-dev ninja-build
octave octave-io octave-signal
octave octave-signal

# testbench needs some topologies.
- name: build test topologies
run: ./scripts/build-tools.sh -t ||
run: CMAKE_BUILD_TYPE=Release ./scripts/docker-run.sh
./scripts/build-tools.sh -Y ||
VERBOSE=1 NO_PROCESSORS=1 USE_XARGS=no
./scripts/build-tools.sh -t
CMAKE_BUILD_TYPE=Release ./scripts/docker-run.sh
./scripts/build-tools.sh -Y

- name: build testbench
run: ./scripts/rebuild-testbench.sh ||
Expand Down
18 changes: 9 additions & 9 deletions scripts/host-testbench.sh
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ function die() {
}

process_test_cmd() {
octave -q --eval "pkg load signal io; [n_fail]=process_test('$1', $2, $3, $4, $5);exit(n_fail)"
octave -q --eval "pkg load signal; [n_fail]=process_test('$1', $2, $3, $4, $5);exit(n_fail)"
}

# function test_component()
Expand Down Expand Up @@ -86,17 +86,17 @@ head -c ${INPUT_FILE_SIZE} < /dev/zero > zeros_in.raw
FullTest=${FullTest:-0}

# test with volume
test_component volume 16 16 48000 "$FullTest"
test_component volume 24 24 48000 "$FullTest"
test_component volume 32 32 48000 "$FullTest"
test_component gain 16 16 48000 "$FullTest"
test_component gain 24 24 48000 "$FullTest"
test_component gain 32 32 48000 "$FullTest"

# test with eq-iir
test_component eq-iir 16 16 48000 "$FullTest"
test_component eq-iir 24 24 48000 "$FullTest"
test_component eq-iir 32 32 48000 "$FullTest"
test_component eqiir 16 16 48000 "$FullTest"
test_component eqiir 24 24 48000 "$FullTest"
test_component eqiir 32 32 48000 "$FullTest"

# test with eq-fir
test_component eq-fir 32 32 48000 "$FullTest"
test_component eqfir 32 32 48000 "$FullTest"

# test with dcblock
test_component dcblock 32 32 48000 "$FullTest"
Expand All @@ -105,7 +105,7 @@ test_component dcblock 32 32 48000 "$FullTest"
test_component drc 32 32 48000 "$FullTest"

# test with multiband-drc
test_component multiband-drc 32 32 48000 "$FullTest"
test_component drc_multiband 32 32 48000 "$FullTest"

# test with src
test_component src 24 24 48000 "$FullTest"
Expand Down
2 changes: 1 addition & 1 deletion scripts/rebuild-testbench.sh
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ export_xtensa_setup()
{
export_dir=$TESTBENCH_DIR/$BUILD_DIR_NAME
export_script=$export_dir/xtrun_env.sh
xtbench=$export_dir/testbench
xtbench=$export_dir/sof-testbench4
xtbench_run="XTENSA_CORE=$XTENSA_CORE \$XTENSA_TOOLS_ROOT/$install_bin/xt-run $xtbench"
cat <<EOFSETUP > "$export_script"
export XTENSA_TOOLS_ROOT=$XTENSA_TOOLS_ROOT
Expand Down
4 changes: 2 additions & 2 deletions src/arch/host/configs/library_defconfig
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ CONFIG_COMP_VOLUME=y
CONFIG_COMP_VOLUME_LINEAR_RAMP=y
CONFIG_COMP_VOLUME_WINDOWS_FADE=y
CONFIG_DEBUG_MEMORY_USAGE_SCAN=n
CONFIG_IPC_MAJOR_3=y
CONFIG_IPC_MAJOR_4=n
CONFIG_IPC_MAJOR_3=n
CONFIG_IPC_MAJOR_4=y
CONFIG_LIBRARY=y
CONFIG_LIBRARY_STATIC=y
CONFIG_MATH_IIR_DF2T=y
Expand Down
26 changes: 20 additions & 6 deletions tools/test/audio/comp_run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ Where volume_config.sh could be e.g. next. Minimal configuration need is only
the COMP line.

# Volume component configuration
COMP=volume
COMP=gain
DIRECTION=playback
BITS_IN=16
BITS_OUT=16
Expand All @@ -29,6 +29,7 @@ FN_OUT=output.raw
FN_TRACE:=trace.txt # This is default value if FN_TRACE is not set via -e option
VALGRIND=true
XTRUN=
TESTBENCH=sof-testbench4
EOFHELP
}

Expand All @@ -48,6 +49,7 @@ parse_args ()
FN_TRACE=
EXTRA_OPTS=
XTRUN=
TESTBENCH=sof-testbench4

while getopts ":he:t:" opt; do
case "${opt}" in
Expand Down Expand Up @@ -134,10 +136,10 @@ TPLG_DIR=../../build_tools/test/topology

# Testbench path and executable
if [[ -z $XTRUN ]]; then
TESTBENCH=../../testbench/build_testbench/install/bin/testbench
PATH_TESTBENCH=../../testbench/build_testbench/install/bin/$TESTBENCH
else
BUILD_DIR=../../testbench/build_xt_testbench
TESTBENCH="$BUILD_DIR"/testbench
PATH_TESTBENCH="$BUILD_DIR"/$TESTBENCH
source "$BUILD_DIR"/xtrun_env.sh
XTRUN_CMD=$XTENSA_PATH/$XTRUN
if $VALGRIND; then
Expand All @@ -152,17 +154,29 @@ else
VALGRIND_CMD=
fi

HOST_EXE="$XTRUN_CMD $TESTBENCH"
HOST_EXE="$XTRUN_CMD $PATH_TESTBENCH"

# Use topology from component test topologies
INFMT=s${BITS_IN}le
OUTFMT=s${BITS_OUT}le
TPLGFN=test-${DIRECTION}-ssp5-mclk-0-I2S-${COMP}-${INFMT}-${OUTFMT}-48k-24576k-codec.tplg
TPLG_BUILD_TIP="Please run scripts/build-tools.sh -t"
PIPELINES=

[[ $TESTBENCH == "sof-testbench4" ]] && {
# With comp benchmark topologies for playback use pipelines 1-2, for capture 3-4
[[ $DIRECTION == "playback" ]] && PIPELINES="-p 1,2"
[[ $DIRECTION == "capture" ]] && PIPELINES="-p 3,4"
TPLGFN=sof-hda-benchmark-${COMP}${BITS_IN}.tplg
TPLG_DIR="../../build_tools/topology/topology2/development"
TPLG_BUILD_TIP="Please run scripts/build-tools.sh"
}

TPLG=${TPLG_DIR}/${TPLGFN}
[ -f "$TPLG" ] || {
echo
echo "Error: topology $TPLG does not exist."
echo "Please run scripts/build-tools.sh -t"
echo "$TPLG_BUILD_TIP"
exit 1
}

Expand All @@ -174,7 +188,7 @@ else
fi

# Run command
OPTS="$DEBUG -r $FS_IN -R $FS_OUT -c $CHANNELS_IN -n $CHANNELS_OUT $BINFMT -t $TPLG"
OPTS="$DEBUG -r $FS_IN -R $FS_OUT -c $CHANNELS_IN -n $CHANNELS_OUT $BINFMT $PIPELINES -t $TPLG"
DATA="-i $FN_IN -o $FN_OUT"
ARG="$OPTS $EXTRA_OPTS $DATA"
CMD="$HOST_EXE $ARG"
Expand Down
42 changes: 26 additions & 16 deletions tools/testbench/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,17 @@ include(CheckCCompilerFlag)

set(default_asoc_h "/usr/include/alsa/sound/uapi/asoc.h")

add_executable(testbench
file(READ "../../src/arch/host/configs/library_defconfig" library_defconfig)

if(library_defconfig MATCHES "CONFIG_IPC_MAJOR_4=y")
message("-- Selected IPC4 build for testbench")
set(testbench "sof-testbench4")
else()
message("-- Selected IPC3 build for testbench")
set(testbench "sof-testbench3")
endif()

add_executable(${testbench}
testbench.c
file.c
utils.c
Expand All @@ -19,37 +29,37 @@ add_executable(testbench
topology_ipc4.c
)

sof_append_relative_path_definitions(testbench)
sof_append_relative_path_definitions(${testbench})

target_include_directories(testbench PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include)
target_include_directories(${testbench} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include)

set(sof_source_directory "${PROJECT_SOURCE_DIR}/../..")
set(sof_install_directory "${PROJECT_BINARY_DIR}/sof_ep/install")
set(sof_binary_directory "${PROJECT_BINARY_DIR}/sof_ep/build")

set(config_h ${sof_binary_directory}/library_autoconfig.h)

target_include_directories(testbench PRIVATE "${sof_source_directory}/src/platform/library/include")
target_include_directories(testbench PRIVATE "${sof_source_directory}/src/audio")
target_include_directories(${testbench} PRIVATE "${sof_source_directory}/src/platform/library/include")
target_include_directories(${testbench} PRIVATE "${sof_source_directory}/src/audio")

# Configuration time, make copy
configure_file(${default_asoc_h} ${CMAKE_CURRENT_BINARY_DIR}/include/alsa/sound/asoc.h)

# Build time
target_include_directories(testbench PRIVATE "${CMAKE_CURRENT_BINARY_DIR}/include")
target_include_directories(${testbench} PRIVATE "${CMAKE_CURRENT_BINARY_DIR}/include")

# -Wimplicit-fallthrough is preferred, check if it's supported
check_c_compiler_flag(-Wimplicit-fallthrough supports_implicit_fallthrough)
if (supports_implicit_fallthrough)
set(implicit_fallthrough -Wimplicit-fallthrough)
endif()

target_compile_options(testbench PRIVATE -g -O3 -Wall -Werror -Wmissing-prototypes
target_compile_options(${testbench} PRIVATE -g -O3 -Wall -Werror -Wmissing-prototypes
${implicit_fallthrough} -DCONFIG_LIBRARY -DCONFIG_LIBRARY_STATIC -imacros${config_h})

target_link_libraries(testbench PRIVATE -lm)
target_link_libraries(${testbench} PRIVATE -lm)

install(TARGETS testbench DESTINATION bin)
install(TARGETS ${testbench} DESTINATION bin)

include(ExternalProject)

Expand Down Expand Up @@ -94,14 +104,14 @@ add_library(sof_parser_lib STATIC IMPORTED)
set_target_properties(sof_parser_lib PROPERTIES IMPORTED_LOCATION "${parser_install_dir}/lib/libsof_tplg_parser.a")
add_dependencies(sof_parser_lib parser_ep)

add_dependencies(testbench sof_parser_lib)
target_link_libraries(testbench PRIVATE sof_library)
target_link_libraries(testbench PRIVATE sof_parser_lib)
target_link_libraries(testbench PRIVATE m)
target_include_directories(testbench PRIVATE ${sof_install_directory}/include)
target_include_directories(testbench PRIVATE ${parser_install_dir}/include)
add_dependencies(${testbench} sof_parser_lib)
target_link_libraries(${testbench} PRIVATE sof_library)
target_link_libraries(${testbench} PRIVATE sof_parser_lib)
target_link_libraries(${testbench} PRIVATE m)
target_include_directories(${testbench} PRIVATE ${sof_install_directory}/include)
target_include_directories(${testbench} PRIVATE ${parser_install_dir}/include)

set_target_properties(testbench
set_target_properties(${testbench}
PROPERTIES
INSTALL_RPATH "${sof_install_directory}/lib"
INSTALL_RPATH_USE_LINK_PATH TRUE
Expand Down
Loading