Skip to content

Commit

Permalink
check-suspend-resume: new main() and move more code into a function
Browse files Browse the repository at this point in the history
Per rationale detailed in #740.

Also add new $TOPDIR constant.

Absolutely zero functional change.

Signed-off-by: Marc Herbert <[email protected]>
  • Loading branch information
marc-hb committed Jun 17, 2022
1 parent 1ef9399 commit ebb53de
Showing 1 changed file with 20 additions and 9 deletions.
29 changes: 20 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 Down Expand Up @@ -124,16 +125,26 @@ 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

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
}

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 +171,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 "$@"

0 comments on commit ebb53de

Please sign in to comment.