From e2c463022339b75844ac63f577593ea847090eba Mon Sep 17 00:00:00 2001 From: Chase Qi Date: Tue, 21 Feb 2017 17:47:55 +0800 Subject: automated: improve android-test-lib Change-Id: I6b7eafea28b6bea74a75c31cbb60f6dba2012795 Signed-off-by: Chase Qi --- automated/lib/android-test-lib | 34 +++++++++++++++++++++++++++------- 1 file changed, 27 insertions(+), 7 deletions(-) (limited to 'automated') diff --git a/automated/lib/android-test-lib b/automated/lib/android-test-lib index b66d0da..c179a27 100755 --- a/automated/lib/android-test-lib +++ b/automated/lib/android-test-lib @@ -23,8 +23,8 @@ initialize_adb() { } wait_boot_completed() { - timeout="$1" [ "$#" -ne 1 ] && error_msg "Usage: wait_for_boot_completed timeout_in_seconds" + timeout="$1" end=$(( $(date +%s) + timeout )) boot_completed=false @@ -45,8 +45,8 @@ wait_boot_completed() { } wait_homescreen() { - timeout="$1" [ "$#" -ne 1 ] && error_msg "Usage: wait_homescreen timeout_in_seconds" + timeout="$1" end=$(( $(date +%s) + timeout )) homescreen_displayed=false @@ -78,13 +78,21 @@ detect_abi() { info_msg "ABI: ${abi}" } +# install() push binary or script file to '/system/bin' so that you can run it +# without absolute/relative path. If '/system' is always read-only(like LCR), +# please use adb_push() instead to push binary or file to somewhere that 'rw' +# permission granted, like '/data/local/tmp', and run it from there. install() { + [ "$#" -ne 1 ] && error_msg "Usage: install " 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 info_msg "/system partition is read-only, remounting it read-write..." + # Because of https://bugs.linaro.org/show_bug.cgi?id=2888, this + # function wouldn't work in LAVA v2 LXC until the bug get addressed. + adb root adb -s "${SN}" remount fi @@ -93,10 +101,22 @@ install() { adb -s "${SN}" shell chmod 755 "/system/bin/${file_name}" } -pull_output() { - device_output="$1" - host_output="$2" +adb_push() { + [ "$#" -ne 2 ] && error_msg "Usage: adb_push " + local="$1" + remote="$2" + + adb -s "${SN}" shell mkdir -p "${remote}" + info_msg "Pushing ${local} to devcie ${SN}" + adb -s "${SN}" push "${local}" "${remote}" + adb -s "${SN}" shell chmod -R 755 "${remote}" +} + +adb_pull() { + [ "$#" -ne 2 ] && error_msg "Usage: adb_pull " + remote="$1" + local="$2" - info_msg "Pulling output from devcie ${SN}" - adb -s "${SN}" pull "${device_output}" "${host_output}" + info_msg "Pulling ${remote} from devcie ${SN}" + adb -s "${SN}" pull "${remote}" "${local}" } -- cgit v1.2.3