Commit 5fd85a26 authored by jbudorick's avatar jbudorick Committed by Commit bot

[Android] Fix android_profiling_helper pulling lib from device.

Telemetry's android_profiling_helper currently fails when trying to pull
a library from the device if the library doesn't already exist on the host
(read: most if not all of the time). This patch fixes that.

BUG=489969

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

Cr-Commit-Position: refs/heads/master@{#330744}
parent 69bcb8eb
...@@ -204,8 +204,15 @@ def CreateSymFs(device, symfs_dir, libraries, use_symlinks=True): ...@@ -204,8 +204,15 @@ def CreateSymFs(device, symfs_dir, libraries, use_symlinks=True):
# the profiler can at least use the public symbols of that library. To # the profiler can at least use the public symbols of that library. To
# speed things up, only pull files that don't match copies we already # speed things up, only pull files that don't match copies we already
# have in the symfs. # have in the symfs.
if (md5sum.CalculateHostMd5Sums([output_lib])[0] != if not os.path.exists(output_lib):
md5sum.CalculateDeviceMd5Sums([lib])[0]): pull = True
else:
host_md5sums = md5sum.CalculateHostMd5Sums([output_lib])
device_md5sums = md5sum.CalculateDeviceMd5Sums([lib], device)
pull = (not host_md5sums or not device_md5sums
or host_md5sums[0] != device_md5sums[0])
if pull:
logging.info('Pulling %s to %s', lib, output_lib) logging.info('Pulling %s to %s', lib, output_lib)
device.PullFile(lib, output_lib) device.PullFile(lib, output_lib)
...@@ -260,10 +267,22 @@ def GetToolchainBinaryPath(library_file, binary_name): ...@@ -260,10 +267,22 @@ def GetToolchainBinaryPath(library_file, binary_name):
return None return None
toolchain_version = toolchain_version.group(1) toolchain_version = toolchain_version.group(1)
path = os.path.join(util.GetChromiumSrcDir(), 'third_party', 'android_tools', toolchain_path = os.path.abspath(os.path.join(
'ndk', 'toolchains', util.GetChromiumSrcDir(), 'third_party', 'android_tools', 'ndk',
'%s-%s' % (toolchain_config, toolchain_version), 'toolchains', '%s-%s' % (toolchain_config, toolchain_version)))
'prebuilt', '%s-%s' % (host_os, host_machine), 'bin', if not os.path.exists(toolchain_path):
'%s-%s' % (toolchain_config, binary_name)) logging.warning(
path = os.path.abspath(path) 'Unable to find toolchain binary %s: toolchain not found at %s',
return path if os.path.exists(path) else None binary_name, toolchain_path)
return None
path = os.path.join(
toolchain_path, 'prebuilt', '%s-%s' % (host_os, host_machine), 'bin',
'%s-%s' % (toolchain_config, binary_name))
if not os.path.exists(path):
logging.warning(
'Unable to find toolchain binary %s: binary not found at %s',
binary_name, path)
return None
return path
...@@ -96,9 +96,7 @@ class TestAndroidProfilingHelperTabTestCase(tab_test_case.TabTestCase): ...@@ -96,9 +96,7 @@ class TestAndroidProfilingHelperTabTestCase(tab_test_case.TabTestCase):
browser_backend = self._browser._browser_backend browser_backend = self._browser._browser_backend
self._device = browser_backend._adb.device() self._device = browser_backend._adb.device()
# Test fails: crbug.com/437081 @decorators.Enabled('android')
# @decorators.Enabled('android')
@decorators.Disabled
def testCreateSymFs(self): def testCreateSymFs(self):
# pylint: disable=W0212 # pylint: disable=W0212
browser_pid = self._browser._browser_backend.pid browser_pid = self._browser._browser_backend.pid
...@@ -115,7 +113,7 @@ class TestAndroidProfilingHelperTabTestCase(tab_test_case.TabTestCase): ...@@ -115,7 +113,7 @@ class TestAndroidProfilingHelperTabTestCase(tab_test_case.TabTestCase):
# Check that we have kernel symbols. # Check that we have kernel symbols.
assert os.path.exists(kallsyms) assert os.path.exists(kallsyms)
is_unstripped = re.compile(r'^/data/app/.*\.so$') is_unstripped = re.compile(r'^/data/app(-lib)?/.*\.so$')
has_unstripped = False has_unstripped = False
# Check that all requested libraries are present. # Check that all requested libraries are present.
...@@ -137,4 +135,4 @@ class TestAndroidProfilingHelperTabTestCase(tab_test_case.TabTestCase): ...@@ -137,4 +135,4 @@ class TestAndroidProfilingHelperTabTestCase(tab_test_case.TabTestCase):
self._device.PullFile('/system/lib/libc.so', libc.name) self._device.PullFile('/system/lib/libc.so', libc.name)
path = android_profiling_helper.GetToolchainBinaryPath(libc.name, path = android_profiling_helper.GetToolchainBinaryPath(libc.name,
'objdump') 'objdump')
assert os.path.exists(path) assert path and os.path.exists(path)
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment