Skip to content

Commit cd1841e

Browse files
committed
Use adb serial to assert adb connection in e2e tests.
Bug: b/519670213
1 parent 1e881ff commit cd1841e

3 files changed

Lines changed: 22 additions & 14 deletions

File tree

e2etests/cvdr/common_utils.sh

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,3 +16,15 @@ function validate_components() {
1616
function cvdr() {
1717
HOME=${PWD} CVDR_USER_CONFIG_PATH=${CVDR_CONFIG_PATH} ${CVDR_PATH} "$@"
1818
}
19+
20+
21+
function verify_adb_connection() {
22+
# TODO(b/448209030): Retrieve serial of the device from the output of cvdr list.
23+
local cvdr_create_output="${1}"
24+
adb_serial=$(echo -e "${cvdr_create_output}" | grep "ADB:" | grep -oE "[^ ]+$")
25+
if [[ -z "${adb_serial}" ]]; then
26+
echo "Device is not adb connected"
27+
exit 1
28+
fi
29+
timeout 30s adb -s ${adb_serial} wait-for-device
30+
}

e2etests/cvdr/cvdr_create_with_branch_test.sh

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,9 @@ cleanup() {
1313
}
1414
trap cleanup EXIT
1515

16-
cvdr create \
17-
--host=${HOSTNAME} \
18-
--branch=aosp-android-latest-release \
19-
--build_target=aosp_cf_x86_64_only_phone-userdebug
16+
out=$(cvdr create \
17+
--host=${HOSTNAME} \
18+
--branch=aosp-android-latest-release \
19+
--build_target=aosp_cf_x86_64_only_phone-userdebug)
2020

21-
# Check ADB connection
22-
# TODO(b/448209030): Retrieve serial of the device from the output of cvdr list.
23-
adb shell uptime
21+
verify_adb_connection "${out}"

e2etests/cvdr/cvdr_create_with_local_srcs_test.sh

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -24,11 +24,9 @@ cleanup() {
2424
}
2525
trap cleanup EXIT
2626

27-
cvdr create \
28-
--host=${HOSTNAME} \
29-
--local_cvd_host_pkg_src=${CVD_HOST_PKG} \
30-
--local_images_zip_src=${IMAGE_ZIP}
27+
out=$(cvdr create \
28+
--host=${HOSTNAME} \
29+
--local_cvd_host_pkg_src=${CVD_HOST_PKG} \
30+
--local_images_zip_src=${IMAGE_ZIP})
3131

32-
# Check ADB connection
33-
# TODO(b/448209030): Retrieve serial of the device from the output of cvdr list.
34-
adb shell uptime
32+
verify_adb_connection "${out}"

0 commit comments

Comments
 (0)