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
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
63 changes: 46 additions & 17 deletions Runner/utils/lib_connectivity.sh
Original file line number Diff line number Diff line change
Expand Up @@ -19,39 +19,68 @@ wait_for_wifi_interface() {
sleep_step="${2:-2}"
waited=0
iface=""

settle_done=0

case "$max_wait" in
''|*[!0-9]*)
max_wait=30
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Should this be updated to 60 too?

;;
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
fi
if [ "$sleep_step" -le 0 ] 2>/dev/null; then
sleep_step=2
fi

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

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


# Keep stdout reserved for the detected interface name. This helper is
# commonly used through command substitution, so all diagnostics from the
# wait loop must go to stderr. The final interface is printed through fd 3,
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Should the README be also updated to let the user know that fd 3 is in use and they cannot use it.

# which preserves the caller's original stdout.
{
log_info "Waiting up to ${max_wait}s for WiFi interface creation"

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" >&3
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 uevents and waiting for udev settle"
udevadm trigger --subsystem-match=net >/dev/null 2>&1 || true
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

This will re-trigger on all network interfaces, which are already settled.
Perhaps this can be done

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" >&3
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"
fi
done
} 3>&1 1>&2

return 1
}

Expand Down
Loading