diff --git a/Runner/suites/Connectivity/Bluetooth/BT_FW_KMD_Service/run.sh b/Runner/suites/Connectivity/Bluetooth/BT_FW_KMD_Service/run.sh index 60b56cbc..f371d5b4 100755 --- a/Runner/suites/Connectivity/Bluetooth/BT_FW_KMD_Service/run.sh +++ b/Runner/suites/Connectivity/Bluetooth/BT_FW_KMD_Service/run.sh @@ -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 @@ -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 diff --git a/Runner/utils/lib_bluetooth.sh b/Runner/utils/lib_bluetooth.sh index b8e6b8b3..8fce0f0c 100755 --- a/Runner/utils/lib_bluetooth.sh +++ b/Runner/utils/lib_bluetooth.sh @@ -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 @@ -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)