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):
# 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
# have in the symfs.
if (md5sum.CalculateHostMd5Sums([output_lib])[0] !=
md5sum.CalculateDeviceMd5Sums([lib])[0]):
if not os.path.exists(output_lib):
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)
device.PullFile(lib, output_lib)
......@@ -260,10 +267,22 @@ def GetToolchainBinaryPath(library_file, binary_name):
return None
toolchain_version = toolchain_version.group(1)
path = os.path.join(util.GetChromiumSrcDir(), 'third_party', 'android_tools',
'ndk', 'toolchains',
'%s-%s' % (toolchain_config, toolchain_version),
'prebuilt', '%s-%s' % (host_os, host_machine), 'bin',
toolchain_path = os.path.abspath(os.path.join(
util.GetChromiumSrcDir(), 'third_party', 'android_tools', 'ndk',
'toolchains', '%s-%s' % (toolchain_config, toolchain_version)))
if not os.path.exists(toolchain_path):
logging.warning(
'Unable to find toolchain binary %s: toolchain not found at %s',
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))
path = os.path.abspath(path)
return path if os.path.exists(path) else None
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):
browser_backend = self._browser._browser_backend
self._device = browser_backend._adb.device()
# Test fails: crbug.com/437081
# @decorators.Enabled('android')
@decorators.Disabled
@decorators.Enabled('android')
def testCreateSymFs(self):
# pylint: disable=W0212
browser_pid = self._browser._browser_backend.pid
......@@ -115,7 +113,7 @@ class TestAndroidProfilingHelperTabTestCase(tab_test_case.TabTestCase):
# Check that we have kernel symbols.
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
# Check that all requested libraries are present.
......@@ -137,4 +135,4 @@ class TestAndroidProfilingHelperTabTestCase(tab_test_case.TabTestCase):
self._device.PullFile('/system/lib/libc.so', libc.name)
path = android_profiling_helper.GetToolchainBinaryPath(libc.name,
'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