aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVishal Bhoj <vishal.bhoj@linaro.org>2018-10-03 15:58:36 +0530
committerVishal Bhoj <vishal.bhoj@linaro.org>2018-10-04 17:18:24 +0530
commit86116c4947a95e0f3877cea02c356a2fa4f461a8 (patch)
treede0390f64bec3e311e73312d443da4c7dfb1bc91
parent09f9569f2f8e92528be0523373cdc32115ab7d52 (diff)
android: test to report android boot
Change-Id: I6a2f3b7d984740eabc08d2a8e819bfa33252d021 Signed-off-by: Vishal Bhoj <vishal.bhoj@linaro.org>
-rwxr-xr-xautomated/android/boottest/boottest.sh87
-rw-r--r--automated/android/boottest/boottest.yaml28
2 files changed, 115 insertions, 0 deletions
diff --git a/automated/android/boottest/boottest.sh b/automated/android/boottest/boottest.sh
new file mode 100755
index 00000000..fa1d2224
--- /dev/null
+++ b/automated/android/boottest/boottest.sh
@@ -0,0 +1,87 @@
+#!/bin/sh -e
+# shellcheck disable=SC1091
+
+ANDROID_SERIAL=""
+BOOT_TIMEOUT="300"
+OUTPUT="$(pwd)/output"
+export RESULT_FILE="${OUTPUT}/result.txt"
+
+. ../../lib/sh-test-lib
+. ../../lib/android-test-lib
+
+usage() {
+ echo "Usage: $0 [-s <android_serial>] [-t <boot_timeout>] " 1>&2
+ exit 1
+}
+
+while getopts ":S:s:t:o:n:" o; do
+ case "$o" in
+ s) export ANDROID_SERIAL="${OPTARG}" ;;
+ t) BOOT_TIMEOUT="${OPTARG}" ;;
+ *) usage ;;
+ esac
+done
+
+
+safe_initialize_adb() {
+ # enable debug
+ set -x
+ adb_debug_info
+ adb start-server
+ timeout 300 adb wait-for-device || info_msg "Device NOT found!"
+ adb devices
+
+ if [ -z "${ANDROID_SERIAL}" ]; then
+ number="$(adb devices | grep -wc 'device')"
+ if [ "${number}" -gt 1 ]; then
+ info_msg "More than one device or emulator found! Please set ANDROID_SERIAL from test script."
+ elif [ "${number}" -eq 1 ]; then
+ ANDROID_SERIAL="$(adb get-serialno)"
+ else
+ info_msg "Device NOT found"
+ fi
+ fi
+ export ANDROID_SERIAL
+ info_msg "Default adb device: ${ANDROID_SERIAL}"
+
+ if adb shell echo "Testing adb connectivity"; then
+ info_msg "Connected to device ${ANDROID_SERIAL} successfully"
+ else
+ info_msg "Unable to connect to device ${ANDROID_SERIAL}"
+ fi
+ # disable debug
+ set +x
+}
+
+safe_wait_boot_completed() {
+ [ "$#" -ne 1 ] && info_msg "Usage: wait_for_boot_completed timeout_in_seconds"
+ timeout="$1"
+ end=$(( $(date +%s) + timeout ))
+
+ boot_completed=0
+ while [ "$(date +%s)" -lt "$end" ]; do
+ if adb shell getprop sys.boot_completed | grep "1"; then
+ boot_completed=1
+ break
+ else
+ sleep 3
+ fi
+ done
+
+ if "${boot_completed}"; then
+ info_msg "Target booted up completely."
+ else
+ info_msg "wait_boot_completed timed out after ${timeout} seconds"
+ fi
+ return boot_completed
+}
+
+safe_initialize_adb
+adb_root
+create_out_dir "${OUTPUT}"
+# wait till the launcher displayed
+if safe_wait_boot_completed "${BOOT_TIMEOUT}"; then
+ report_pass android-boot
+else
+ report_fail android-boot
+fi
diff --git a/automated/android/boottest/boottest.yaml b/automated/android/boottest/boottest.yaml
new file mode 100644
index 00000000..fd6c3e39
--- /dev/null
+++ b/automated/android/boottest/boottest.yaml
@@ -0,0 +1,28 @@
+metadata:
+ name: boottest
+ format: "Lava-Test-Shell Test Definition 1.0"
+ description: "Android boot test"
+ maintainer:
+ - yongqin.liu@linaro.org
+ - chase.qi@linaro.org
+ os:
+ - android
+ scope:
+ - performance
+ devices:
+ - juno
+ - hi6220-hikey
+
+params:
+ # specify true or false to skip or not the installation of lxc packages
+ SKIP_INSTALL: "false"
+ # Specify device serial no. when more than one device connected.
+ ANDROID_SERIAL: ""
+ # Specify timeout in seconds for wait_boot_completed.
+ BOOT_TIMEOUT: "300"
+
+run:
+ steps:
+ - cd ./automated/android/boottest
+ - ./boottest.sh -s "${ANDROID_SERIAL}" -t "${BOOT_TIMEOUT}"
+ - ../../utils/send-to-lava.sh ./output/result.txt