Skip to content

Commit d64bb44

Browse files
committed
Added adb server restart and made ADB wait logic robust across reboot in LAVA
Signed-off-by: Nitin Nakka <nitinn@qti.qualcomm.com>
1 parent 06b39f5 commit d64bb44

File tree

2 files changed

+29
-32
lines changed

2 files changed

+29
-32
lines changed

host-tools/SuspendResume/run.sh

Lines changed: 16 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -34,22 +34,26 @@ res_file="./$TESTNAME.res"
3434
log_info "Rebooting device to ensure adb functionality..."
3535
sync
3636
sleep 2
37-
reboot -f
37+
reboot
3838
sleep 30
3939

40+
# Restart adb server
41+
log_info "Restarting adb server..."
42+
adb kill-server
43+
sleep 2
44+
adb start-server
45+
sleep 2
46+
4047
# Wait for adb to detect the device (non-blocking, 30s timeout)
4148
log_info "Waiting for device to be detected by adb (timeout: 30s)..."
42-
WAIT_COUNT=0
43-
DEVICE_DETECTED=0
44-
while [ $WAIT_COUNT -lt 30 ]; do
45-
if adb get-state >/dev/null 2>&1; then
46-
DEVICE_DETECTED=1
47-
log_info "Device detected by adb after ${WAIT_COUNT}s"
48-
break
49-
fi
50-
sleep 1
51-
WAIT_COUNT=$((WAIT_COUNT + 1))
52-
done
49+
50+
if timeout 30s adb wait-for-device >/dev/null 2>&1; then
51+
log_info "Device detected by adb"
52+
else
53+
log_warn "$TESTNAME SKIP: Device not detected by adb within timeout"
54+
echo "SKIP" > "$res_file"
55+
exit 0
56+
fi
5357

5458
if [ $DEVICE_DETECTED -eq 0 ]; then
5559
log_warn "$TESTNAME SKIP: Device not detected by adb within timeout"

host-tools/run-test.sh

Lines changed: 13 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -40,28 +40,21 @@ sleep 2
4040
reboot -f
4141
sleep 30
4242

43+
# Restart adb server
44+
log_info "Restarting adb server..."
45+
adb kill-server
46+
sleep 2
47+
adb start-server
48+
sleep 2
49+
4350
# Wait for adb to detect the device (non-blocking, 30s timeout)
4451
log_info "Waiting for device to be detected by adb (timeout: 30s)..."
45-
WAIT_COUNT=0
46-
DEVICE_DETECTED=0
47-
while [ $WAIT_COUNT -lt 30 ]; do
48-
if adb get-state >/dev/null 2>&1; then
49-
DEVICE_DETECTED=1
50-
log_info "Device detected by adb after ${WAIT_COUNT}s"
51-
break
52-
fi
53-
sleep 1
54-
WAIT_COUNT=$((WAIT_COUNT + 1))
55-
done
56-
57-
if [ $DEVICE_DETECTED -eq 0 ]; then
58-
if [ "$1" = "all" ]; then
59-
log_warn "ALL_TESTS SKIP: Device not detected by adb within timeout"
60-
echo "SKIP" > "ALL_TESTS.res"
61-
else
62-
log_warn "$1 SKIP: Device not detected by adb within timeout"
63-
echo "SKIP" > "$1.res"
64-
fi
52+
53+
if timeout 30s adb wait-for-device >/dev/null 2>&1; then
54+
log_info "Device detected by adb"
55+
else
56+
log_warn "$TESTNAME SKIP: Device not detected by adb within timeout"
57+
echo "SKIP" > "$res_file"
6558
exit 0
6659
fi
6760

0 commit comments

Comments
 (0)