| OLD | NEW |
| 1 # Copyright 2014 The Chromium Authors. All rights reserved. | 1 # Copyright 2014 The Chromium Authors. All rights reserved. |
| 2 # Use of this source code is governed by a BSD-style license that can be | 2 # Use of this source code is governed by a BSD-style license that can be |
| 3 # found in the LICENSE file. | 3 # found in the LICENSE file. |
| 4 import glob | 4 import glob |
| 5 import os | 5 import os |
| 6 import pickle | 6 import pickle |
| 7 import re | 7 import re |
| 8 import shutil | 8 import shutil |
| 9 import tempfile | 9 import tempfile |
| 10 | 10 |
| 11 from telemetry import benchmark | 11 from telemetry import benchmark |
| 12 from telemetry.core import util | 12 from telemetry.core import util |
| 13 from telemetry.core.platform.profiler import android_profiling_helper | 13 from telemetry.core.platform.profiler import android_profiling_helper |
| 14 from telemetry.unittest import simple_mock | 14 from telemetry.unittest import simple_mock |
| 15 from telemetry.unittest import tab_test_case | 15 from telemetry.unittest import tab_test_case |
| 16 | 16 |
| 17 | 17 |
| 18 def _GetLibrariesMappedIntoProcesses(device, pids): | 18 def _GetLibrariesMappedIntoProcesses(device, pids): |
| 19 libs = set() | 19 libs = set() |
| 20 for pid in pids: | 20 for pid in pids: |
| 21 maps_file = '/proc/%d/maps' % pid | 21 maps_file = '/proc/%d/maps' % pid |
| 22 maps = device.old_interface.GetProtectedFileContents(maps_file) | 22 maps = device.ReadFile(maps_file, as_root=True) |
| 23 for map_line in maps: | 23 for map_line in maps: |
| 24 lib = re.match(r'.*\s(/.*[.]so)$', map_line) | 24 lib = re.match(r'.*\s(/.*[.]so)$', map_line) |
| 25 if lib: | 25 if lib: |
| 26 libs.add(lib.group(1)) | 26 libs.add(lib.group(1)) |
| 27 return libs | 27 return libs |
| 28 | 28 |
| 29 | 29 |
| 30 class TestAndroidProfilingHelper(tab_test_case.TabTestCase): | 30 class TestAndroidProfilingHelper(tab_test_case.TabTestCase): |
| 31 def setUp(self): | 31 def setUp(self): |
| 32 super(TestAndroidProfilingHelper, self).setUp() | 32 super(TestAndroidProfilingHelper, self).setUp() |
| (...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 119 # Check that all requested libraries are present. | 119 # Check that all requested libraries are present. |
| 120 for lib in libs: | 120 for lib in libs: |
| 121 assert os.path.exists(os.path.join(symfs_dir, lib[1:])), \ | 121 assert os.path.exists(os.path.join(symfs_dir, lib[1:])), \ |
| 122 '%s not found in symfs' % lib | 122 '%s not found in symfs' % lib |
| 123 finally: | 123 finally: |
| 124 shutil.rmtree(symfs_dir) | 124 shutil.rmtree(symfs_dir) |
| 125 | 125 |
| 126 @benchmark.Enabled('android') | 126 @benchmark.Enabled('android') |
| 127 def testGetToolchainBinaryPath(self): | 127 def testGetToolchainBinaryPath(self): |
| 128 with tempfile.NamedTemporaryFile() as libc: | 128 with tempfile.NamedTemporaryFile() as libc: |
| 129 self._device.old_interface.PullFileFromDevice('/system/lib/libc.so', | 129 self._device.PullFile('/system/lib/libc.so', libc.name) |
| 130 libc.name) | |
| 131 path = android_profiling_helper.GetToolchainBinaryPath(libc.name, | 130 path = android_profiling_helper.GetToolchainBinaryPath(libc.name, |
| 132 'objdump') | 131 'objdump') |
| 133 assert os.path.exists(path) | 132 assert os.path.exists(path) |
| OLD | NEW |