| 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 | 4 |
| 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 import time | 10 import time |
| 11 import unittest | 11 import unittest |
| 12 | 12 |
| 13 from telemetry.core import util | 13 from telemetry.core import util |
| 14 from telemetry import decorators | 14 from telemetry import decorators |
| 15 from telemetry.internal.platform.profiler import android_profiling_helper | 15 from telemetry.internal.platform.profiler import android_profiling_helper |
| 16 from telemetry.internal.util import binary_manager |
| 16 from telemetry.testing import simple_mock | 17 from telemetry.testing import simple_mock |
| 17 from telemetry.testing import tab_test_case | 18 from telemetry.testing import tab_test_case |
| 18 | 19 |
| 19 | 20 |
| 20 def _GetLibrariesMappedIntoProcesses(device, pids): | 21 def _GetLibrariesMappedIntoProcesses(device, pids): |
| 21 libs = set() | 22 libs = set() |
| 22 for pid in pids: | 23 for pid in pids: |
| 23 maps_file = '/proc/%d/maps' % pid | 24 maps_file = '/proc/%d/maps' % pid |
| 24 maps = device.ReadFile(maps_file, as_root=True).splitlines() | 25 maps = device.ReadFile(maps_file, as_root=True).splitlines() |
| 25 for map_line in maps: | 26 for map_line in maps: |
| (...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 111 mock_popen = simple_mock.MockObject() | 112 mock_popen = simple_mock.MockObject() |
| 112 mock_popen.ExpectCall('communicate').WillReturn([None, perf_output]) | 113 mock_popen.ExpectCall('communicate').WillReturn([None, perf_output]) |
| 113 | 114 |
| 114 mock_subprocess = simple_mock.MockObject() | 115 mock_subprocess = simple_mock.MockObject() |
| 115 mock_subprocess.ExpectCall( | 116 mock_subprocess.ExpectCall( |
| 116 'Popen').WithArgs(simple_mock.DONT_CARE).WillReturn(mock_popen) | 117 'Popen').WithArgs(simple_mock.DONT_CARE).WillReturn(mock_popen) |
| 117 mock_subprocess.SetAttribute('PIPE', simple_mock.MockObject()) | 118 mock_subprocess.SetAttribute('PIPE', simple_mock.MockObject()) |
| 118 | 119 |
| 119 real_subprocess = android_profiling_helper.subprocess | 120 real_subprocess = android_profiling_helper.subprocess |
| 120 android_profiling_helper.subprocess = mock_subprocess | 121 android_profiling_helper.subprocess = mock_subprocess |
| 122 |
| 123 binary_manager.InitDependencyManagerForUnittests() |
| 121 try: | 124 try: |
| 122 libs = android_profiling_helper.GetRequiredLibrariesForPerfProfile('foo') | 125 libs = android_profiling_helper.GetRequiredLibrariesForPerfProfile('foo') |
| 123 self.assertEqual(libs, set([ | 126 self.assertEqual(libs, set([ |
| 124 '/data/app-lib/com.google.android.apps.chrome-2/libchrome.2016.0.so', | 127 '/data/app-lib/com.google.android.apps.chrome-2/libchrome.2016.0.so', |
| 125 '/system/lib/libart.so', | 128 '/system/lib/libart.so', |
| 126 '/system/lib/libc.so', | 129 '/system/lib/libc.so', |
| 127 '/system/lib/libm.so'])) | 130 '/system/lib/libm.so'])) |
| 128 finally: | 131 finally: |
| 129 android_profiling_helper.subprocess = real_subprocess | 132 android_profiling_helper.subprocess = real_subprocess |
| 130 | 133 |
| (...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 201 | 204 |
| 202 # Test fails: crbug.com/437081 | 205 # Test fails: crbug.com/437081 |
| 203 # @decorators.Enabled('android') | 206 # @decorators.Enabled('android') |
| 204 @decorators.Disabled | 207 @decorators.Disabled |
| 205 def testGetToolchainBinaryPath(self): | 208 def testGetToolchainBinaryPath(self): |
| 206 with tempfile.NamedTemporaryFile() as libc: | 209 with tempfile.NamedTemporaryFile() as libc: |
| 207 self._device.PullFile('/system/lib/libc.so', libc.name) | 210 self._device.PullFile('/system/lib/libc.so', libc.name) |
| 208 path = android_profiling_helper.GetToolchainBinaryPath(libc.name, | 211 path = android_profiling_helper.GetToolchainBinaryPath(libc.name, |
| 209 'objdump') | 212 'objdump') |
| 210 assert path and os.path.exists(path) | 213 assert path and os.path.exists(path) |
| OLD | NEW |