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
|
|
|
|
# ./scripts/host-build-all.sh
|
|
|
|
# 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
|
|
|
|
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
|
|
|
|
2020-03-30 16:39:25 +08:00
|
|
|
# test with volume
|
|
|
|
echo "=========================================================="
|
|
|
|
echo "test volume with ./volume_run.sh 16 16 48000 zeros_in.raw volume_out.raw"
|
2020-04-17 13:46:09 +08:00
|
|
|
if ./volume_run.sh 16 16 48000 zeros_in.raw volume_out.raw &>vol.log; then
|
|
|
|
echo "volume test passed!"
|
|
|
|
else
|
2020-03-30 16:39:25 +08:00
|
|
|
echo "volume test failed!"
|
|
|
|
cat vol.log
|
2020-04-17 13:46:09 +08:00
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
if comparesize ${INPUT_FILE_SIZE} "$(filesize volume_out.raw)"; then
|
|
|
|
echo "volume_out size check passed!"
|
2020-03-30 16:39:25 +08:00
|
|
|
else
|
2020-04-17 13:46:09 +08:00
|
|
|
echo "volume_out size check failed!"
|
|
|
|
cat vol.log
|
|
|
|
exit 1
|
2020-03-30 16:39:25 +08:00
|
|
|
fi
|
2018-06-01 10:29:09 +08:00
|
|
|
|
2020-04-17 13:46:09 +08:00
|
|
|
# test with src
|
2020-03-30 16:39:25 +08:00
|
|
|
echo "=========================================================="
|
|
|
|
echo "test src with ./src_run.sh 32 32 44100 48000 zeros_in.raw src_out.raw"
|
2020-04-17 13:46:09 +08:00
|
|
|
if ./src_run.sh 32 32 44100 48000 zeros_in.raw src_out.raw &>src.log; then
|
|
|
|
echo "src test passed!"
|
|
|
|
else
|
2020-03-30 16:39:25 +08:00
|
|
|
echo "src test failed!"
|
|
|
|
cat src.log
|
2020-04-17 13:46:09 +08:00
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
if comparesize "$(srcsize ${INPUT_FILE_SIZE} 44100 48000)" "$(filesize src_out.raw)";then
|
|
|
|
echo "src_out size check passed!"
|
2020-03-30 16:39:25 +08:00
|
|
|
else
|
2020-04-17 13:46:09 +08:00
|
|
|
echo "src_out size check failed!"
|
|
|
|
cat src.log
|
|
|
|
exit 1
|
2020-03-30 16:39:25 +08:00
|
|
|
fi
|
2018-06-01 10:29:09 +08:00
|
|
|
|
2020-03-30 16:39:25 +08:00
|
|
|
# test with eq
|
|
|
|
echo "=========================================================="
|
|
|
|
echo "test eqiir with ./eqiir_run.sh 16 16 48000 zeros_in.raw eqiir_out.raw"
|
2020-04-17 13:46:09 +08:00
|
|
|
if ./eqiir_run.sh 16 16 48000 zeros_in.raw eqiir_out.raw &>eqiir.log; then
|
|
|
|
echo "eqiir test passed!"
|
|
|
|
else
|
2020-03-30 16:39:25 +08:00
|
|
|
echo "eqiir test failed!"
|
|
|
|
cat eqiir.log
|
2020-04-17 13:46:09 +08:00
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
|
|
if comparesize $INPUT_FILE_SIZE "$(filesize eqiir_out.raw)"; then
|
|
|
|
echo "eqiir_out size check passed!"
|
2020-03-30 16:39:25 +08:00
|
|
|
else
|
2020-04-17 13:46:09 +08:00
|
|
|
echo "eqiir_out size check failed!"
|
|
|
|
cat eqiir.log
|
|
|
|
exit 1
|
2020-03-30 16:39:25 +08:00
|
|
|
fi
|