Skip to content
Merged
Show file tree
Hide file tree
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
35 changes: 35 additions & 0 deletions case-lib/lib.sh
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,41 @@ if [ ! "$SOFCARD" ]; then
awk '/sof-[a-z]/ && $1 ~ /^[0-9]+$/ { $1=$1; print $1; exit 0;}')
fi

# Arguments:
#
# - poll interval in secs
# - timeout in secs, rounded up to the next interval
# - command and arguments
#
poll_wait_for()
{
test $# -ge 3 ||
die "poll_wait_for() invoked with $# arguments"

Choose a reason for hiding this comment

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

if the user use it wrong, maybe we should inform the correct usage?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

We could but this function is not meant to be used outside sof-test, so the only user using it wrong is either you or me.

More seriously, the only user using it wrong is someone writing sof-test code who can just open the file and look at the header above = what they should have done already before even starting to use the function.


local ival="$1"; shift
local maxtime="$1"; shift

printf "Polling '%s' every ${ival}s for ${maxtime}s\n" "$*"

local waited=0 attempts=1 pass=true
while ! "$@"; do
if [ "$waited" -ge "$maxtime" ]; then
pass=false
break;
fi
sleep "$ival"
: $((attempts++)); waited=$((waited+ival))
done
local timeinfo="${waited}s and ${attempts} attempts"
if $pass; then
printf "Completed '%s' after ${timeinfo}\n" "$*"
else
>&2 printf "Command '%s' timed out after ${timeinfo}\n" "$*"
fi

$pass
}

setup_kernel_check_point()
{
# Make the check point $SOF_TEST_INTERVAL second(s) earlier to avoid
Expand Down
3 changes: 2 additions & 1 deletion test-case/check-kmod-load-unload.sh
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,8 @@ do
die "Found error(s) in kernel log after module insertion"

dlogi "checking if firmware is loaded successfully"
if sof_firmware_boot_complete --since=@"$KERNEL_CHECKPOINT"; then
# Check every 1s for 10s
if poll_wait_for 1 10 sof_firmware_boot_complete --since=@"$KERNEL_CHECKPOINT"; then
grep_firmware_info_in_logs --since=@"$KERNEL_CHECKPOINT"
else
die "Failed to load firmware after module insertion"
Expand Down