Skip to content

Commit a4b62b7

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 feded0f commit a4b62b7

File tree

1 file changed

+23
-15
lines changed

1 file changed

+23
-15
lines changed

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>, default 48000"
1918
echo " -t <force topology>, default none, e.g. production/sof-hda-generic.tplg"
@@ -44,7 +43,6 @@ if [ ! -d "sof" ]; then
4443
exit 1
4544
fi
4645

47-
OUTWAV=
4846
CLIP=/usr/share/sounds/alsa/Front_Center.wav
4947
MODULE=gain
5048
BITS=32
@@ -53,10 +51,6 @@ RATE_OUT=48000
5351
CHANNELS_IN=2
5452
CHANNELS_OUT=2
5553
PIPELINES="1,2"
56-
INFILE1=$(mktemp --tmpdir=/tmp in-XXXX.raw)
57-
OUTFILE1=$(mktemp --tmpdir=/tmp out-XXXX.raw)
58-
TRACEFILE=$(mktemp --tmpdir=/tmp trace-XXXX.txt)
59-
PROFILEOUT=$(mktemp --tmpdir=/tmp profile-XXXX.out)
6054
KEEP_TMP=false
6155
XTRUN=false
6256
PROFILE=false
@@ -116,6 +110,19 @@ while getopts "b:c:hi:km:n:o:p:r:t:vx" opt; do
116110
done
117111
shift $((OPTIND-1))
118112

113+
# Get the current date and time in a specific format (YYYYMMDD_HHMMSS)
114+
timestamp=$(date +"%Y%m%d_%H%M%S")
115+
116+
# Combine the prefix and timestamp to create the filename
117+
INFILE1="$PWD/testbench_data/in-${MODULE}-${timestamp}.raw"
118+
OUTFILE1="$PWD/testbench_data/out-${MODULE}-${timestamp}.raw"
119+
TRACEFILE="$PWD/testbench_data/trace-${MODULE}-${timestamp}.txt"
120+
PROFILEOUT="$PWD/testbench_data/profile-${MODULE}-${timestamp}.out"
121+
OUTWAV="$PWD/testbench_data/outwav-${MODULE}-${timestamp}.wav"
122+
123+
# make the data directory if it doesn't exist
124+
mkdir -p $PWD/testbench_data
125+
119126
echo Converting clip "$CLIP" to raw input
120127
if [[ "$BITS" == "24" ]]; then
121128
# Sox does not support S24_4LE format
@@ -177,16 +184,17 @@ else
177184
fi
178185
fi
179186

180-
if [ -n "$OUTWAV" ]; then
187+
# Generate the outwav if we are keeping our data files for inspection.
188+
if [[ "$KEEP_TMP" == false ]]; then
189+
echo Deleting temporary files
190+
rm -f "$INFILE1" "$OUTFILE1" "$TRACEFILE" "$PROFILEOUT"
191+
else
181192
echo Converting raw output to "$OUTWAV"
182193
if [[ "$BITS" == "24" ]]; then
183-
sox --encoding signed-integer -L -r "$RATE_OUT" -c "$CHANNELS_OUT" -b 32 "$OUTFILE1" "$OUTWAV" vol 256
194+
sox --encoding signed-integer -L -r "$RATE_OUT" -c "$CHANNELS_OUT" -b 32 \
195+
"$OUTFILE1" "$OUTWAV" vol 256
184196
else
185-
sox --encoding signed-integer -L -r "$RATE_OUT" -c "$CHANNELS_OUT" -b "$BITS" "$OUTFILE1" "$OUTWAV"
197+
sox --encoding signed-integer -L -r "$RATE_OUT" -c "$CHANNELS_OUT" -b "$BITS" \
198+
"$OUTFILE1" "$OUTWAV"
186199
fi
187200
fi
188-
189-
if [[ "$KEEP_TMP" == false ]]; then
190-
echo Deleting temporary files
191-
rm -f "$INFILE1" "$OUTFILE1" "$TRACEFILE" "$PROFILEOUT"
192-
fi

0 commit comments

Comments
 (0)