From 7c42868d583d7b7464162a189c0cabc4051960cb Mon Sep 17 00:00:00 2001 From: Chase Qi Date: Wed, 22 Mar 2017 14:38:53 +0800 Subject: automated: android-test-lib: add adb_shell_which() Change-Id: Ieec3d241a33c5d9a645a2e5ca2c1aeab96cc955d Signed-off-by: Chase Qi --- automated/lib/android-test-lib | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'automated/lib') diff --git a/automated/lib/android-test-lib b/automated/lib/android-test-lib index 3fe6831..8a11279 100755 --- a/automated/lib/android-test-lib +++ b/automated/lib/android-test-lib @@ -141,3 +141,17 @@ adb_pull() { info_msg "Pulling ${remote} from devcie ${ANDROID_SERIAL}" adb pull "${remote}" "${local}" } + +adb_shell_which() { + [ "$#" -ne 1 ] && error_msg "Usage: adb_shell_which " + cmd="$1" + # Only latest version adb able to return exit code. + # Check if output of which is empty is a more reliable way. + which_output="$(adb shell "which ${cmd}")" + info_msg "Output of which: *${which_output}*" + if [ -n "${which_output}" ]; then + return 0 + else + return 1 + fi +} -- cgit v1.2.3