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
2 changes: 2 additions & 0 deletions .github/workflows/testbench.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ on:
jobs:
build-and-test:
runs-on: ubuntu-24.04
env:
SOF_WORKSPACE=$HOME:/work/sof/sof

steps:
- name: Checkout SOF repository (PR source)
Expand Down
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,6 @@ tools/test/audio/zeros_in.raw
__pycache__
.checkpatch-camelcase.git.*

build*/

# Eclipse project metadata
.settings
Expand Down
18 changes: 15 additions & 3 deletions scripts/build-tools.sh
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ Attention: the list of selected shortcuts below is _not_ exhaustive. To
build _everything_ don't select any particular target; this will build
CMake's default target "ALL".

usage: $0 [-c|-f|-h|-l|-p|-t|-T|-X|-Y|-A]
usage: $0 [-c|-f|-h|-l|-p|-t|-T|-X|-Y|-A|-d]
-h Display help

-c Rebuild ctl/
Expand All @@ -27,6 +27,7 @@ usage: $0 [-c|-f|-h|-l|-p|-t|-T|-X|-Y|-A]
-Y Rebuild topology2 only
-t Rebuild test/topology/ (or tools/test/topology/tplg-build.sh directly)
-A Clone and rebuild local ALSA lib and utils.
-d Deployment build

-C No build, only CMake re-configuration. Shows CMake targets.
EOFUSAGE
Expand Down Expand Up @@ -98,8 +99,9 @@ main()
CMAKE_ONLY BUILD_ALL
SCRIPT_DIR=$(cd "$(dirname "$0")" && pwd)
SOF_REPO=$(dirname "$SCRIPT_DIR")
: "${BUILD_TOOLS_DIR:=$SOF_REPO/tools/build_tools}"
: "${BUILD_TOOLS_DIR:=$SOF_REPO/../build-tools-tplg}"
: "${NO_PROCESSORS:=$(nproc)}"
DEPLOY_DIR="$SOF_REPO/../build-sof-staging"
BUILD_ALL=false

if [ $# -eq 0 ]; then
Expand All @@ -113,14 +115,15 @@ main()
DO_BUILD_tests=false
DO_BUILD_topologies1=false
DO_BUILD_topologies2=false
DO_DEPLOYMENT=false
CMAKE_ONLY=false

# better safe than sorry
local warn_incremental_build=true

# eval is a sometimes necessary evil
# shellcheck disable=SC2034
while getopts "cfhlptTCXYA" OPTION; do
while getopts "cfhlptTCXYAd" OPTION; do
case "$OPTION" in
c) DO_BUILD_ctl=true ;;
l) DO_BUILD_logger=true ;;
Expand All @@ -131,6 +134,7 @@ main()
Y) DO_BUILD_topologies2=true ;;
C) CMAKE_ONLY=true ;;
A) DO_BUILD_alsa=true ;;
d) DO_DEPLOYMENT=true ;;
h) print_usage; exit 1;;
*) print_usage; exit 1;;
esac
Expand Down Expand Up @@ -174,6 +178,14 @@ main()
fi
done

