Skip to content
Open
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
19 changes: 17 additions & 2 deletions Runner/suites/Kernel/Baseport/adsp_remoteproc/run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ log_info "------------------- Starting $TESTNAME Testcase ----------------------
log_info "=== Test Initialization ==="

# --- Tunables (override via env) ----------------------------------------------
BOOT_TO="${BOOT_TO:-30}" # wait for a processor to reach running (s)
STOP_TO="${STOP_TO:-10}" # remoteproc stop timeout (s)
START_TO="${START_TO:-10}" # remoteproc start timeout (s)
POLL_I="${POLL_I:-1}" # state poll interval (s)
Expand All @@ -53,10 +54,11 @@ FATAL_ON_UNSUSPENDED="${FATAL_ON_UNSUSPENDED:-0}" # 1 = abort if audio not suspe
DO_SSR=0

usage() {
echo "Usage: $0 [--ssr] [--pre-stop-delay SEC] [--fatal-on-unsuspended] [--stop-to SEC] [--start-to SEC] [--poll-i SEC]" >&2
echo "Usage: $0 [--ssr] [--pre-stop-delay SEC] [--fatal-on-unsuspended] [--boot-to SEC] [--stop-to SEC] [--start-to SEC] [--poll-i SEC]" >&2
echo " --ssr Perform ADSP stop/start (SSR). Default: OFF" >&2
echo " --pre-stop-delay SEC Delay before stop when --ssr is used (default: $PRE_STOP_DELAY)" >&2
echo " --fatal-on-unsuspended Abort if audio not suspended/unsupported after delay (only meaningful with --ssr)" >&2
echo " --boot-to SEC Boot-state wait (default: $BOOT_TO, 0 disables)" >&2
echo " --stop-to SEC Stop timeout (default: $STOP_TO)" >&2
echo " --start-to SEC Start timeout (default: $START_TO)" >&2
echo " --poll-i SEC Poll interval (default: $POLL_I)" >&2
Expand All @@ -81,6 +83,15 @@ while [ $# -gt 0 ]; do
FATAL_ON_UNSUSPENDED=1
shift
;;
--boot-to)
if [ $# -lt 2 ]; then
log_fail "Missing value for --boot-to"
usage
exit 2
fi
BOOT_TO="$2"
shift 2
;;
--stop-to)
if [ $# -lt 2 ]; then
log_fail "Missing value for --stop-to"
Expand Down Expand Up @@ -120,7 +131,7 @@ while [ $# -gt 0 ]; do
esac
done

log_info "Tunables: STOP_TO=$STOP_TO START_TO=$START_TO POLL_I=$POLL_I PRE_STOP_DELAY=$PRE_STOP_DELAY FATAL_ON_UNSUSPENDED=$FATAL_ON_UNSUSPENDED"
log_info "Tunables: BOOT_TO=$BOOT_TO STOP_TO=$STOP_TO START_TO=$START_TO POLL_I=$POLL_I PRE_STOP_DELAY=$PRE_STOP_DELAY FATAL_ON_UNSUSPENDED=$FATAL_ON_UNSUSPENDED"
log_info "SSR control: DO_SSR=$DO_SSR (0=no stop/start, 1=do stop/start)"

# --- Audio readiness snapshot (no hardcoding, no long wait) -------------------
Expand Down Expand Up @@ -265,6 +276,10 @@ while IFS='|' read -r rpath rstate rfirm rname; do
start_res="NA"
ping_res="SKIPPED"

# Boot check: the instance list snapshot was taken moments after login,
# so let a processor still coming up reach running before judging it.
rstate="$(wait_remoteproc_boot_state "$rpath" "$inst_id" "$BOOT_TO" "$POLL_I")"

if [ "$rstate" = "running" ]; then
log_pass "$inst_id: boot check PASS"
else
Expand Down
20 changes: 17 additions & 3 deletions Runner/suites/Kernel/Baseport/cdsp_remoteproc/run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ log_info "------------------- Starting $TESTNAME Testcase ----------------------
log_info "=== Test Initialization ==="

# Timeouts (can be overridden via env)
BOOT_TO="${BOOT_TO:-30}"
STOP_TO="${STOP_TO:-10}"
START_TO="${START_TO:-10}"
POLL_I="${POLL_I:-1}"
Expand All @@ -49,8 +50,9 @@ POLL_I="${POLL_I:-1}"
DO_SSR=0

usage() {
echo "Usage: $0 [--ssr] [--stop-to SEC] [--start-to SEC] [--poll-i SEC]" >&2
echo "Usage: $0 [--ssr] [--boot-to SEC] [--stop-to SEC] [--start-to SEC] [--poll-i SEC]" >&2
echo " --ssr Perform CDSP stop/start (SSR). Default: OFF" >&2
echo " --boot-to SEC Boot-state wait (default: $BOOT_TO, 0 disables)" >&2
echo " --stop-to SEC Stop timeout (default: $STOP_TO)" >&2
echo " --start-to SEC Start timeout (default: $START_TO)" >&2
echo " --poll-i SEC Poll interval (default: $POLL_I)" >&2
Expand All @@ -62,6 +64,15 @@ while [ $# -gt 0 ]; do
DO_SSR=1
shift
;;
--boot-to)
if [ $# -lt 2 ]; then
log_fail "Missing value for --boot-to"
usage
exit 2
fi
BOOT_TO="$2"
shift 2
;;
--stop-to)
if [ $# -lt 2 ]; then
log_fail "Missing value for --stop-to"
Expand Down Expand Up @@ -101,7 +112,7 @@ while [ $# -gt 0 ]; do
esac
done

log_info "Tunables: STOP_TO=$STOP_TO START_TO=$START_TO POLL_I=$POLL_I"
log_info "Tunables: BOOT_TO=$BOOT_TO STOP_TO=$STOP_TO START_TO=$START_TO POLL_I=$POLL_I"
log_info "SSR control: DO_SSR=$DO_SSR (0=no stop/start, 1=do stop/start)"

# --- Device Tree gate ----------------------------------------------------
Expand Down Expand Up @@ -145,7 +156,10 @@ while IFS='|' read -r rpath rstate rfirm rname; do
start_res="NA"
ping_res="SKIPPED"

# Boot check
# Boot check: the instance list snapshot was taken moments after login,
# so let a processor still coming up reach running before judging it.
rstate="$(wait_remoteproc_boot_state "$rpath" "$inst_id" "$BOOT_TO" "$POLL_I")"

if [ "$rstate" = "running" ]; then
log_pass "$inst_id: boot check PASS"
else
Expand Down
20 changes: 17 additions & 3 deletions Runner/suites/Kernel/Baseport/gpdsp_remoteproc/run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ log_info "------------------- Starting $TESTNAME Testcase ----------------------
log_info "=== Test Initialization ==="

# Tunables
BOOT_TO="${BOOT_TO:-30}"
STOP_TO="${STOP_TO:-10}"
START_TO="${START_TO:-10}"
POLL_I="${POLL_I:-1}"
Expand All @@ -49,8 +50,9 @@ POLL_I="${POLL_I:-1}"
DO_SSR=0

usage() {
echo "Usage: $0 [--ssr] [--stop-to SEC] [--start-to SEC] [--poll-i SEC]" >&2
echo "Usage: $0 [--ssr] [--boot-to SEC] [--stop-to SEC] [--start-to SEC] [--poll-i SEC]" >&2
echo " --ssr Perform $FW stop/start (SSR). Default: OFF" >&2
echo " --boot-to SEC Boot-state wait (default: $BOOT_TO, 0 disables)" >&2
echo " --stop-to SEC Stop timeout (default: $STOP_TO)" >&2
echo " --start-to SEC Start timeout (default: $START_TO)" >&2
echo " --poll-i SEC Poll interval (default: $POLL_I)" >&2
Expand All @@ -62,6 +64,15 @@ while [ $# -gt 0 ]; do
DO_SSR=1
shift
;;
--boot-to)
if [ $# -lt 2 ]; then
log_fail "Missing value for --boot-to"
usage
exit 2
fi
BOOT_TO="$2"
shift 2
;;
--stop-to)
if [ $# -lt 2 ]; then
log_fail "Missing value for --stop-to"
Expand Down Expand Up @@ -101,7 +112,7 @@ while [ $# -gt 0 ]; do
esac
done

log_info "Tunables: STOP_TO=$STOP_TO START_TO=$START_TO POLL_I=$POLL_I"
log_info "Tunables: BOOT_TO=$BOOT_TO STOP_TO=$STOP_TO START_TO=$START_TO POLL_I=$POLL_I"
log_info "SSR control: DO_SSR=$DO_SSR (0=no stop/start, 1=do stop/start)"

# DT check for entries
Expand Down Expand Up @@ -142,7 +153,10 @@ while IFS='|' read -r rpath rstate rfirm rname; do
start_res="NA"
ping_res="SKIPPED"

# Boot check
# Boot check: the instance list snapshot was taken moments after login,
# so let a processor still coming up reach running before judging it.
rstate="$(wait_remoteproc_boot_state "$rpath" "$inst_id" "$BOOT_TO" "$POLL_I")"

if [ "$rstate" = "running" ]; then
log_pass "$inst_id: boot check PASS"
else
Expand Down
20 changes: 17 additions & 3 deletions Runner/suites/Kernel/Baseport/wpss_remoteproc/run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ log_info "------------------- Starting $TESTNAME Testcase ----------------------
log_info "=== Test Initialization ==="

# Tunables
BOOT_TO="${BOOT_TO:-30}"
STOP_TO="${STOP_TO:-10}"
START_TO="${START_TO:-10}"
POLL_I="${POLL_I:-1}"
Expand All @@ -52,8 +53,9 @@ POLL_I="${POLL_I:-1}"
DO_SSR=0

usage() {
echo "Usage: $0 [--ssr] [--stop-to SEC] [--start-to SEC] [--poll-i SEC]" >&2
echo "Usage: $0 [--ssr] [--boot-to SEC] [--stop-to SEC] [--start-to SEC] [--poll-i SEC]" >&2
echo " --ssr Perform WPSS stop/start (SSR). Default: OFF" >&2
echo " --boot-to SEC Boot-state wait (default: $BOOT_TO, 0 disables)" >&2
echo " --stop-to SEC Stop timeout (default: $STOP_TO)" >&2
echo " --start-to SEC Start timeout (default: $START_TO)" >&2
echo " --poll-i SEC Poll interval (default: $POLL_I)" >&2
Expand All @@ -65,6 +67,15 @@ while [ $# -gt 0 ]; do
DO_SSR=1
shift
;;
--boot-to)
if [ $# -lt 2 ]; then
log_fail "Missing value for --boot-to"
usage
exit 2
fi
BOOT_TO="$2"
shift 2
;;
--stop-to)
if [ $# -lt 2 ]; then
log_fail "Missing value for --stop-to"
Expand Down Expand Up @@ -104,7 +115,7 @@ while [ $# -gt 0 ]; do
esac
done

log_info "Tunables: STOP_TO=$STOP_TO START_TO=$START_TO POLL_I=$POLL_I"
log_info "Tunables: BOOT_TO=$BOOT_TO STOP_TO=$STOP_TO START_TO=$START_TO POLL_I=$POLL_I"
log_info "SSR control: DO_SSR=$DO_SSR (0=no stop/start, 1=do stop/start)"

# ---------- Try remoteproc path ----------
Expand Down Expand Up @@ -139,7 +150,10 @@ if [ -n "$rp_entries" ]; then
start_res="NA"
ping_res="SKIPPED"

# Boot check
# Boot check: the instance list snapshot was taken moments after login,
# so let a processor still coming up reach running before judging it.
rstate="$(wait_remoteproc_boot_state "$rpath" "$inst" "$BOOT_TO" "$POLL_I")"

if [ "$rstate" = "running" ]; then
log_pass "$inst: boot check PASS"
else
Expand Down
29 changes: 26 additions & 3 deletions Runner/suites/Multimedia/Audio/AudioRecord/run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -539,7 +539,7 @@ if [ -n "$CONFIG_NAMES" ] && [ -n "$CONFIG_FILTER" ]; then
CONFIG_FILTER=""
fi

log_info "Args: backend=${AUDIO_BACKEND:-auto} source=$SRC_CHOICE overlay=$AUDIO_OVERLAY_REQUESTED loops=$LOOPS durations='$DURATIONS' record_seconds=$RECORD_SECONDS timeout=$TIMEOUT strict=$STRICT signal_strict=$AUDIO_RECORD_STRICT_SIGNAL dmesg=$DMESG_SCAN bootstrap=$AUDIO_BOOTSTRAP_MODE runtime_dir=${AUDIO_RUNTIME_DIR:-auto}"
log_info "Args: backend=${AUDIO_BACKEND:-auto} source=$SRC_CHOICE overlay=$AUDIO_OVERLAY_REQUESTED loops=$LOOPS durations='$DURATIONS' record_seconds=$RECORD_SECONDS timeout=$TIMEOUT start_grace=${AUDIO_RECORD_START_GRACE:-5} strict=$STRICT signal_strict=$AUDIO_RECORD_STRICT_SIGNAL dmesg=$DMESG_SCAN bootstrap=$AUDIO_BOOTSTRAP_MODE runtime_dir=${AUDIO_RUNTIME_DIR:-auto}"

# Resolve backend (allow minimal-build ALSA capture fallback)
if [ -z "$AUDIO_BACKEND" ]; then
Expand Down Expand Up @@ -960,6 +960,29 @@ auto_secs_for() {
esac
}

# Add startup headroom to the capture watchdog.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

audio_record_timeout_with_grace() is reusable audio timeout policy and is called from both record execution paths.
Move it to the shared audio library next to the timeout/recording helpers, then have this runner only select the requested duration and invoke the helper. This keeps timeout semantics testable and prevents future audio suites from copying policy into their own run.sh.

#
# pw-record has no duration flag on this path, so the watchdog is what ends
# the recording, and its clock starts before PipeWire has opened the device:
# a slow start is taken out of the recording and fails the duration check.
# Grant AUDIO_RECORD_START_GRACE extra watchdog seconds so the requested
# duration is still captured. The duration validated against is unchanged,
# and an explicit --timeout still overrides the watchdog.
audio_record_timeout_with_grace() {
artg_requested="$(audio_parse_secs "$1" 2>/dev/null || echo 0)"
artg_grace="${AUDIO_RECORD_START_GRACE:-5}"

is_unsigned_number "$artg_grace" || artg_grace=5

if [ "${artg_requested:-0}" -gt 0 ] 2>/dev/null &&
[ "$artg_grace" -gt 0 ] 2>/dev/null; then
printf '%ss\n' "$((artg_requested + artg_grace))"
return 0
fi

printf '%s\n' "$1"
}

# Validate the final capture selected by the existing backend/retry flow.
# Size remains useful only for deciding whether compatibility fallbacks should
# run; PASS requires a structurally valid WAV with acceptable sample content.
Expand Down Expand Up @@ -1079,7 +1102,7 @@ if [ "$USE_CONFIG_DISCOVERY" = "true" ]; then

while [ "$i" -le "$LOOPS" ]; do
iso="$(date -u +%Y-%m-%dT%H:%M:%SZ)"
effective_timeout="$secs"
effective_timeout="$(audio_record_timeout_with_grace "$secs")"

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Keep startup headroom separate from requested recording duration. For PipeWire and PulseAudio, the watchdog is what stops the recorder, so this changes every fast-start capture from RECORD_SECONDS to RECORD_SECONDS + AUDIO_RECORD_START_GRACE. A ten-case matrix adds 50 seconds per loop by default and produces longer artifacts than requested. Apply the grace only while waiting for the recorder to become active, then start the requested-duration timer, rather than extending the whole capture watchdog.

if [ -n "$TIMEOUT" ] && [ "$TIMEOUT" != "0" ]; then
effective_timeout="$TIMEOUT"
fi
Expand Down Expand Up @@ -1384,7 +1407,7 @@ else

while [ "$i" -le "$LOOPS" ]; do
iso="$(date -u +%Y-%m-%dT%H:%M:%SZ)"
effective_timeout="$secs"
effective_timeout="$(audio_record_timeout_with_grace "$secs")"
if [ -n "$TIMEOUT" ] && [ "$TIMEOUT" != "0" ]; then
effective_timeout="$TIMEOUT"
fi
Expand Down
28 changes: 26 additions & 2 deletions Runner/utils/functestlib.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3886,12 +3886,13 @@ wait_remoteproc_state() {
*) rpath="/sys/class/remoteproc/$rp" ;;
esac

start_ts=$(date +%s)
# Monotonic, so an NTP step cannot skew the wait.
start_ts=$(get_monotonic_seconds)
while :; do
cur=$(get_remoteproc_state "$rpath")
[ "$cur" = "$want" ] && return 0

now_ts=$(date +%s)
now_ts=$(get_monotonic_seconds)
[ $((now_ts - start_ts)) -ge "$to" ] && {
log_info "Waiting for state='$want' timed out (got='$cur')..."
return 1
Expand All @@ -3900,6 +3901,29 @@ wait_remoteproc_state() {
done
}

# wait_remoteproc_boot_state <rproc> <label> [timeout_s] [poll_s]
# Boot check for suites whose instance list snapshots state right after login:
# give a processor still coming up timeout_s (default 30, 0 keeps the single
# shot) to reach running, then print the refreshed state.
wait_remoteproc_boot_state() {
wrbs_rp="$1"
wrbs_label="${2:-$1}"
wrbs_to="${3:-30}"
wrbs_poll="${4:-1}"

is_unsigned_number "$wrbs_to" || wrbs_to=30

wrbs_state="$(get_remoteproc_state "$wrbs_rp")"
if [ "$wrbs_state" != "running" ] && [ "$wrbs_to" -gt 0 ]; then
# stderr: stdout carries the state for command substitution.
log_info "$wrbs_label: state=$wrbs_state, waiting up to ${wrbs_to}s for state=running" >&2
wait_remoteproc_state "$wrbs_rp" running "$wrbs_to" "$wrbs_poll" >&2 || true
wrbs_state="$(get_remoteproc_state "$wrbs_rp")"
fi

printf '%s\n' "$wrbs_state"
}

# Stop remoteproc
stop_remoteproc() {
rproc_path="$1"
Expand Down
Loading
Loading