summaryrefslogtreecommitdiff
path: root/automated/lib
diff options
context:
space:
mode:
authorChase Qi <chase.qi@linaro.org>2017-03-27 11:34:38 +0800
committerMilosz Wasilewski <milosz.wasilewski@linaro.org>2017-03-27 13:42:25 +0000
commit398778587abb3419f561439e7d073cca50f3b1a1 (patch)
tree4e874b9910a6b87f858438790af4bd13feb510ff /automated/lib
parent0f6d45e70b627c233d780166baa2c3ef1793f879 (diff)
downloadtest-definitions-pipe-398778587abb3419f561439e7d073cca50f3b1a1.tar.gz
android-test-lib: add parse_common_args()
Moving the parsing for common args to android-test-lib can avoid code duplication. On the other hand, except the common args, if the test script support additional args, IMO, we should put them together and do the paring in the script. Actually, with the capability to handle illegal input, I don't see an easy way to split the args. And make the code easy to read also is a priority. Change-Id: I6ea7ac4a624f6accb509aaf4e735cd8e190fcc36 Signed-off-by: Chase Qi <chase.qi@linaro.org>
Diffstat (limited to 'automated/lib')
-rwxr-xr-xautomated/lib/android-test-lib20
1 files changed, 20 insertions, 0 deletions
diff --git a/automated/lib/android-test-lib b/automated/lib/android-test-lib
index 7330c8b..3bacee6 100755
--- a/automated/lib/android-test-lib
+++ b/automated/lib/android-test-lib
@@ -161,3 +161,23 @@ adb_shell_which() {
return 1
fi
}
+
+parse_common_args() {
+ while getopts ":s:t:" opt; do
+ case "${opt}" in
+ # Specify device serial number when more than one device connected.
+ s)
+ ANDROID_SERIAL="${OPTARG}"
+ ;;
+ # Specify timeout in seconds for wait_boot_completed.
+ t)
+ BOOT_TIMEOUT="${OPTARG}"
+ export BOOT_TIMEOUT
+ ;;
+ *)
+ echo "Usage: $0 [-s <android_serial>] [-t <boot_timeout>]" 1>&2
+ exit 1
+ ;;
+ esac
+ done
+}