From 98fa1e56c700da88b4cb922d80db666c9d455e15 Mon Sep 17 00:00:00 2001 From: Greg Galloway Date: Tue, 6 Jun 2023 15:47:50 -0700 Subject: [PATCH 1/5] check-suspend-resume-with-audio.sh: Fix quoting issues. Fix a variety of quote and quote-related issues per shellcheck's requests. Signed-off-by: Greg Galloway --- test-case/check-suspend-resume-with-audio.sh | 22 ++++++++++---------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/test-case/check-suspend-resume-with-audio.sh b/test-case/check-suspend-resume-with-audio.sh index fa2fbe6a..597c228b 100755 --- a/test-case/check-suspend-resume-with-audio.sh +++ b/test-case/check-suspend-resume-with-audio.sh @@ -42,7 +42,7 @@ OPT_HAS_ARG['r']=0 OPT_VAL['r']=0 OPT_NAME['m']='mode' OPT_DESC['m']='alsa application type: playback/capture' OPT_HAS_ARG['m']=1 OPT_VAL['m']='playback' -OPT_NAME['t']='tplg' OPT_DESC['t']='tplg file, default value is env TPLG: $TPLG' +OPT_NAME['t']='tplg' OPT_DESC['t']="tplg file, default value is env TPLG: $TPLG" OPT_HAS_ARG['t']=1 OPT_VAL['t']="$TPLG" OPT_NAME['s']='sof-logger' OPT_DESC['s']="Open sof-logger trace the data will store at $LOG_ROOT" @@ -89,28 +89,28 @@ else opt="$opt -r" fi -for idx in $(seq 0 $(expr $PIPELINE_COUNT - 1)) +for idx in $(seq 0 $((PIPELINE_COUNT - 1))) do # set up checkpoint for each iteration setup_kernel_check_point # store local checkpoint as we have sub-test LOCAL_CHECK_POINT="$KERNEL_CHECKPOINT" - channel=$(func_pipeline_parse_value $idx channel) - rate=$(func_pipeline_parse_value $idx rate) - fmt=$(func_pipeline_parse_value $idx fmt) - dev=$(func_pipeline_parse_value $idx dev) - pcm=$(func_pipeline_parse_value $idx pcm) - snd=$(func_pipeline_parse_value $idx snd) + channel=$(func_pipeline_parse_value "$idx" channel) + rate=$(func_pipeline_parse_value "$idx" rate) + fmt=$(func_pipeline_parse_value "$idx" fmt) + dev=$(func_pipeline_parse_value "$idx" dev) + pcm=$(func_pipeline_parse_value "$idx" pcm) + snd=$(func_pipeline_parse_value "$idx" snd) dlogi "Run $TYPE command for the background" cmd_args="$cmd -D$dev -r $rate -c $channel -f $fmt $file_name -q" dlogc "$cmd_args" - $cmd -D$dev -r $rate -c $channel -f $fmt $file_name -q & process_id=$! + $cmd -D"$dev" -r "$rate" -c "$channel" -f "$fmt" "$file_name" -q & process_id=$! # delay for process run sleep 1 # check process status is correct sof-process-state.sh $process_id if [ $? -ne 0 ]; then - func_lib_lsof_error_dump $snd + func_lib_lsof_error_dump "$snd" dloge "error process state of $cmd" dlogi "dump ps for aplay & arecord" ps -ef |grep -E 'aplay|arecord' @@ -125,7 +125,7 @@ do # check process status is correct sof-process-state.sh $process_id || { - func_lib_lsof_error_dump $snd + func_lib_lsof_error_dump "$snd" dloge "process status is abnormal" dlogi "dump ps for aplay & arecord" ps -ef |grep -E 'aplay|arecord' From 7a6dd6e463514b43d5b8200ec33e7cd1c60fda1e Mon Sep 17 00:00:00 2001 From: Greg Galloway Date: Wed, 7 Jun 2023 13:15:06 -0700 Subject: [PATCH 2/5] check-suspend-resume-with-audio: fix source references. The previous source reference for lib.sh triggers shellcheck errors. Fixed a later BASH_SOURCE[0] reference to follow the same pattern. Signed-off-by: Greg Galloway --- test-case/check-suspend-resume-with-audio.sh | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/test-case/check-suspend-resume-with-audio.sh b/test-case/check-suspend-resume-with-audio.sh index 597c228b..2a0f5519 100755 --- a/test-case/check-suspend-resume-with-audio.sh +++ b/test-case/check-suspend-resume-with-audio.sh @@ -22,7 +22,8 @@ set -e ## check kernel log and find no errors ## -source $(dirname ${BASH_SOURCE[0]})/../case-lib/lib.sh +# shellcheck source=case-lib/lib.sh +source "$(dirname "${BASH_SOURCE[0]}")"/../case-lib/lib.sh OPT_NAME['l']='loop' OPT_DESC['l']='suspend/resume loop count' OPT_HAS_ARG['l']=1 OPT_VAL['l']=3 @@ -118,7 +119,7 @@ do ps --ppid $$ -f exit 1 fi - $(dirname ${BASH_SOURCE[0]})/check-suspend-resume.sh $(echo $opt) || die "suspend resume failed" + "$(dirname "${BASH_SOURCE[0]}")"/check-suspend-resume.sh "$opt" || die "suspend resume failed" # check kernel log for each iteration to catch issues sof-kernel-log-check.sh "$LOCAL_CHECK_POINT" || die "Caught error in kernel log" From cb392b00e54291373bc87077a21642f5f9bc83b4 Mon Sep 17 00:00:00 2001 From: Greg Galloway Date: Mon, 12 Jun 2023 12:43:54 -0700 Subject: [PATCH 3/5] check-suspend-resume-with-audio.sh: Shellcheck fixes. Rewrote 'opt' to be an array. Quoting opt as an argument caused issues that won't manifest when it's an array. Removed unnecessary quoting from array assignments. Signed-off-by: Greg Galloway --- test-case/check-suspend-resume-with-audio.sh | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/test-case/check-suspend-resume-with-audio.sh b/test-case/check-suspend-resume-with-audio.sh index 2a0f5519..2901bd6f 100755 --- a/test-case/check-suspend-resume-with-audio.sh +++ b/test-case/check-suspend-resume-with-audio.sh @@ -79,15 +79,14 @@ fi func_pipeline_export "$tplg" "type:${OPT_VAL['m']} & ${OPT_VAL['P']}" +opt_arr=(-l "${OPT_VAL['l']}") if [ "${OPT_VAL['T']}" ]; then - opt="-l ${OPT_VAL['l']} -T ${OPT_VAL['T']}" -else - opt="-l ${OPT_VAL['l']}" + opt_arr+=(-T "${OPT_VAL['T']}") fi if [ ${OPT_VAL['r']} -eq 0 ]; then - opt="$opt -S ${OPT_VAL['S']} -w ${OPT_VAL['w']}" + opt_arr+=(-S "${OPT_VAL['S']}" -w "${OPT_VAL['w']}") else - opt="$opt -r" + opt_arr+=(-r) fi for idx in $(seq 0 $((PIPELINE_COUNT - 1))) @@ -119,7 +118,7 @@ do ps --ppid $$ -f exit 1 fi - "$(dirname "${BASH_SOURCE[0]}")"/check-suspend-resume.sh "$opt" || die "suspend resume failed" + "$(dirname "${BASH_SOURCE[0]}")"/check-suspend-resume.sh "${opt_arr[@]}" || die "suspend resume failed" # check kernel log for each iteration to catch issues sof-kernel-log-check.sh "$LOCAL_CHECK_POINT" || die "Caught error in kernel log" From 2eca21ddd10901b8bafe9a06e4ef9be92978bf06 Mon Sep 17 00:00:00 2001 From: Greg Galloway Date: Mon, 12 Jun 2023 15:20:22 -0700 Subject: [PATCH 4/5] check-suspend-resume-with-audio.sh: Shellcheck pgrep fixes. Replaced ps -ef | grep lines with pgrep. Rewrote conditional of a sof-process-state.sh line (that was basically broken). The script had 'set -e' so the command would fail and exit the script. This prevented the follow-up lines, which were checking exit status ($?), from ever being run if the command failed. Removed unused variable assignment pcm). Signed-off-by: Greg Galloway --- test-case/check-suspend-resume-with-audio.sh | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/test-case/check-suspend-resume-with-audio.sh b/test-case/check-suspend-resume-with-audio.sh index 2901bd6f..b328ff5e 100755 --- a/test-case/check-suspend-resume-with-audio.sh +++ b/test-case/check-suspend-resume-with-audio.sh @@ -99,7 +99,6 @@ do rate=$(func_pipeline_parse_value "$idx" rate) fmt=$(func_pipeline_parse_value "$idx" fmt) dev=$(func_pipeline_parse_value "$idx" dev) - pcm=$(func_pipeline_parse_value "$idx" pcm) snd=$(func_pipeline_parse_value "$idx" snd) dlogi "Run $TYPE command for the background" cmd_args="$cmd -D$dev -r $rate -c $channel -f $fmt $file_name -q" @@ -108,16 +107,15 @@ do # delay for process run sleep 1 # check process status is correct - sof-process-state.sh $process_id - if [ $? -ne 0 ]; then + sof-process-state.sh $process_id || { func_lib_lsof_error_dump "$snd" dloge "error process state of $cmd" dlogi "dump ps for aplay & arecord" - ps -ef |grep -E 'aplay|arecord' + pgrep -fla "aplay|arecord" dlogi "dump ps for child process" ps --ppid $$ -f exit 1 - fi + } "$(dirname "${BASH_SOURCE[0]}")"/check-suspend-resume.sh "${opt_arr[@]}" || die "suspend resume failed" # check kernel log for each iteration to catch issues @@ -128,7 +126,7 @@ do func_lib_lsof_error_dump "$snd" dloge "process status is abnormal" dlogi "dump ps for aplay & arecord" - ps -ef |grep -E 'aplay|arecord' + pgrep -fla "aplay|arecord" dlogi "dump ps for child process" ps --ppid $$ -f exit 1 From 1e7f1e2b160c72d3b8790bf311a54dd6b5fe0050 Mon Sep 17 00:00:00 2001 From: Greg Galloway Date: Tue, 13 Jun 2023 15:54:42 -0700 Subject: [PATCH 5/5] check-suspend-resume-with-audio.sh: de-dupe directory. There were two references to $(dirname "${BASH_SOURCE[0]}), so a temp variable was created to hold this reference. The two references were then re-written. Signed-off-by: Greg Galloway --- test-case/check-suspend-resume-with-audio.sh | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/test-case/check-suspend-resume-with-audio.sh b/test-case/check-suspend-resume-with-audio.sh index b328ff5e..3feba8bb 100755 --- a/test-case/check-suspend-resume-with-audio.sh +++ b/test-case/check-suspend-resume-with-audio.sh @@ -22,8 +22,9 @@ set -e ## check kernel log and find no errors ## +TESTDIR=$(cd "$(dirname "${BASH_SOURCE[0]}")/" && pwd) # shellcheck source=case-lib/lib.sh -source "$(dirname "${BASH_SOURCE[0]}")"/../case-lib/lib.sh +source "${TESTDIR}"/../case-lib/lib.sh OPT_NAME['l']='loop' OPT_DESC['l']='suspend/resume loop count' OPT_HAS_ARG['l']=1 OPT_VAL['l']=3 @@ -116,7 +117,7 @@ do ps --ppid $$ -f exit 1 } - "$(dirname "${BASH_SOURCE[0]}")"/check-suspend-resume.sh "${opt_arr[@]}" || die "suspend resume failed" + "${TESTDIR}"/check-suspend-resume.sh "${opt_arr[@]}" || die "suspend resume failed" # check kernel log for each iteration to catch issues sof-kernel-log-check.sh "$LOCAL_CHECK_POINT" || die "Caught error in kernel log"