Skip to content

Commit

Permalink
scripts: testbench: move test files outside of source directory
Browse files Browse the repository at this point in the history
Move the test data files outside of the source directory and add
more context to their names for easier lookup. Do the same with
the outfile and generate it if we keep the temporary files.

Signed-off-by: Liam Girdwood <liam.r.girdwood@intel.com>
  • Loading branch information
lgirdwood authored and lrgirdwo committed Mar 5, 2025
1 parent feded0f commit a4b62b7
Showing 1 changed file with 23 additions and 15 deletions.
38 changes: 23 additions & 15 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 Down Expand Up @@ -44,7 +43,6 @@ if [ ! -d "sof" ]; then
exit 1
fi

OUTWAV=
CLIP=/usr/share/sounds/alsa/Front_Center.wav
MODULE=gain
BITS=32
Expand All @@ -53,10 +51,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 Down Expand Up @@ -116,6 +110,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 Down Expand Up @@ -177,16 +184,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

0 comments on commit a4b62b7

Please sign in to comment.