Skip to content
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
52 changes: 43 additions & 9 deletions test-case/check-suspend-resume.sh
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,9 @@ set -e
## check kernel log and find no errors
##

TOPDIR=$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)
# shellcheck source=case-lib/lib.sh
source "$(dirname "${BASH_SOURCE[0]}")"/../case-lib/lib.sh
source "$TOPDIR"/case-lib/lib.sh

random_min=3 # wait time should >= 3 for other device wakeup from sleep
random_max=20
Expand All @@ -34,6 +35,9 @@ OPT_HAS_ARG['T']=1 OPT_VAL['T']=""
OPT_NAME['S']='sleep' OPT_DESC['S']='suspend/resume command:rtcwake sleep duration'
OPT_HAS_ARG['S']=1 OPT_VAL['S']=5

OPT_NAME['u']='unload-audio' OPT_DESC['u']='unload audio modules for the test'
OPT_HAS_ARG['u']=0 OPT_VAL['u']=0

OPT_NAME['w']='wait' OPT_DESC['w']='idle time after suspend/resume wakeup'
OPT_HAS_ARG['w']=1 OPT_VAL['w']=5

Expand Down Expand Up @@ -124,16 +128,46 @@ dump_and_die()
die "$@"
}

main()
{
# This is used to workaround https://github.com/thesofproject/sof-test/issues/650,
# which may be caused by kernel issue or unstable network connection.
# TODO: remove this after issue fixed.
sleep 1
sleep 1

local keep_modules=true already_unloaded=false

if [ ${OPT_VAL['u']} = 1 ]; then
keep_modules=false
fi

sudo lsmod | grep -q snd.sof || {
already_unloaded=true
$keep_modules ||
dlogw 'modules already unloaded, ignoring option -u!'
}

$already_unloaded || $keep_modules || "$TOPDIR"/tools/kmod/sof_remove.sh ||
die "Failed to unload audio drivers"

expected_wakeup_count=$(cat /sys/power/wakeup_count)
expected_stats_success=$(cat /sys/power/suspend_stats/success)
save_initial_stats
for i in $(seq 1 $loop_count)
do
sleep_once "$i"
done

Copy link
Member

Choose a reason for hiding this comment

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

should there be a checkpoint here before reloading audio drivers?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

There could be but it's not really necessary because one of the last thing sleep_once did is to check the kernel logs and die if that failed. So if the execution makes it to this point it means the kernel logs are free of errors so far.

Copy link
Member

Choose a reason for hiding this comment

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

I don't disagree, it's more that if you get an error while loading audio drivers it might be a bit difficult to check if the test worked until the point where you start loading driver. You'd get a fail and no intermediate information, that's it.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

You will see the difference because of the different die error message; one is dump_and_die "Caught error in kernel log" whereas the other one below is die "Found kernel error after reloading audio drivers"

Setting the $KERNEL_CHECKPOINT is completely quiet so it won't help in that respect.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Think of $KERNEL_CHECKPOINT as a way to avoid errors from previous tests but inside the same test looking for errors and dying is actually a "stronger" checkpoint.

Copy link
Member

Choose a reason for hiding this comment

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

I will have to trust you on that, I don't have any context here.

$already_unloaded || $keep_modules || "$TOPDIR"/tools/kmod/sof_insert.sh ||
die "Failed to reload audio drivers"
sof-kernel-log-check.sh "$KERNEL_CHECKPOINT" ||
die "Found kernel error after reloading audio drivers"
}

sleep_once()
{
local i="$1"

expected_wakeup_count=$(cat /sys/power/wakeup_count)
expected_stats_success=$(cat /sys/power/suspend_stats/success)
save_initial_stats
for i in $(seq 1 $loop_count)
do
dlogi "===== Round($i/$loop_count) ====="
# set up checkpoint for each iteration
setup_kernel_check_point
Expand All @@ -160,6 +194,6 @@ do
[ "$stats_success" -eq "$expected_stats_success" ] ||
dump_and_die "/sys/power/suspend_stats/success is $stats_success, expected $expected_stats_success"
check_suspend_fails || dump_and_die "some failure counts have changed"
}

done

main "$@"