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
2 changes: 1 addition & 1 deletion Runner/suites/Connectivity/WiFi/WiFi_OnOff/run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ mhi
EOF
)"

WIFI_WAIT_SECS="${WIFI_WAIT_SECS:-30}"
WIFI_WAIT_SECS="${WIFI_WAIT_SECS:-60}"
WIFI_WAIT_STEP_SECS="${WIFI_WAIT_STEP_SECS:-2}"
WIFI_PROBE_LOG_DIR="${WIFI_PROBE_LOG_DIR:-./wifi_onoff_dmesg}"
WIFI_PROBE_LOG_TAG="${WIFI_PROBE_LOG_TAG:-${TESTNAME}/probe}"
Expand Down
50 changes: 40 additions & 10 deletions Runner/utils/lib_connectivity.sh
Original file line number Diff line number Diff line change
Expand Up @@ -15,43 +15,73 @@ wifi_unblock_rfkill() {
# Retry WiFi interface discovery for a bounded time while unblocking rfkill.
# Prints interface name on success and returns non-zero on timeout.
wait_for_wifi_interface() {
max_wait="${1:-30}"
max_wait="${1:-60}"
sleep_step="${2:-2}"
waited=0
iface=""

settle_done=0

case "$max_wait" in
''|*[!0-9]*)
max_wait=30
max_wait=60
;;
esac

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Extra white-space

case "$sleep_step" in
''|*[!0-9]*)
sleep_step=2
;;
esac

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Extra white-space

if [ "$max_wait" -le 0 ] 2>/dev/null; then
max_wait=30
max_wait=60
fi

if [ "$sleep_step" -le 0 ] 2>/dev/null; then
sleep_step=2
fi


# Keep stdout reserved only for the detected interface name because callers
# commonly use command substitution:
# wifi_iface="$(wait_for_wifi_interface ...)"
#
# All diagnostics must go to stderr to avoid contaminating the returned
# interface name.
log_info "Waiting up to ${max_wait}s for WiFi interface creation" >&2

while [ "$waited" -lt "$max_wait" ]; do
wifi_unblock_rfkill

iface="$(get_wifi_interface 2>/dev/null || true)"
if [ -n "$iface" ]; then
printf '%s\n' "$iface"
return 0
fi


if [ "$settle_done" -eq 0 ]; then
settle_done=1

if command -v udevadm >/dev/null 2>&1; then
log_info "No WiFi interface yet; triggering net add uevents and waiting for udev settle" >&2
udevadm trigger --action=add --subsystem-match=net >/dev/null 2>&1 || true
udevadm settle --timeout=5 >/dev/null 2>&1 || true

iface="$(get_wifi_interface 2>/dev/null || true)"
if [ -n "$iface" ]; then
printf '%s\n' "$iface"
return 0
fi
fi
fi

sleep "$sleep_step"
waited=$((waited + sleep_step))

if [ "$waited" -gt 0 ] && [ $((waited % 10)) -eq 0 ]; then
log_info "Still waiting for WiFi interface... waited=${waited}s/${max_wait}s" >&2
fi
done

return 1
}

Expand Down
Loading