if "$DO_DEPLOYMENT"; then
# copy Intel topology2 files to output directory
# This will need updated when other uses topology2
cp -ap "$BUILD_TOOLS_DIR"/topology/topology2/production/*.tplg \
$DEPLOY_DIR/lib/firmware/intel/sof-ipc4-tplg/
echo "Deployment build done"
fi

warn_if_incremental_build
}

Expand Down
32 changes: 24 additions & 8 deletions scripts/rebuild-testbench.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,32 @@
# stop on most errors
set -e

SCRIPT_DIR=$(cd "$(dirname "$0")" && pwd)
SOF_REPO=$(dirname "$SCRIPT_DIR")
TESTBENCH_DIR="$SOF_REPO"/tools/testbench
# This script can be executed from the sof firmware toplevel or workspace directory
# First check for the worksapce environment variable
if [ -z "$SOF_WORKSPACE" ]; then
# Environment variable is empty or unset so use default
BASE_DIR="$HOME/work/sof"
else
# Environment variable exists and has a value
BASE_DIR="$SOF_WORKSPACE"
fi
cd "$BASE_DIR"

# check we are in the workspace directory
if [ ! -d "sof" ]; then
echo "Error: can't find SOF firmware directory. Please check your installation."
exit 1
fi

TESTBENCH_DIR=$BASE_DIR/sof/tools/testbench

# Defaults
BUILD_BACKEND='make'
BUILD_TYPE=native
BUILD_DIR_NAME=build_testbench
BUILD_DIR_NAME=$BASE_DIR/build_testbench
BUILD_TARGET=install
: "${SOF_AFL:=$HOME/sof/work/AFL/afl-gcc}"
SCRIPT_DIR=$BASE_DIR/sof/scripts

print_usage()
{
Expand Down Expand Up @@ -59,7 +75,7 @@ setup_xtensa_tools_build()
{
BUILD_TYPE=xt
BUILD_TARGET=
BUILD_DIR_NAME=build_xt_testbench
BUILD_DIR_NAME=$BASE_DIR/build_xt_testbench

# check needed environment variables
test -n "${XTENSA_TOOLS_ROOT}" || die "XTENSA_TOOLS_ROOT need to be set.\n"
Expand Down Expand Up @@ -90,7 +106,7 @@ setup_xtensa_tools_build()

export_xtensa_setup()
{
export_dir=$TESTBENCH_DIR/$BUILD_DIR_NAME
export_dir=$BUILD_DIR_NAME
export_script=$export_dir/xtrun_env.sh
xtbench=$export_dir/sof-testbench4
xtbench_run="XTENSA_CORE=$XTENSA_CORE \$XTENSA_TOOLS_ROOT/$install_bin/xt-run $xtbench"
Expand All @@ -114,14 +130,14 @@ Success!

For temporary, interactive Kconfiguration use:

$BUILD_BACKEND -C $TESTBENCH_DIR/$BUILD_DIR_NAME/sof_ep/build/ menuconfig
$BUILD_BACKEND -C $BUILD_DIR_NAME/sof_ep/build/ menuconfig

Permanent configuration is "src/arch/host/configs/library_defconfig".

For instant, incremental build:

$src_env_msg
$BUILD_BACKEND -C $TESTBENCH_DIR/$BUILD_DIR_NAME/ -j$(nproc)
$BUILD_BACKEND -C $BUILD_DIR_NAME/ -j$(nproc)

EOF0

Expand Down
22 changes: 18 additions & 4 deletions scripts/sof-testbench-build-profile.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,18 +9,32 @@ usage() {
echo " -h shows this text"
echo " -p <platform> sets platform for scripts/rebuild-testbench.sh"
echo
echo "This script must be run from the sof firmware toplevel or workspace directory"
}

MODULES_S32="asrc dcblock drc drc_multiband eqfir eqiir gain src tdfb"
MODULES_S24="aria"

if [ -z "${SOF_WORKSPACE}" ]; then
echo "Error: environment variable SOF_WORKSPACE need to be set to top level sof directory"
# This script can be executed from the sof firmware toplevel or workspace directory
# First check for the worksapce environment variable
if [ -z "$SOF_WORKSPACE" ]; then
# Environment variable is empty or unset so use default
BASE_DIR="$HOME/work/sof"
else
# Environment variable exists and has a value
BASE_DIR="$SOF_WORKSPACE"
fi
cd "$BASE_DIR"
Copy link
Collaborator

Choose a reason for hiding this comment

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

cannot we use something like

SCRIPTS_DIR=$(dirname "${BASH_SOURCE[0]}")
SOF_DIR=$SCRIPTS_DIR/../

like other SOF scripts do to avoid guessing?

Copy link
Member Author

Choose a reason for hiding this comment

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

So we have a bit of complexity today as CI has some hard coded rules (with config outside this repo). Long term trying to move to an environment variable where the scripts could be executed in any directory under SOF_WORKSPACE.
I do like this idea, will make the change.


# check we are in the workspace directory
if [ ! -d "sof" ]; then
echo "Error: can't find SOF firmware directory. Please check your installation."
exit 1
fi

#set default values
PLATFORM=none
PDIR=$SOF_WORKSPACE/sof/tools/testbench/profile
PDIR=$PWD/testbench/profile

while getopts "hp:d:" opt; do
case "${opt}" in
Expand All @@ -43,7 +57,7 @@ done
shift $((OPTIND-1))

# Build
SCRIPTS=$SOF_WORKSPACE/sof/scripts
SCRIPTS=$PWD/sof/scripts
mkdir -p "$PDIR"
"$SCRIPTS"/rebuild-testbench.sh -p "$PLATFORM"
HELPER="$SCRIPTS"/sof-testbench-helper.sh
Expand Down
70 changes: 45 additions & 25 deletions scripts/sof-testbench-helper.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,9 @@ usage() {
echo " -c <channels>, default 2"
echo " -h shows this text"
echo " -i <input wav>, default /usr/share/sounds/alsa/Front_Center.wav"
echo " -k keep temporary files in /tmp"
echo " -k keep temporary files in data directory"
echo " -m <module>, default gain"
echo " -n <pipelines>, default 1,2"
echo " -o <output wav>, default none"
echo " -p <profiling result text>, use with -x, default none"
echo " -r <rate>, default 48000"
echo " -t <force topology>, default none, e.g. production/sof-hda-generic.tplg"
Expand All @@ -29,14 +28,25 @@ usage() {
echo "Example: check component eqiir with valgrind"
echo "$0 -v -m eqiir"
echo
echo This script must be run from the sof firmware toplevel or workspace directory
}

if [ -z "${SOF_WORKSPACE}" ]; then
echo "Error: environment variable SOF_WORKSPACE need to be set to top level sof directory"
# First check for the workspace environment variable
if [ -z "$SOF_WORKSPACE" ]; then
# Environment variable is empty or unset so use default
BASE_DIR="$HOME/work/sof"
else
# Environment variable exists and has a value
BASE_DIR="$SOF_WORKSPACE"
fi
cd "$BASE_DIR"

# check we are in the workspace directory
if [ ! -d "sof" ]; then
echo "Error: can't find SOF firmware directory. Please check your installation."
exit 1
fi

OUTWAV=
CLIP=/usr/share/sounds/alsa/Front_Center.wav
MODULE=gain
BITS=32
Expand All @@ -45,10 +55,6 @@ RATE_OUT=48000
CHANNELS_IN=2
CHANNELS_OUT=2
PIPELINES="1,2"
INFILE1=$(mktemp --tmpdir=/tmp in-XXXX.raw)
OUTFILE1=$(mktemp --tmpdir=/tmp out-XXXX.raw)
TRACEFILE=$(mktemp --tmpdir=/tmp trace-XXXX.txt)
PROFILEOUT=$(mktemp --tmpdir=/tmp profile-XXXX.out)
KEEP_TMP=false
XTRUN=false
PROFILE=false
Expand All @@ -71,7 +77,7 @@ while getopts "b:c:hi:km:n:o:p:r:t:vx" opt; do
i)
CLIP=${OPTARG}
;;
k)
k)
KEEP_TMP=true
;;
m)
Expand All @@ -97,7 +103,7 @@ while getopts "b:c:hi:km:n:o:p:r:t:vx" opt; do
v)
VALGRIND=valgrind
;;
x)
x)
XTRUN=true
;;
*)
Expand All @@ -108,6 +114,19 @@ while getopts "b:c:hi:km:n:o:p:r:t:vx" opt; do
done
shift $((OPTIND-1))

# Get the current date and time in a specific format (YYYYMMDD_HHMMSS)
timestamp=$(date +"%Y%m%d_%H%M%S")

# Combine the prefix and timestamp to create the filename
INFILE1="$PWD/testbench_data/in-${MODULE}-${timestamp}.raw"
OUTFILE1="$PWD/testbench_data/out-${MODULE}-${timestamp}.raw"
TRACEFILE="$PWD/testbench_data/trace-${MODULE}-${timestamp}.txt"
PROFILEOUT="$PWD/testbench_data/profile-${MODULE}-${timestamp}.out"
OUTWAV="$PWD/testbench_data/outwav-${MODULE}-${timestamp}.wav"

# make the data directory if it doesn't exist
mkdir -p $PWD/testbench_data

echo Converting clip "$CLIP" to raw input
if [[ "$BITS" == "24" ]]; then
# Sox does not support S24_4LE format
Expand All @@ -118,14 +137,14 @@ if [[ "$BITS" == "24" ]]; then
else
sox --encoding signed-integer "$CLIP" -L -r "$RATE_IN" -c "$CHANNELS_IN" -b "$BITS" "$INFILE1"
fi

TB4="$SOF_WORKSPACE/sof/tools/testbench/build_testbench/install/bin/sof-testbench4"
XTB4="$SOF_WORKSPACE/sof/tools/testbench/build_xt_testbench/sof-testbench4"
XTB4_SETUP="$SOF_WORKSPACE/sof/tools/testbench/build_xt_testbench/xtrun_env.sh"
TOOLSDIR="$PWD/build_tools/testbench"
TB4="$PWD/build-testbench/install/bin/sof-testbench4"
XTB4="$PWD/build-xt-testbench/sof-testbench4"
XTB4_SETUP="$PWD/build-xt-testbench/xtrun_env.sh"
if [ -z "$TPLG0" ]; then
TPLG="$SOF_WORKSPACE/sof/tools/build_tools/topology/topology2/development/sof-hda-benchmark-${MODULE}${BITS}.tplg"
TPLG="$PWD/build_tools/topology/topology2/development/sof-hda-benchmark-${MODULE}${BITS}.tplg"
else
TPLG="$SOF_WORKSPACE/sof/tools/build_tools/topology/topology2/$TPLG0"
TPLG="$PWD/build_tools/topology/topology2/$TPLG0"
fi
FMT="S${BITS}_LE"
OPTS="-r $RATE_IN -R $RATE_OUT -c $CHANNELS_IN -c $CHANNELS_OUT -b $FMT -p $PIPELINES -t $TPLG -i $INFILE1 -o $OUTFILE1"
Expand Down Expand Up @@ -169,16 +188,17 @@ else
fi
fi

if [ -n "$OUTWAV" ]; then
# Generate the outwav if we are keeping our data files for inspection.
if [[ "$KEEP_TMP" == false ]]; then
echo Deleting temporary files
rm -f "$INFILE1" "$OUTFILE1" "$TRACEFILE" "$PROFILEOUT"
else
echo Converting raw output to "$OUTWAV"
if [[ "$BITS" == "24" ]]; then
sox --encoding signed-integer -L -r "$RATE_OUT" -c "$CHANNELS_OUT" -b 32 "$OUTFILE1" "$OUTWAV" vol 256
sox --encoding signed-integer -L -r "$RATE_OUT" -c "$CHANNELS_OUT" -b 32 \
"$OUTFILE1" "$OUTWAV" vol 256
else
sox --encoding signed-integer -L -r "$RATE_OUT" -c "$CHANNELS_OUT" -b "$BITS" "$OUTFILE1" "$OUTWAV"
sox --encoding signed-integer -L -r "$RATE_OUT" -c "$CHANNELS_OUT" -b "$BITS" \
"$OUTFILE1" "$OUTWAV"
fi
fi

if [[ "$KEEP_TMP" == false ]]; then
echo Deleting temporary files
rm -f "$INFILE1" "$OUTFILE1" "$TRACEFILE" "$PROFILEOUT"
fi
8 changes: 4 additions & 4 deletions tools/test/audio/comp_run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -132,13 +132,13 @@ run_testbench ()
parse_args "$@"

# Path to topologies
TPLG_DIR=../../build_tools/test/topology
TPLG_DIR=../../../../build_tools/test/topology

# Testbench path and executable
if [[ -z $XTRUN ]]; then
PATH_TESTBENCH=../../testbench/build_testbench/install/bin/$TESTBENCH
PATH_TESTBENCH=../../../../build_testbench/install/bin/$TESTBENCH
else
BUILD_DIR=../../testbench/build_xt_testbench
BUILD_DIR=../../../../build_xt_testbench
PATH_TESTBENCH="$BUILD_DIR"/$TESTBENCH
source "$BUILD_DIR"/xtrun_env.sh
XTRUN_CMD=$XTENSA_PATH/$XTRUN
Expand Down Expand Up @@ -168,7 +168,7 @@ PIPELINES=
[[ $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_DIR="../../../../build_tools/topology/topology2/development"
TPLG_BUILD_TIP="Please run scripts/build-tools.sh"
}

Expand Down
Loading