diff options
author | Cassidy Burden <cburden@google.com> | 2016-07-28 13:13:29 -0700 |
---|---|---|
committer | chrome-bot <chrome-bot@chromium.org> | 2016-07-28 19:27:31 -0700 |
commit | f67b68da6d8ed5e8e84409a1c78be4d457e792b4 (patch) | |
tree | a2b901d72ee40421b23c865241216034ff3700fa /binary_search_tool | |
parent | c583dac5abda3ecb5f05e35f77251fa3cef0c13c (diff) | |
download | toolchain-utils-f67b68da6d8ed5e8e84409a1c78be4d457e792b4.tar.gz |
binary search tool: Add android test scripts
Add android test scripts: boot test and interactive test. Boot test
waits for device to boot up and reach homescreen. Interactive test waits
for device to boot and asks user if the image is good or bad.
TEST=Run full bisection with boot test, test code paths with interactive
test
Change-Id: I04490da381964ca157f72f70cca49213e0e827c0
Reviewed-on: https://chrome-internal-review.googlesource.com/271975
Commit-Ready: Cassidy Burden <cburden@google.com>
Tested-by: Cassidy Burden <cburden@google.com>
Reviewed-by: Caroline Tice <cmtice@google.com>
Reviewed-by: Han Shen <shenhan@google.com>
Diffstat (limited to 'binary_search_tool')
-rwxr-xr-x | binary_search_tool/android/boot_test.sh | 61 | ||||
-rwxr-xr-x | binary_search_tool/android/interactive_test.sh | 39 |
2 files changed, 100 insertions, 0 deletions
diff --git a/binary_search_tool/android/boot_test.sh b/binary_search_tool/android/boot_test.sh new file mode 100755 index 00000000..8fec34f2 --- /dev/null +++ b/binary_search_tool/android/boot_test.sh @@ -0,0 +1,61 @@ +#!/bin/bash -u +# +# Copyright 2016 Google Inc. All Rights Reserved. +# +# This script pings the android device to determine if it successfully booted. +# +# This script is intended to be used by binary_search_state.py, as +# part of the binary search triage on the Android source tree. It +# waits for the install script to build and install the image, then checks if +# image boots or not. It should return '0' if the test succeeds +# (the image is 'good'); '1' if the test fails (the image is 'bad'); and '2' if +# it could not determine (does not apply in this case). +# + +source android/common.sh + +# Check if boot animation has stopped and trim whitespace +is_booted() +{ + # Wait for boot animation to stop and trim whitespace + status=`adb shell getprop init.svc.bootanim | tr -d '[:space:]'` + [[ "$status" == "stopped" ]] + return $? +} + +# Wait for device to boot, retry every 1s +# WARNING: Do not run without timeout command, could run forever +wait_for_boot() +{ + while ! is_booted + do + sleep 1 + done +} + +echo "Waiting 60 seconds for device to come online..." +timeout 60 adb wait-for-device +retval=$? + +if [[ ${retval} -eq 0 ]]; then + echo "Android image has been built and installed." +else + echo "Device failed to reboot within 60 seconds." + exit 1 +fi + +echo "Waiting 60 seconds for device to finish boot..." +# Spawn subshell that will timeout in 60 seconds +# Feed to cat so that timeout will recognize it as a command +# (timeout only works for commands/programs, not functions) +timeout 60 cat <(wait_for_boot) +retval=$? + +if [[ ${retval} -eq 0 ]]; then + echo "Android device fully booted!" +else + echo "Device failed to fully boot within 60 seconds." + exit 1 +fi + +exit ${retval} diff --git a/binary_search_tool/android/interactive_test.sh b/binary_search_tool/android/interactive_test.sh new file mode 100755 index 00000000..99dfd050 --- /dev/null +++ b/binary_search_tool/android/interactive_test.sh @@ -0,0 +1,39 @@ +#!/bin/bash -u +# +# Copyright 2016 Google Inc. All Rights Reserved. +# +# This script pings the android device to determine if it successfully booted. +# It then asks the user if the image is good or not, allowing the user to +# conduct whatever tests the user wishes, and waiting for a response. +# +# This script is intended to be used by binary_search_state.py, as +# part of the binary search triage on the Android source tree. It +# waits for the install script to build and install the image, then asks the +# user if the image is good or not. It should return '0' if the test succeeds +# (the image is 'good'); '1' if the test fails (the image is 'bad'); and '2' if +# it could not determine (does not apply in this case). +# + +source android/common.sh + +echo "Waiting 60 seconds for device to boot..." +timeout 60 adb wait-for-device +retval=$? + +if [[ ${retval} -eq 0 ]]; then + echo "Android image has been built and installed." +else + echo "Device failed to reboot within 60 seconds." + exit 1 +fi + +while true; do + read -p "Is this a good Android image?" yn + case $yn in + [Yy]* ) exit 0;; + [Nn]* ) exit 1;; + * ) echo "Please answer yes or no.";; + esac +done + +exit 2 |