From 398778587abb3419f561439e7d073cca50f3b1a1 Mon Sep 17 00:00:00 2001 From: Chase Qi Date: Mon, 27 Mar 2017 11:34:38 +0800 Subject: 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 --- automated/lib/android-test-lib | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) (limited to 'automated') 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 ] [-t ]" 1>&2 + exit 1 + ;; + esac + done +} -- cgit v1.2.3