Skip to content

Commit 322b8f2

Browse files
lgirdwoodlrgirdwo
authored andcommitted
scripts: testbench: check for workspace environment variable
Allow both scripts to be executed from the SOF FW directory or the parent SOF workspace directory using an environment variable or the default SOF workspace. This simplifies usage and opens the way for vscode integration. Signed-off-by: Liam Girdwood <liam.r.girdwood@intel.com>
1 parent 7ed4499 commit 322b8f2

3 files changed

Lines changed: 39 additions & 11 deletions

File tree

.github/workflows/testbench.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,8 @@ on:
3131
jobs:
3232
build-and-test:
3333
runs-on: ubuntu-24.04
34+
env:
35+
SOF_WORKSPACE=$HOME:/work/sof/sof
3436

3537
steps:
3638
- name: Checkout SOF repository (PR source)

scripts/sof-testbench-build-profile.sh

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,18 +9,32 @@ usage() {
99
echo " -h shows this text"
1010
echo " -p <platform> sets platform for scripts/rebuild-testbench.sh"
1111
echo
12+
echo "This script must be run from the sof firmware toplevel or workspace directory"
1213
}
1314

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

17-
if [ -z "${SOF_WORKSPACE}" ]; then
18-
echo "Error: environment variable SOF_WORKSPACE need to be set to top level sof directory"
18+
# This script can be executed from the sof firmware toplevel or workspace directory
19+
# First check for the worksapce environment variable
20+
if [ -z "$SOF_WORKSPACE" ]; then
21+
# Environment variable is empty or unset so use default
22+
BASE_DIR="$HOME/work/sof"
23+
else
24+
# Environment variable exists and has a value
25+
BASE_DIR="$SOF_WORKSPACE"
26+
fi
27+
cd "$BASE_DIR"
28+
29+
# check we are in the workspace directory
30+
if [ ! -d "sof" ]; then
31+
echo "Error: can't find SOF firmware directory. Please check your installation."
1932
exit 1
2033
fi
2134

35+
#set default values
2236
PLATFORM=none
23-
PDIR=$SOF_WORKSPACE/sof/tools/testbench/profile
37+
PDIR=$PWD/sof/tools/testbench/profile
2438

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

4559
# Build
46-
SCRIPTS=$SOF_WORKSPACE/sof/scripts
60+
SCRIPTS=$PWD/sof/scripts
4761
mkdir -p "$PDIR"
4862
"$SCRIPTS"/rebuild-testbench.sh -p "$PLATFORM"
4963
HELPER="$SCRIPTS"/sof-testbench-helper.sh

scripts/sof-testbench-helper.sh

Lines changed: 19 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -29,10 +29,22 @@ usage() {
2929
echo "Example: check component eqiir with valgrind"
3030
echo "$0 -v -m eqiir"
3131
echo
32+
echo This script must be run from the sof firmware toplevel or workspace directory
3233
}
3334

34-
if [ -z "${SOF_WORKSPACE}" ]; then
35-
echo "Error: environment variable SOF_WORKSPACE need to be set to top level sof directory"
35+
# First check for the workspace environment variable
36+
if [ -z "$SOF_WORKSPACE" ]; then
37+
# Environment variable is empty or unset so use default
38+
BASE_DIR="$HOME/work/sof"
39+
else
40+
# Environment variable exists and has a value
41+
BASE_DIR="$SOF_WORKSPACE"
42+
fi
43+
cd "$BASE_DIR"
44+
45+
# check we are in the workspace directory
46+
if [ ! -d "sof" ]; then
47+
echo "Error: can't find SOF firmware directory. Please check your installation."
3648
exit 1
3749
fi
3850

@@ -119,13 +131,13 @@ else
119131
sox --encoding signed-integer "$CLIP" -L -r "$RATE_IN" -c "$CHANNELS_IN" -b "$BITS" "$INFILE1"
120132
fi
121133

122-
TB4="$SOF_WORKSPACE/sof/tools/testbench/build_testbench/install/bin/sof-testbench4"
123-
XTB4="$SOF_WORKSPACE/sof/tools/testbench/build_xt_testbench/sof-testbench4"
124-
XTB4_SETUP="$SOF_WORKSPACE/sof/tools/testbench/build_xt_testbench/xtrun_env.sh"
134+
TB4="$PWD/sof/tools/testbench/build_testbench/install/bin/sof-testbench4"
135+
XTB4="$PWD/sof/tools/testbench/build_xt_testbench/sof-testbench4"
136+
XTB4_SETUP="$PWD/sof/tools/testbench/build_xt_testbench/xtrun_env.sh"
125137
if [ -z "$TPLG0" ]; then
126-
TPLG="$SOF_WORKSPACE/sof/tools/build_tools/topology/topology2/development/sof-hda-benchmark-${MODULE}${BITS}.tplg"
138+
TPLG="$PWD/sof/tools/build_tools/topology/topology2/development/sof-hda-benchmark-${MODULE}${BITS}.tplg"
127139
else
128-
TPLG="$SOF_WORKSPACE/sof/tools/build_tools/topology/topology2/$TPLG0"
140+
TPLG="$PWD/sof/tools/build_tools/topology/topology2/$TPLG0"
129141
fi
130142
FMT="S${BITS}_LE"
131143
OPTS="-r $RATE_IN -R $RATE_OUT -c $CHANNELS_IN -c $CHANNELS_OUT -b $FMT -p $PIPELINES -t $TPLG -i $INFILE1 -o $OUTFILE1"

0 commit comments

Comments
 (0)