diff --git a/test-case/check-suspend-resume-with-audio.sh b/test-case/check-suspend-resume-with-audio.sh index fa2fbe6a..3feba8bb 100755 --- a/test-case/check-suspend-resume-with-audio.sh +++ b/test-case/check-suspend-resume-with-audio.sh @@ -22,7 +22,9 @@ set -e ## check kernel log and find no errors ## -source $(dirname ${BASH_SOURCE[0]})/../case-lib/lib.sh +TESTDIR=$(cd "$(dirname "${BASH_SOURCE[0]}")/" && pwd) +# shellcheck source=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 @@ -42,7 +44,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" @@ -78,57 +80,54 @@ 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 $(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) + 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 + 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 $(echo $opt) || 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" # 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' + pgrep -fla "aplay|arecord" dlogi "dump ps for child process" ps --ppid $$ -f exit 1