summaryrefslogtreecommitdiff
path: root/automated/lib
diff options
context:
space:
mode:
authorChase Qi <chase.qi@linaro.org>2017-02-08 08:29:48 +0800
committerMilosz Wasilewski <milosz.wasilewski@linaro.org>2017-02-20 13:19:30 +0000
commit7d317f8b0be720c10394d94283c16583dad34b06 (patch)
tree5de82fba7fe97d5b50f3335989e9c1ecc92a72e0 /automated/lib
parent6f49a1bbb11e50165dd17c4f67f49d8f10c01144 (diff)
automated: android: add cts test
Change-Id: I75eb65bc7de03cbe612b33c4ee69d50cfdc6608d Signed-off-by: Chase Qi <chase.qi@linaro.org>
Diffstat (limited to 'automated/lib')
-rwxr-xr-xautomated/lib/android-test-lib60
-rwxr-xr-xautomated/lib/py_test_lib.py4
2 files changed, 56 insertions, 8 deletions
diff --git a/automated/lib/android-test-lib b/automated/lib/android-test-lib
index 034b153..b66d0da 100755
--- a/automated/lib/android-test-lib
+++ b/automated/lib/android-test-lib
@@ -1,27 +1,71 @@
#!/bin/sh
initialize_adb() {
+ adb devices
if [ -z "${SN}" ]; then
- local number="$(adb devices | grep -wc 'device')"
+ number="$(adb devices | grep -wc 'device')"
if [ "${number}" -gt 1 ]; then
warn_msg "Device not specified; define SN or use '-s'"
error_msg "More than one device or emulator found"
elif [ "${number}" -eq 1 ]; then
- SN="$(adb devices | grep -w 'device' | awk '{print $1}')"
+ SN="$(adb get-serialno)"
export SN
else
error_msg "Device NOT found"
fi
fi
- adb -s "${SN}" shell ls / > /dev/null 2>&1
- if [ $? -eq 0 ]; then
+ if adb -s "${SN}" shell echo "Testing adb connectivity"; then
info_msg "Connected to device ${SN} successfully"
else
error_msg "Unable to connect to device ${SN}"
fi
}
+wait_boot_completed() {
+ timeout="$1"
+ [ "$#" -ne 1 ] && error_msg "Usage: wait_for_boot_completed timeout_in_seconds"
+ end=$(( $(date +%s) + timeout ))
+
+ boot_completed=false
+ while [ "$(date +%s)" -lt "$end" ]; do
+ if adb -s "${SN}" shell getprop sys.boot_completed | grep "1"; then
+ boot_completed=true
+ break
+ else
+ sleep 3
+ fi
+ done
+
+ if "${boot_completed}"; then
+ info_msg "Target booted up completely."
+ else
+ error_msg "wait_boot_completed timed out after ${timeout} seconds"
+ fi
+}
+
+wait_homescreen() {
+ timeout="$1"
+ [ "$#" -ne 1 ] && error_msg "Usage: wait_homescreen timeout_in_seconds"
+ end=$(( $(date +%s) + timeout ))
+
+ homescreen_displayed=false
+ while [ "$(date +%s)" -lt "$end" ]; do
+ if adb -s "${SN}" logcat -sd ActivityManager:I | grep "Displayed com.android.launcher"; then
+ homescreen_displayed=true
+ break
+ else
+ sleep 3
+ fi
+ done
+
+ if "${homescreen_displayed}"; then
+ info_msg "Target booted to homescreen successfully."
+ else
+ error_msg "wait_homescreen timed out after ${timeout} seconds"
+ fi
+}
+
detect_abi() {
# "| tr -d '\r'" is needed here, refer to the below issue.
# https://code.google.com/p/android/issues/detail?id=2482
@@ -35,8 +79,8 @@ detect_abi() {
}
install() {
- local file_path="$1"
- local file_name="$(basename "${file_path}")"
+ file_path="$1"
+ file_name="$(basename "${file_path}")"
if adb -s "${SN}" shell mount | grep system | grep -q ro; then
# Remounts the /system partition on the device read-write
@@ -50,8 +94,8 @@ install() {
}
pull_output() {
- local device_output="$1"
- local host_output="$2"
+ device_output="$1"
+ host_output="$2"
info_msg "Pulling output from devcie ${SN}"
adb -s "${SN}" pull "${device_output}" "${host_output}"
diff --git a/automated/lib/py_test_lib.py b/automated/lib/py_test_lib.py
new file mode 100755
index 0000000..e8932bf
--- /dev/null
+++ b/automated/lib/py_test_lib.py
@@ -0,0 +1,4 @@
+def add_result(result_file, result):
+ print(result)
+ with open(result_file, 'a') as f:
+ f.write('%s\n' % result)