From ec0720e087e0b63fa250ae90c59f0893d490e645 Mon Sep 17 00:00:00 2001 From: Seppo Ingalsuo Date: Mon, 23 Mar 2020 12:16:33 +0200 Subject: [PATCH] Tools: Test: Audio: Add double quotes to shell scripts This patch adds the double quotes to shell scripts to avoid fails with arguments or shell variables when there are space characters. The processing components run scripts are all edited for better structure with functions usage() and main() and with local variables within functions. Signed-off-by: Seppo Ingalsuo --- tools/test/audio/asrc_run.sh | 28 ++++++++++++++++++++-------- tools/test/audio/comp_run.sh | 2 +- tools/test/audio/eqfir_run.sh | 24 ++++++++++++++++++------ tools/test/audio/eqiir_run.sh | 23 +++++++++++++++++------ tools/test/audio/src_run.sh | 28 ++++++++++++++++++++-------- tools/test/audio/volume_run.sh | 23 +++++++++++++++++------ 6 files changed, 93 insertions(+), 35 deletions(-) diff --git a/tools/test/audio/asrc_run.sh b/tools/test/audio/asrc_run.sh index 217dc58a9fd5..ff7180951db2 100755 --- a/tools/test/audio/asrc_run.sh +++ b/tools/test/audio/asrc_run.sh @@ -2,13 +2,25 @@ # SPDX-License-Identifier: BSD-3-Clause # Copyright(c) 2020 Intel Corporation. All rights reserved. -if [ -z "$6" ]; then - echo "Usage: $0 " - echo "Example: $0 16 16 32000 48000 input.raw output.raw" - exit -fi +usage () +{ + echo "Usage: $1 " + echo "Example: $1 16 16 32000 48000 input.raw output.raw" +} -COMP=asrc -DIRECTION=playback +main() +{ + local COMP DIRECTION -./comp_run.sh $COMP $DIRECTION $1 $2 $3 $4 $5 $6 + if [ $# -ne 6 ]; then + usage "$0" + exit + fi + + COMP=asrc + DIRECTION=playback + + ./comp_run.sh $COMP $DIRECTION "$@" +} + +main "$@" diff --git a/tools/test/audio/comp_run.sh b/tools/test/audio/comp_run.sh index c6b8dd337f56..45b34172be2c 100755 --- a/tools/test/audio/comp_run.sh +++ b/tools/test/audio/comp_run.sh @@ -25,7 +25,7 @@ TPLGFN=test-${DIRECTION}-ssp5-mclk-0-I2S-${COMP}-${INFMT}-${OUTFMT}-48k-24576k-c TPLG=${TPLG_DIR}/${TPLGFN} # If binary test vectors -if [ ${FN_IN: -4} == ".raw" ]; then +if [ "${FN_IN: -4}" == ".raw" ]; then BINFMT="-b S${BITS_IN}_LE" else BINFMT="" diff --git a/tools/test/audio/eqfir_run.sh b/tools/test/audio/eqfir_run.sh index 1360c04bb81b..923029d37980 100755 --- a/tools/test/audio/eqfir_run.sh +++ b/tools/test/audio/eqfir_run.sh @@ -2,13 +2,25 @@ # SPDX-License-Identifier: BSD-3-Clause # Copyright(c) 2020 Intel Corporation. All rights reserved. -if [ -z "$5" ]; then +usage () +{ echo "Usage: $0 " echo "Example: $0 16 16 48000 input.raw output.raw" - exit -fi +} -COMP=eq-fir -DIRECTION=playback +main () +{ + local COMP DIRECTION -./comp_run.sh $COMP $DIRECTION $1 $2 $3 $3 $4 $5 + if [ $# -ne 5 ]; then + usage "$0" + exit + fi + + COMP=eq-fir + DIRECTION=playback + + ./comp_run.sh $COMP $DIRECTION "$1" "$2" "$3" "$3" "$4" "$5" +} + +main "$@" diff --git a/tools/test/audio/eqiir_run.sh b/tools/test/audio/eqiir_run.sh index 833f03202f5f..bd0ff4989fc3 100755 --- a/tools/test/audio/eqiir_run.sh +++ b/tools/test/audio/eqiir_run.sh @@ -2,14 +2,25 @@ # SPDX-License-Identifier: BSD-3-Clause # Copyright(c) 2020 Intel Corporation. All rights reserved. -if [ -z "$5" ]; then +usage () +{ echo "Usage: $0 " echo "Example: $0 16 16 48000 input.raw output.raw" - exit -fi +} +main () +{ + local COMP DIRECTION -COMP=eq-iir -DIRECTION=playback + if [ $# -ne 5 ]; then + usage "$0" + exit + fi -./comp_run.sh $COMP $DIRECTION $1 $2 $3 $3 $4 $5 + COMP=eq-iir + DIRECTION=playback + + ./comp_run.sh $COMP $DIRECTION "$1" "$2" "$3" "$3" "$4" "$5" +} + +main "$@" diff --git a/tools/test/audio/src_run.sh b/tools/test/audio/src_run.sh index 277388a15dd0..03920012d380 100755 --- a/tools/test/audio/src_run.sh +++ b/tools/test/audio/src_run.sh @@ -2,13 +2,25 @@ # SPDX-License-Identifier: BSD-3-Clause # Copyright(c) 2018-2020 Intel Corporation. All rights reserved. -if [ -z "$6" ]; then - echo "Usage: $0 " - echo "Example: $0 16 16 32000 48000 input.raw output.raw" - exit -fi +usage () +{ + echo "Usage: $1 " + echo "Example: $1 16 16 32000 48000 input.raw output.raw" +} -COMP=src -DIRECTION=playback +main() +{ + local COMP DIRECTION -./comp_run.sh $COMP $DIRECTION $1 $2 $3 $4 $5 $6 + if [ $# -ne 6 ]; then + usage "$0" + exit + fi + + COMP=src + DIRECTION=playback + + ./comp_run.sh $COMP $DIRECTION "$@" +} + +main "$@" diff --git a/tools/test/audio/volume_run.sh b/tools/test/audio/volume_run.sh index 084b2bbbf5a1..dd8308ae8c36 100755 --- a/tools/test/audio/volume_run.sh +++ b/tools/test/audio/volume_run.sh @@ -2,14 +2,25 @@ # SPDX-License-Identifier: BSD-3-Clause # Copyright(c) 2020 Intel Corporation. All rights reserved. -if [ -z "$5" ]; then +usage () +{ echo "Usage: $0 " echo "Example: $0 16 16 48000 input.raw output.raw" - exit -fi +} +main () +{ + local COMP DIRECTION -COMP=volume -DIRECTION=playback + if [ $# -ne 5 ]; then + usage "$0" + exit + fi -./comp_run.sh $COMP $DIRECTION $1 $2 $3 $3 $4 $5 + COMP=volume + DIRECTION=playback + + ./comp_run.sh $COMP $DIRECTION "$1" "$2" "$3" "$3" "$4" "$5" +} + +main "$@"