2020-03-30 16:39:25 +08:00
|
|
|
#!/bin/bash
|
2019-06-02 04:58:16 +08:00
|
|
|
# SPDX-License-Identifier: BSD-3-Clause
|
|
|
|
# Copyright(c) 2018 Intel Corporation. All rights reserved.
|
2018-06-01 10:29:09 +08:00
|
|
|
|
2020-03-30 16:39:25 +08:00
|
|
|
#
|
|
|
|
# Usage:
|
|
|
|
# please run following scrits for the test tplg and host build
|
|
|
|
# ./scripts/build-tools.sh -t
|
2020-11-06 13:52:24 +08:00
|
|
|
# ./scripts/rebuild-testbench.sh
|
2020-03-30 16:39:25 +08:00
|
|
|
# Run test
|
|
|
|
# ./scripts/host-testbench.sh
|
|
|
|
#
|
2018-06-01 10:29:09 +08:00
|
|
|
|
2020-05-14 06:11:27 +08:00
|
|
|
# stop on most errors
|
|
|
|
set -e
|
|
|
|
|
2020-03-30 16:39:25 +08:00
|
|
|
function filesize() {
|
2020-04-17 13:46:09 +08:00
|
|
|
du -b "$1" | awk '{print $1}'
|
2020-03-30 16:39:25 +08:00
|
|
|
}
|
2018-06-01 10:29:09 +08:00
|
|
|
|
2020-03-30 16:39:25 +08:00
|
|
|
function comparesize() {
|
|
|
|
INPUT_SIZE=$1
|
|
|
|
OUTPUT_SIZE=$2
|
|
|
|
INPUT_SIZE_MIN=$(echo "$INPUT_SIZE*0.9/1"|bc)
|
|
|
|
# echo "MIN SIZE with 90% tolerance is $INPUT_SIZE_MIN"
|
|
|
|
# echo "ACTUALL SIZE is $OUTPUT_SIZE"
|
|
|
|
if [[ "$OUTPUT_SIZE" -gt "$INPUT_SIZE" ]]; then
|
|
|
|
echo "OUTPUT_SIZE $OUTPUT_SIZE too big"
|
|
|
|
return 1
|
|
|
|
fi
|
|
|
|
if [[ "$OUTPUT_SIZE" -lt "$INPUT_SIZE_MIN" ]]; then
|
|
|
|
echo "OUTPUT_SIZE $OUTPUT_SIZE too small"
|
|
|
|
return 1
|
|
|
|
fi
|
2018-06-01 10:29:09 +08:00
|
|
|
|
2020-03-30 16:39:25 +08:00
|
|
|
return 0
|
|
|
|
}
|
2018-06-01 10:29:09 +08:00
|
|
|
|
2020-03-30 16:39:25 +08:00
|
|
|
function srcsize() {
|
|
|
|
INPUT_SIZE=$1
|
|
|
|
INPUT_RATE=$2
|
|
|
|
OUTPUT_RATE=$3
|
|
|
|
OUTPUT_SIZE=$(echo "${INPUT_SIZE}*${OUTPUT_RATE}/${INPUT_RATE}"|bc)
|
2020-04-17 13:46:09 +08:00
|
|
|
echo "$OUTPUT_SIZE"
|
2020-03-30 16:39:25 +08:00
|
|
|
}
|
2018-06-28 12:16:44 +08:00
|
|
|
|
2022-08-24 16:42:46 +08:00
|
|
|
function die() {
|
|
|
|
printf "$@"
|
|
|
|
exit 1
|
|
|
|
}
|
|
|
|
|
|
|
|
process_test_cmd() {
|
|
|
|
octave -q --eval "pkg load signal io; [n_fail]=process_test('$1', $2, $3, $4, $5);exit(n_fail)"
|
|
|
|
}
|
|
|
|
|
|
|
|
# function test_component()
|
|
|
|
# $1 : component name
|
|
|
|
# $2 : input bits per sample
|
|
|
|
# $3 : output bits per sample
|
|
|
|
# $4 : sampling rate
|
|
|
|
# $5 : quick test=0, fulltest=1
|
|
|
|
test_component() {
|
|
|
|
test "$#" -eq 5 || die "Have $# parameters but 5 expected"
|
|
|
|
|
|
|
|
echo "------------------------------------------------------------"
|
|
|
|
echo "test $1 component with $2 $3 $4 $5"
|
|
|
|
if process_test_cmd "$@"; then
|
|
|
|
echo "$1 test passed!"
|
|
|
|
else
|
|
|
|
die "$1 test failed!"
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
2020-04-17 13:46:09 +08:00
|
|
|
SCRIPTS_DIR=$(dirname "${BASH_SOURCE[0]}")
|
2020-03-30 16:39:25 +08:00
|
|
|
SOF_DIR=$SCRIPTS_DIR/../
|
|
|
|
TESTBENCH_DIR=${SOF_DIR}/tools/test/audio
|
|
|
|
INPUT_FILE_SIZE=10240
|
2018-06-28 12:16:44 +08:00
|
|
|
|
2020-05-14 06:11:27 +08:00
|
|
|
cd "$TESTBENCH_DIR"
|
2020-04-17 13:46:09 +08:00
|
|
|
rm -rf ./*.raw
|
2018-06-28 12:16:44 +08:00
|
|
|
|
2020-03-30 16:39:25 +08:00
|
|
|
# create input zeros raw file
|
|
|
|
head -c ${INPUT_FILE_SIZE} < /dev/zero > zeros_in.raw
|
2018-06-28 12:16:44 +08:00
|
|
|
|
2022-08-31 01:59:33 +08:00
|
|
|
# by default quick test
|
|
|
|
FullTest=${FullTest:-0}
|
|
|
|
|
2020-03-30 16:39:25 +08:00
|
|
|
# test with volume
|
2022-08-31 01:59:33 +08:00
|
|
|
test_component volume 16 16 48000 "$FullTest"
|
|
|
|
test_component volume 24 24 48000 "$FullTest"
|
|
|
|
test_component volume 32 32 48000 "$FullTest"
|
2020-04-17 13:46:09 +08:00
|
|
|
|
2022-08-24 16:42:46 +08:00
|
|
|
# test with eq-iir
|
2022-08-31 01:59:33 +08:00
|
|
|
test_component eq-iir 16 16 48000 "$FullTest"
|
|
|
|
test_component eq-iir 24 24 48000 "$FullTest"
|
|
|
|
test_component eq-iir 32 32 48000 "$FullTest"
|
2018-06-01 10:29:09 +08:00
|
|
|
|
2022-08-24 16:42:46 +08:00
|
|
|
# test with eq-fir
|
2022-08-31 01:59:33 +08:00
|
|
|
test_component eq-fir 32 32 48000 "$FullTest"
|
2020-04-17 13:46:09 +08:00
|
|
|
|
2022-08-24 16:42:46 +08:00
|
|
|
# test with dcblock
|
2022-08-31 01:59:33 +08:00
|
|
|
test_component dcblock 32 32 48000 "$FullTest"
|
2020-04-17 13:46:09 +08:00
|
|
|
|
2022-08-24 16:42:46 +08:00
|
|
|
# test with drc
|
2022-08-31 01:59:33 +08:00
|
|
|
test_component drc 32 32 48000 "$FullTest"
|
2020-04-17 13:46:09 +08:00
|
|
|
|
2022-08-24 16:42:46 +08:00
|
|
|
# test with multiband-drc
|
2022-08-31 01:59:33 +08:00
|
|
|
test_component multiband-drc 32 32 48000 "$FullTest"
|
2022-08-24 16:42:46 +08:00
|
|
|
|
|
|
|
# test with src
|
2022-08-31 01:59:33 +08:00
|
|
|
test_component src 24 24 48000 "$FullTest"
|
2022-08-24 16:42:46 +08:00
|
|
|
|
|
|
|
# test with tdfb
|
2022-08-31 01:59:33 +08:00
|
|
|
test_component tdfb 32 32 48000 "$FullTest"
|
2020-08-29 02:20:15 +08:00
|
|
|
|
2022-08-24 16:42:46 +08:00
|
|
|
echo "All tests are done!"
|