Skip to content

Commit

Permalink
noninteractive-tradefed: improvement on network check
Browse files Browse the repository at this point in the history
Benjamin Copeland suggested some improvements on the
network check lines during the review of PR#534,
which would be better to be submitted as a separate commit here.

The improvements are using top variables, reporting dns failures
separately, and adding some more meaningful debug output,
as well as the output of ifconfig command

Signed-off-by: Yongqin Liu <[email protected]>
  • Loading branch information
liuyq committed Oct 29, 2024
1 parent eb22b4c commit 9ac8ed8
Showing 1 changed file with 26 additions and 5 deletions.
31 changes: 26 additions & 5 deletions automated/android/noninteractive-tradefed/tradefed.sh
Original file line number Diff line number Diff line change
Expand Up @@ -97,15 +97,36 @@ fi
sleep 60

SERVER="www.google.com"
info_msg "device-${ANDROID_SERIAL}: About to check with ping ${SERVER}..."
DNS_TEST_SERVER="8.8.8.8"

info_msg "device-${ANDROID_SERIAL}: Checking network connectivity by pinging ${SERVER}..."

# Try pinging www.google.com first
if adb shell 'ping -c 10 '"${SERVER}"'; echo exitcode: $?' | grep -q "exitcode: 0"; then
report_pass "network-available"
else
info_msg "Ping to ${SERVER} failed, testing DNS by pinging ${DNS_TEST_SERVER}..."
report_fail "network-available"
# print more debug information
adb shell ip address || true
adb shell ping -c 10 8.8.8.8 || true
# to be caught by the yaml file

# If ping to $DNS_TEST_SERVER succeeds, it's likely a DNS issue
if adb shell 'ping -c 10 '"${DNS_TEST_SERVER}"'; echo exitcode: $?' | grep -q "exitcode: 0"; then
report_pass "network-dns-works"

# DNS-specific debug information
info_msg "DNS resolution issue suspected; gathering DNS configuration information..."
adb shell getprop | grep dns || true # Display DNS settings

else
report_fail "network-dns-works"

# General network debug information
info_msg "Ping to ${DNS_TEST_SERVER} failed too..."
info_msg "Network connectivity issue detected; gathering debug information..."
adb shell ip address || true
adb shell ifconfig || true
fi

# Exit with error to trigger YAML file handling
exit 100
fi

Expand Down

0 comments on commit 9ac8ed8

Please sign in to comment.