Skip to content

Commit b3a3123

Browse files
lgirdwoodlrgirdwo
authored andcommitted
scripts: testbench: move test files outside of source directory
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>
1 parent 1b4fdf3 commit b3a3123

1 file changed

Lines changed: 23 additions & 15 deletions

File tree

scripts/sof-testbench-helper.sh

Lines changed: 23 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,9 @@ usage() {
1010
echo " -c <channels>, default 2"
1111
echo " -h shows this text"
1212
echo " -i <input wav>, default /usr/share/sounds/alsa/Front_Center.wav"
13-
echo " -k keep temporary files in /tmp"
13+
echo " -k keep temporary files in data directory"
1414
echo " -m <module>, default gain"
1515
echo " -n <pipelines>, default 1,2"
16-
echo " -o <output wav>, default none"
1716
echo " -p <profiling result text>, use with -x, default none"
1817
echo " -r <rate>, input rate, default 48000"
1918
echo " -R <rate>, output rate, default 48000"
@@ -49,7 +48,6 @@ if [ ! -d "sof" ]; then
4948
exit 1
5049
fi
5150

52-
OUTWAV=
5351
CLIP=/usr/share/sounds/alsa/Front_Center.wav
5452
MODULE=gain
5553
BITS=32
@@ -58,10 +56,6 @@ RATE_OUT=48000
5856
CHANNELS_IN=2
5957
CHANNELS_OUT=2
6058
PIPELINES="1,2"
61-
INFILE1=$(mktemp --tmpdir=/tmp in-XXXX.raw)
62-
OUTFILE1=$(mktemp --tmpdir=/tmp out-XXXX.raw)
63-
TRACEFILE=$(mktemp --tmpdir=/tmp trace-XXXX.txt)
64-
PROFILEOUT=$(mktemp --tmpdir=/tmp profile-XXXX.out)
6559
KEEP_TMP=false
6660
XTRUN=false
6761
PROFILE=false
@@ -123,6 +117,19 @@ while getopts "b:c:hi:km:n:o:p:r:R:t:vx" opt; do
123117
done
124118
shift $((OPTIND-1))
125119

120+
# Get the current date and time in a specific format (YYYYMMDD_HHMMSS)
121+
timestamp=$(date +"%Y%m%d_%H%M%S")
122+
123+
# Combine the prefix and timestamp to create the filename
124+
INFILE1="$PWD/testbench_data/in-${MODULE}-${timestamp}.raw"
125+
OUTFILE1="$PWD/testbench_data/out-${MODULE}-${timestamp}.raw"
126+
TRACEFILE="$PWD/testbench_data/trace-${MODULE}-${timestamp}.txt"
127+
PROFILEOUT="$PWD/testbench_data/profile-${MODULE}-${timestamp}.out"
128+
OUTWAV="$PWD/testbench_data/outwav-${MODULE}-${timestamp}.wav"
129+
130+
# make the data directory if it doesn't exist
131+
mkdir -p $PWD/testbench_data
132+
126133
echo Converting clip "$CLIP" to raw input
127134
if [[ "$BITS" == "24" ]]; then
128135
# Sox does not support S24_4LE format
@@ -184,16 +191,17 @@ else
184191
fi
185192
fi
186193

187-
if [ -n "$OUTWAV" ]; then
194+
# Generate the outwav if we are keeping our data files for inspection.
195+
if [[ "$KEEP_TMP" == false ]]; then
196+
echo Deleting temporary files
197+
rm -f "$INFILE1" "$OUTFILE1" "$TRACEFILE" "$PROFILEOUT"
198+
else
188199
echo Converting raw output to "$OUTWAV"
189200
if [[ "$BITS" == "24" ]]; then
190-
sox --encoding signed-integer -L -r "$RATE_OUT" -c "$CHANNELS_OUT" -b 32 "$OUTFILE1" "$OUTWAV" vol 256
201+
sox --encoding signed-integer -L -r "$RATE_OUT" -c "$CHANNELS_OUT" -b 32 \
202+
"$OUTFILE1" "$OUTWAV" vol 256
191203
else
192-
sox --encoding signed-integer -L -r "$RATE_OUT" -c "$CHANNELS_OUT" -b "$BITS" "$OUTFILE1" "$OUTWAV"
204+
sox --encoding signed-integer -L -r "$RATE_OUT" -c "$CHANNELS_OUT" -b "$BITS" \
205+
"$OUTFILE1" "$OUTWAV"
193206
fi
194207
fi
195-
196-
if [[ "$KEEP_TMP" == false ]]; then
197-
echo Deleting temporary files
198-
rm -f "$INFILE1" "$OUTFILE1" "$TRACEFILE" "$PROFILEOUT"
199-
fi

0 commit comments

Comments
 (0)