Skip to content

Commit

Permalink
[Android] Use more specific host platforms for devil.
Browse files Browse the repository at this point in the history
BUG=566160,566170

Review URL: https://codereview.chromium.org/1501843002

Cr-Commit-Position: refs/heads/master@{#363488}
  • Loading branch information
jbudorick authored and Commit bot committed Dec 7, 2015
1 parent 14957be commit e29693b
Show file tree
Hide file tree
Showing 8 changed files with 63 additions and 24 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ v8.log
/ash/ash_unittests_run.xml
/base/base_unittests_run.xml
/breakpad/src/
/build/android/bin
/build/Debug
/build/Debug_x64
/build/gomacc.lock
Expand Down
9 changes: 9 additions & 0 deletions build/android/devil/android/device_errors.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ def __init__(self, args, output, status=None, device_serial=None,
message = ''.join(message)
super(_BaseCommandFailedError, self).__init__(message, device_serial)


class AdbCommandFailedError(_BaseCommandFailedError):
"""Exception for adb command failures."""

Expand Down Expand Up @@ -106,3 +107,11 @@ class NoDevicesError(base_error.BaseError):
def __init__(self):
super(NoDevicesError, self).__init__(
'No devices attached.', is_infra_error=True)


class NoAdbError(base_error.BaseError):
"""Exception for being unable to find ADB."""

def __init__(self):
super(NoAdbError, self).__init__(
'Unable to find adb.', is_infra_error=True)
5 changes: 4 additions & 1 deletion build/android/devil/android/sdk/adb_wrapper.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,10 @@ def _FindAdb():
except dependency_manager.NoPathFoundError:
pass

return devil_env.config.FetchPath('adb')
try:
return devil_env.config.FetchPath('adb')
except dependency_manager.NoPathFoundError:
raise device_errors.NoAdbError()


DeviceStat = collections.namedtuple('DeviceStat',
Expand Down
26 changes: 18 additions & 8 deletions build/android/devil/devil_dependencies.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"cloud_storage_bucket": "chromium-telemetry",
"cloud_storage_base_folder": "binary_dependencies",
"file_info": {
"android_host": {
"android_linux2": {
"cloud_storage_hash": "7448de3cb5e834afdedeaad8b40ba63ac53f3dc4",
"download_path": "../bin/aapt"
}
Expand All @@ -15,7 +15,7 @@
"cloud_storage_bucket": "chromium-telemetry",
"cloud_storage_base_folder": "binary_dependencies",
"file_info": {
"android_host": {
"android_linux2": {
"cloud_storage_hash": "0c2043552619c8ec8bb5d986ba75703a598611fc",
"download_path": "../bin/adb"
}
Expand All @@ -25,7 +25,7 @@
"cloud_storage_bucket": "chromium-telemetry",
"cloud_storage_base_folder": "binary_dependencies",
"file_info": {
"android_host": {
"android_linux2": {
"cloud_storage_hash": "52d150a7ccde835f38b4337392152f3013d5f303",
"download_path": "../bin/lib/libc++.so"
}
Expand All @@ -35,7 +35,7 @@
"cloud_storage_bucket": "chromium-telemetry",
"cloud_storage_base_folder": "binary_dependencies",
"file_info": {
"android_host": {
"android_linux2": {
"cloud_storage_hash": "38765b5b358c29003e56b1d214606ea13467b6fe",
"download_path": "../bin/dexdump"
}
Expand All @@ -59,7 +59,7 @@
"cloud_storage_bucket": "chromium-telemetry",
"cloud_storage_base_folder": "binary_dependencies",
"file_info": {
"android_host": {
"android_linux2": {
"cloud_storage_hash": "b3dda9fbdd4a3fb933b64111c11070aa809c7ed4",
"download_path": "../bin/forwarder_host"
}
Expand Down Expand Up @@ -87,15 +87,25 @@
"cloud_storage_bucket": "chromium-telemetry",
"cloud_storage_base_folder": "binary_dependencies",
"file_info": {
"android_host": {
"android_linux2": {
"cloud_storage_hash": "49e36c9c4246cfebef26cbd07436c1a8343254aa",
"download_path": "../bin/md5sum_host"
}
}
},
"pymock": {
"file_info": {
"android_host": {
"android_darwin": {
"local_paths": [
"../../../tools/telemetry/third_party/mock"
]
},
"android_linux2": {
"local_paths": [
"../../../tools/telemetry/third_party/mock"
]
},
"android_win32": {
"local_paths": [
"../../../tools/telemetry/third_party/mock"
]
Expand All @@ -106,7 +116,7 @@
"cloud_storage_bucket": "chromium-telemetry",
"cloud_storage_base_folder": "binary_dependencies",
"file_info": {
"android_host": {
"android_linux2": {
"cloud_storage_hash": "3327881fa3951a503b9467425ea8e781cdffeb9f",
"download_path": "../bin/split-select"
}
Expand Down
12 changes: 6 additions & 6 deletions build/android/devil/devil_env.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,11 @@ def SysPath(path):
_LEGACY_ENVIRONMENT_VARIABLES = {
'ADB_PATH': {
'dependency_name': 'adb',
'platform': 'android_host',
'platform': 'android_linux2',
},
'ANDROID_SDK_ROOT': {
'dependency_name': 'android_sdk',
'platform': 'android_host',
'platform': 'android_linux2',
},
}

Expand Down Expand Up @@ -120,17 +120,17 @@ def FetchPath(self, dependency, arch=None, device=None):
self.Initialize()
if dependency in _ANDROID_BUILD_TOOLS:
self.FetchPath('android_build_tools_libc++', arch=arch, device=device)
return self._dm.FetchPath(dependency, _GetPlatform(arch, device))
return self._dm.FetchPath(dependency, GetPlatform(arch, device))

def LocalPath(self, dependency, arch=None, device=None):
if self._dm is None:
self.Initialize()
return self._dm.LocalPath(dependency, _GetPlatform(arch, device))
return self._dm.LocalPath(dependency, GetPlatform(arch, device))


def _GetPlatform(arch, device):
def GetPlatform(arch=None, device=None):
if not arch:
arch = device.product_cpu_abi if device else 'host'
arch = device.product_cpu_abi if device else sys.platform
return 'android_%s' % arch


Expand Down
22 changes: 16 additions & 6 deletions build/android/devil_chromium.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"dependencies": {
"aapt": {
"file_info": {
"android_host": {
"android_linux2": {
"local_paths": [
"../../third_party/android_tools/sdk/build-tools/23.0.0/aapt"
]
Expand All @@ -12,7 +12,7 @@
},
"adb": {
"file_info": {
"android_host": {
"android_linux2": {
"local_paths": [
"../../third_party/android_tools/sdk/platform-tools/adb"
]
Expand All @@ -21,7 +21,7 @@
},
"android_sdk": {
"file_info": {
"android_host": {
"android_linux2": {
"local_paths": [
"../../third_party/android_tools/sdk"
]
Expand All @@ -30,7 +30,7 @@
},
"dexdump": {
"file_info": {
"android_host": {
"android_linux2": {
"local_paths": [
"../../third_party/android_tools/sdk/build-tools/23.0.0/dexdump"
]
Expand All @@ -39,7 +39,7 @@
},
"split-select": {
"file_info": {
"android_host": {
"android_linux2": {
"local_paths": [
"../../third_party/android_tools/sdk/build-tools/23.0.0/split-select"
]
Expand All @@ -48,7 +48,17 @@
},
"pymock": {
"file_info": {
"android_host": {
"android_darwin": {
"local_paths": [
"../../third_party/pymock"
]
},
"android_linux2": {
"local_paths": [
"../../third_party/pymock"
]
},
"android_win32": {
"local_paths": [
"../../third_party/pymock"
]
Expand Down
3 changes: 2 additions & 1 deletion build/android/test_runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
import devil_chromium

from devil import base_error
from devil import devil_env
from devil.android import apk_helper
from devil.android import device_blacklist
from devil.android import device_errors
Expand Down Expand Up @@ -122,7 +123,7 @@ def ProcessCommonOptions(args):
if args.adb_path:
devil_custom_deps = {
'adb': {
'android_host': [args.adb_path]
devil_env.GetPlatform(): [args.adb_path]
}
}

Expand Down
9 changes: 7 additions & 2 deletions tools/telemetry/telemetry/internal/platform/android_device.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
from devil.android import device_blacklist
from devil.android import device_errors
from devil.android import device_utils
from pylib import constants
from devil.android.sdk import adb_wrapper


class AndroidDevice(device.Device):
Expand Down Expand Up @@ -132,9 +132,14 @@ def CanDiscoverDevices():
if os.name != 'posix':
return False

adb_path = constants.GetAdbPath()
try:
adb_path = adb_wrapper.AdbWrapper.GetAdbPath()
except device_errors.NoAdbError:
return False

if os.path.isabs(adb_path) and not os.path.exists(adb_path):
return False

try:
with open(os.devnull, 'w') as devnull:
adb_process = subprocess.Popen(
Expand Down

0 comments on commit e29693b

Please sign in to comment.