diff --git a/Runner/suites/Kernel/Baseport/adsp_remoteproc/run.sh b/Runner/suites/Kernel/Baseport/adsp_remoteproc/run.sh index 833b675c3..802f8f5ac 100755 --- a/Runner/suites/Kernel/Baseport/adsp_remoteproc/run.sh +++ b/Runner/suites/Kernel/Baseport/adsp_remoteproc/run.sh @@ -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) @@ -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 @@ -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" @@ -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) ------------------- @@ -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 diff --git a/Runner/suites/Kernel/Baseport/cdsp_remoteproc/run.sh b/Runner/suites/Kernel/Baseport/cdsp_remoteproc/run.sh index 45beda881..fad845df7 100755 --- a/Runner/suites/Kernel/Baseport/cdsp_remoteproc/run.sh +++ b/Runner/suites/Kernel/Baseport/cdsp_remoteproc/run.sh @@ -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}" @@ -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 @@ -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" @@ -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 ---------------------------------------------------- @@ -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 diff --git a/Runner/suites/Kernel/Baseport/gpdsp_remoteproc/run.sh b/Runner/suites/Kernel/Baseport/gpdsp_remoteproc/run.sh index aa07858d9..a7a3e5df3 100755 --- a/Runner/suites/Kernel/Baseport/gpdsp_remoteproc/run.sh +++ b/Runner/suites/Kernel/Baseport/gpdsp_remoteproc/run.sh @@ -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}" @@ -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 @@ -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" @@ -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 @@ -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 diff --git a/Runner/suites/Kernel/Baseport/wpss_remoteproc/run.sh b/Runner/suites/Kernel/Baseport/wpss_remoteproc/run.sh index df72f35de..617e08f7e 100755 --- a/Runner/suites/Kernel/Baseport/wpss_remoteproc/run.sh +++ b/Runner/suites/Kernel/Baseport/wpss_remoteproc/run.sh @@ -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}" @@ -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 @@ -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" @@ -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 ---------- @@ -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 diff --git a/Runner/suites/Multimedia/Audio/AudioRecord/run.sh b/Runner/suites/Multimedia/Audio/AudioRecord/run.sh index 37d597247..6a067dea2 100755 --- a/Runner/suites/Multimedia/Audio/AudioRecord/run.sh +++ b/Runner/suites/Multimedia/Audio/AudioRecord/run.sh @@ -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 @@ -960,6 +960,29 @@ auto_secs_for() { esac } +# Add startup headroom to the capture watchdog. +# +# 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. @@ -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")" if [ -n "$TIMEOUT" ] && [ "$TIMEOUT" != "0" ]; then effective_timeout="$TIMEOUT" fi @@ -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 diff --git a/Runner/utils/functestlib.sh b/Runner/utils/functestlib.sh index e8ab66ff8..99ca72aa8 100755 --- a/Runner/utils/functestlib.sh +++ b/Runner/utils/functestlib.sh @@ -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 @@ -3900,6 +3901,29 @@ wait_remoteproc_state() { done } +# wait_remoteproc_boot_state