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
15 changes: 12 additions & 3 deletions Runner/suites/Connectivity/Bluetooth/BT_FW_KMD_Service/run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,11 @@ if ! check_dependencies bluetoothctl hciconfig lsmod; then
echo "$TESTNAME SKIP" > "$RES_FILE"
exit 0
fi

# ---------- Bluetooth runtime check/ readiness ----------
log_info "Waiting for Bluetooth runtime readiness..."
bt_wait_ready 60 2 || true

# ---------- Bluetooth service / daemon ----------
log_info "Checking if bluetoothd (or bluetooth.service) is running..."
if btsvcactive; then
Expand Down Expand Up @@ -196,11 +201,15 @@ else
fi

if [ -z "$ADAPTER" ]; then
log_warn "No HCI adapter found; skipping BT FW/KMD test."
echo "$TESTNAME SKIP" > "./$TESTNAME.res"
log_warn "No HCI adapter found."

if [ "$FAIL_COUNT" -gt 0 ]; then
echo "$TESTNAME FAIL" > "$RES_FILE"
else
echo "$TESTNAME SKIP" > "$RES_FILE"
fi
exit 0
fi

# ---------- BD address sanity check ----------
if [ -n "$ADAPTER" ]; then
if btbdok "$ADAPTER"; then
Expand Down
63 changes: 62 additions & 1 deletion Runner/utils/lib_bluetooth.sh
Original file line number Diff line number Diff line change
Expand Up @@ -1891,7 +1891,13 @@ btfwpresent() {
"msbtfw*.tlv" \
"msnv*.bin" \
"cmbtfw*.tlv" \
"cmnv*.bin"
"cmnv*.bin" \
"hpbtfw*.tlv" \
"wcnhpbtfw*.tlv" \
"hmtbtfw*.tlv" \
"hmtnv*.bin" \
"hpnv*.bin" \
"wcnhpnv*.bin"
do
for file in "$d"/$pattern; do
if [ -e "$file" ]; then
Expand All @@ -1906,6 +1912,61 @@ btfwpresent() {
return 1
}

bt_wait_ready() {
max_wait="${1:-60}"
sleep_step="${2:-2}"
waited=0
started_service=0

if [ -z "$max_wait" ]; then
max_wait=60
fi
if [ -z "$sleep_step" ]; then
sleep_step=2
fi

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

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

while [ "$waited" -lt "$max_wait" ]; do
if btsvcactive && bthcipresent; then
log_info "Bluetooth runtime became ready after ${waited}s."
return 0
fi

if [ "$started_service" -eq 0 ]; then
if command -v systemctl >/dev/null 2>&1; then
if ! btsvcactive; then
log_info "Bluetooth service not active yet, attempting start."
systemctl start bluetooth.service >/dev/null 2>&1 || true
fi
fi
started_service=1
fi

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

log_warn "Bluetooth runtime did not become ready within ${max_wait}s."
return 1
}

btfwloaded() {
# ---- Configurable patterns (override via env if needed) ----
# "Final success" (strongest marker that FW+UART setup completed)
Expand Down
Loading