-
Notifications
You must be signed in to change notification settings - Fork 350
Expand file tree
/
Copy pathcomp_run.sh
More file actions
executable file
·200 lines (174 loc) · 4.47 KB
/
comp_run.sh
File metadata and controls
executable file
·200 lines (174 loc) · 4.47 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
#!/bin/bash
# SPDX-License-Identifier: BSD-3-Clause
# Copyright(c) 2018-2020 Intel Corporation. All rights reserved.
# stop on most errors
set -e
usage ()
{
cat <<EOFHELP
Usage: $0 <options> <comp direction bits_in bits_out fs_in fs_out input output>
Example 1: $0 volume playback 16 16 48000 48000 input.raw output.raw
Example 2: $0 -e volume_trace.txt -t volume_config.sh
Where volume_config.sh could be e.g. next. Minimal configuration need is only
the COMP line.
# Volume component configuration
COMP=gain
DIRECTION=playback
BITS_IN=16
BITS_OUT=16
CHANNELS_IN=2
CHANNELS_OUT=2
FS_IN=48000
FS_OUT=48000
FN_IN=input.raw
FN_OUT=output.raw
FN_TRACE:=trace.txt # This is default value if FN_TRACE is not set via -e option
VALGRIND=true
XTRUN=
TESTBENCH=sof-testbench4
EOFHELP
}
parse_args ()
{
# Defaults
DIRECTION=playback
BITS_IN=16
BITS_OUT=
CHANNELS_IN=2
CHANNELS_OUT=
FS_IN=48000
FS_OUT=
VALGRIND=true
DEBUG=
SOURCED_CONFIG=false
FN_TRACE=
EXTRA_OPTS=
XTRUN=
TESTBENCH=sof-testbench4
while getopts ":he:t:" opt; do
case "${opt}" in
e)
FN_TRACE="${OPTARG}"
;;
h)
usage
exit
;;
t)
# shellcheck disable=SC1090
source "${OPTARG}"
SOURCED_CONFIG=true
;;
*)
usage
exit 1
;;
esac
done
shift $((OPTIND -1))
if ! "$SOURCED_CONFIG"; then
[ $# -eq 8 ] || {
usage "$0"
exit 1
}
COMP="$1"
DIRECTION="$2"
BITS_IN="$3"
BITS_OUT="$4"
FS_IN="$5"
FS_OUT="$6"
FN_IN="$7"
FN_OUT="$8"
fi
if [[ -z $BITS_OUT ]]; then
BITS_OUT=$BITS_IN
fi
if [[ -z $FS_OUT ]]; then
FS_OUT=$FS_IN
fi
if [[ -z $CHANNELS_OUT ]]; then
CHANNELS_OUT=$CHANNELS_IN
fi
}
delete_file_check ()
{
if [ -f "$1" ]; then
rm -f "$1"
fi
}
run_testbench ()
{
delete_file_check "$FN_OUT"
delete_file_check "$FN_TRACE"
if [ -z "$FN_TRACE" ]; then
# shellcheck disable=SC2086
$VALGRIND_CMD $CMD
else
$VALGRIND_CMD $CMD 2> "$FN_TRACE" || {
local ret=$?
echo ----------------------------------------------------------
cat "$FN_TRACE"
echo ----------------------------------------------------------
return $ret # "exit" would be for something unexpected and catastrophic,
# not for a "regular" test failure
}
fi
}
parse_args "$@"
# Path to topologies
TPLG_DIR=../../../../build_tools/test/topology
# Testbench path and executable
if [[ -z $XTRUN ]]; then
PATH_TESTBENCH=../../../../build_testbench/install/bin/$TESTBENCH
else
BUILD_DIR=../../../../build_xt_testbench
PATH_TESTBENCH="$BUILD_DIR"/$TESTBENCH
source "$BUILD_DIR"/xtrun_env.sh
XTRUN_CMD=$XTENSA_PATH/$XTRUN
if $VALGRIND; then
>&2 printf "WARNING: Ignoring VALGRIND with xt-run\n"
VALGRIND=false
fi
fi
if $VALGRIND; then
VALGRIND_CMD="valgrind --leak-check=yes --error-exitcode=1"
else
VALGRIND_CMD=
fi
HOST_EXE="$XTRUN_CMD $PATH_TESTBENCH"
# Use topology from component test topologies
INFMT=s${BITS_IN}le
OUTFMT=s${BITS_OUT}le
TPLGFN=test-${DIRECTION}-ssp5-mclk-0-I2S-${COMP}-${INFMT}-${OUTFMT}-48k-24576k-codec.tplg
TPLG_BUILD_TIP="Please run scripts/build-tools.sh -t"
PIPELINES=
[[ $TESTBENCH == "sof-testbench4" ]] && {
# With comp benchmark topologies for playback use pipelines 1-2, for capture 3-4
[[ $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_BUILD_TIP="Please run scripts/build-tools.sh"
}
TPLG=${TPLG_DIR}/${TPLGFN}
[ -f "$TPLG" ] || {
echo
echo "Error: topology $TPLG does not exist."
echo "$TPLG_BUILD_TIP"
exit 1
}
# If binary test vectors
if [ "${FN_IN: -4}" == ".raw" ]; then
BINFMT="-b S${BITS_IN}_LE"
else
BINFMT=""
fi
# Run command
OPTS="$DEBUG -r $FS_IN -R $FS_OUT -c $CHANNELS_IN -n $CHANNELS_OUT $BINFMT $PIPELINES -t $TPLG"
DATA="-i $FN_IN -o $FN_OUT"
ARG="$OPTS $EXTRA_OPTS $DATA"
CMD="$HOST_EXE $ARG"
# Run test bench
echo "Command: $HOST_EXE"
echo "Argument: $ARG"
run_testbench