Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Simultaneous playback capture shellcheck fixes #1050

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
48 changes: 25 additions & 23 deletions test-case/simultaneous-playback-capture.sh
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,10 @@
## 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['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['w']='wait' OPT_DESC['w']='sleep for wait duration'
Expand All @@ -42,9 +43,9 @@ loop_cnt=${OPT_VAL['l']}
# get 'both' pcm, it means pcm have same id with different type
declare -A tmp_id_lst
id_lst_str=""
tplg_path=`func_lib_get_tplg_path "$tplg"`
[[ "$?" -ne "0" ]] && die "No available topology for this test case"
for i in $(sof-tplgreader.py $tplg_path -d id -v)
tplg_path=$(func_lib_get_tplg_path "$tplg") ||
die "No available topology for this test case"
for i in $(sof-tplgreader.py "$tplg_path" -d id -v)
do
if [ ! "${tmp_id_lst["$i"]}" ]; then # this id is never used
tmp_id_lst["$i"]=0
Expand All @@ -63,8 +64,8 @@ logger_disabled || func_lib_start_log_collect
func_error_exit()
{
dloge "$*"
kill -9 $aplay_pid && wait $aplay_pid 2>/dev/null
kill -9 $arecord_pid && wait $arecord_pid 2>/dev/null
kill -9 "$aplay_pid" && wait "$aplay_pid" 2>/dev/null
kill -9 "$arecord_pid" && wait "$arecord_pid" 2>/dev/null
exit 1
}

Expand All @@ -74,38 +75,38 @@ do
setup_kernel_check_point
dlogi "===== Testing: (Loop: $i/$loop_cnt) ====="
# following sof-tplgreader, split 'both' pipelines into separate playback & capture pipelines, with playback occurring first
for order in $(seq 0 2 $(expr $PIPELINE_COUNT - 1))
for order in $(seq 0 2 $(( "$PIPELINE_COUNT" - 1)))
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
for order in $(seq 0 2 $(( "$PIPELINE_COUNT" - 1)))
for order in $(seq 0 2 $(( PIPELINE_COUNT - 1)))

do
idx=$order
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)
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)

dlogc "aplay -D $dev -c $channel -r $rate -f $fmt /dev/zero -q &"
aplay -D $dev -c $channel -r $rate -f $fmt /dev/zero -q &
aplay -D "$dev" -c "$channel" -r "$rate" -f "$fmt" /dev/zero -q &
aplay_pid=$!

idx=$[ $order + 1 ]
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)
idx=$(( order + 1 ))
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)

dlogc "arecord -D $dev -c $channel -r $rate -f $fmt /dev/null -q &"
arecord -D $dev -c $channel -r $rate -f $fmt /dev/null -q &
arecord -D "$dev" -c "$channel" -r "$rate" -f "$fmt" /dev/null -q &
arecord_pid=$!

dlogi "Preparing to sleep for $wait_time"
sleep $wait_time

# aplay/arecord processes should be persistent for sleep duration.
dlogi "check pipeline after ${wait_time}s"
kill -0 $aplay_pid
[[ $? -ne 0 ]] && func_error_exit "Error in aplay process after sleep."
kill -0 $aplay_pid ||
func_error_exit "Error in aplay process after sleep."

kill -0 $arecord_pid
[[ $? -ne 0 ]] && func_error_exit "Error in arecord process after sleep."
kill -0 $arecord_pid ||
func_error_exit "Error in arecord process after sleep."

# kill all live processes, successful end of test
dlogc "killing all pipelines"
Expand All @@ -116,3 +117,4 @@ do
# check kernel log for each iteration to catch issues
sof-kernel-log-check.sh "$KERNEL_CHECKPOINT" || die "Caught error in kernel log"
done