Commit deb2dfc8 authored by sullivan's avatar sullivan Committed by Commit bot

Fix adb usage in tools/telemetry/telemetry/core/platform/profiler after...

Fix adb usage in tools/telemetry/telemetry/core/platform/profiler after https://codereview.chromium.org/1213423003/

BUG=509039

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

Cr-Commit-Position: refs/heads/master@{#338387}
parent be672cde
......@@ -94,7 +94,7 @@ class TestAndroidProfilingHelperTabTestCase(tab_test_case.TabTestCase):
super(TestAndroidProfilingHelperTabTestCase, self).setUp()
# pylint: disable=W0212
browser_backend = self._browser._browser_backend
self._device = browser_backend._adb.device()
self._device = browser_backend.device()
@decorators.Enabled('android')
def testCreateSymFs(self):
......
......@@ -50,12 +50,12 @@ class JavaHeapProfiler(profiler.Profiler):
self._timer.cancel()
self._DumpJavaHeap(True)
try:
self._browser_backend.adb.device().PullFile(
self._browser_backend.device.PullFile(
self._DEFAULT_DEVICE_DIR, self._output_path)
except:
logging.exception('New exception caused by DeviceUtils conversion')
raise
self._browser_backend.adb.RunShellCommand(
self._browser_backend.device.RunShellCommand(
'rm ' + os.path.join(self._DEFAULT_DEVICE_DIR, '*'))
output_files = []
for f in os.listdir(self._output_path):
......@@ -72,25 +72,25 @@ class JavaHeapProfiler(profiler.Profiler):
self._DumpJavaHeap(False)
def _DumpJavaHeap(self, wait_for_completion):
if not self._browser_backend.adb.device().FileExists(
if not self._browser_backend.device.FileExists(
self._DEFAULT_DEVICE_DIR):
self._browser_backend.adb.RunShellCommand(
self._browser_backend.device.RunShellCommand(
'mkdir -p ' + self._DEFAULT_DEVICE_DIR)
self._browser_backend.adb.RunShellCommand(
self._browser_backend.device.RunShellCommand(
'chmod 777 ' + self._DEFAULT_DEVICE_DIR)
device_dump_file = None
for pid in self._GetProcessOutputFileMap().iterkeys():
device_dump_file = '%s/%s.%s.aprof' % (self._DEFAULT_DEVICE_DIR, pid,
self._run_count)
self._browser_backend.adb.RunShellCommand('am dumpheap %s %s' %
(pid, device_dump_file))
self._browser_backend.device.RunShellCommand('am dumpheap %s %s' %
(pid, device_dump_file))
if device_dump_file and wait_for_completion:
util.WaitFor(lambda: self._FileSize(device_dump_file) > 0, timeout=2)
self._run_count += 1
def _FileSize(self, file_name):
try:
return self._browser_backend.adb.device().Stat(file_name).st_size
return self._browser_backend.device.Stat(file_name).st_size
except device_errors.CommandFailedError:
return 0
......@@ -32,7 +32,7 @@ class OOMKillerProfiler(profiler.Profiler):
browser_backend, platform_backend, output_path, state)
if not 'mem_consumer_launched' in state:
state['mem_consumer_launched'] = True
arch_name = self._browser_backend.adb.device().GetABI()
arch_name = self._browser_backend.device.GetABI()
mem_consumer_path = support_binaries.FindPath(
os.path.join('apks', 'MemConsumer.apk'), arch_name, 'android')
assert mem_consumer_path, ('Could not find memconsumer app. Please build '
......@@ -40,12 +40,12 @@ class OOMKillerProfiler(profiler.Profiler):
if not self._platform_backend.CanLaunchApplication(
'org.chromium.memconsumerg'):
self._platform_backend.InstallApplication(mem_consumer_path)
self._browser_backend.adb.device().GoHome()
self._browser_backend.device.GoHome()
self._platform_backend.LaunchApplication(
'org.chromium.memconsumer/.MemConsumer',
'--ei memory 20')
# Bring the browser to the foreground after launching the mem consumer
self._browser_backend.adb.device().StartActivity(
self._browser_backend.device.StartActivity(
intent.Intent(package=browser_backend.package,
activity=browser_backend.activity),
blocking=True)
......@@ -62,7 +62,7 @@ class OOMKillerProfiler(profiler.Profiler):
@classmethod
def WillCloseBrowser(cls, browser_backend, platform_backend):
browser_backend.adb.device().ForceStop('org.chromium.memconsumer')
browser_backend.device.ForceStop('org.chromium.memconsumer')
def CollectProfile(self):
missing_applications = self._MissingApplications()
......
......@@ -80,15 +80,16 @@ class _SingleProcessPerfProfiler(object):
cmd_prefix = []
perf_args = ['record', '--pid', str(pid)]
if self._is_android:
cmd_prefix = ['adb', '-s', browser_backend.adb.device_serial(), 'shell',
perf_binary]
cmd_prefix = ['adb', '-s', browser_backend.device.adb.GetDeviceSerial(),
'shell', perf_binary]
perf_args += _PERF_OPTIONS_ANDROID
output_file = os.path.join('/sdcard', 'perf_profiles',
os.path.basename(output_file))
self._device_output_file = output_file
browser_backend.adb.RunShellCommand(
browser_backend.device.RunShellCommand(
'mkdir -p ' + os.path.dirname(self._device_output_file))
browser_backend.adb.RunShellCommand('rm -f ' + self._device_output_file)
browser_backend.device.RunShellCommand(
'rm -f ' + self._device_output_file)
else:
cmd_prefix = [perf_binary]
perf_args += ['--output', output_file] + _PERF_OPTIONS
......@@ -103,7 +104,7 @@ class _SingleProcessPerfProfiler(object):
'To collect a full profile rerun with '
'"--extra-browser-args=--single-process"')
if self._is_android:
device = self._browser_backend.adb.device()
device = self._browser_backend.device
try:
binary_name = os.path.basename(self._perf_binary)
device.KillAll(binary_name, signum=signal.SIGINT, blocking=True)
......@@ -127,7 +128,7 @@ Try rerunning this script under sudo or setting
cmd = '%s report -n -i %s' % (_NicePath(self._perfhost_binary),
self._output_file)
if self._is_android:
device = self._browser_backend.adb.device()
device = self._browser_backend.device
try:
device.PullFile(self._device_output_file, self._output_file)
except:
......@@ -177,7 +178,7 @@ class PerfProfiler(profiler.Profiler):
perf_binary = perfhost_binary = _InstallPerfHost()
try:
if platform_backend.GetOSName() == 'android':
device = browser_backend.adb.device()
device = browser_backend.device
perf_binary = android_profiling_helper.PrepareDeviceForPerf(device)
self._perf_control = perf_control.PerfControl(device)
self._perf_control.SetPerfProfilingMode()
......
......@@ -35,20 +35,20 @@ class _TCMallocHeapProfilerAndroid(object):
device_configured = False
# This profiler requires adb root to set properties.
try:
self._browser_backend.adb.device().EnableRoot()
self._browser_backend.device.EnableRoot()
except:
logging.exception('New exception caused by DeviceUtils conversion')
raise
for values in properties.itervalues():
device_property = self._browser_backend.adb.device().GetProp(values[0])
device_property = self._browser_backend.device.GetProp(values[0])
if not device_property or not device_property.strip():
self._browser_backend.adb.device().SetProp(values[0], values[1])
self._browser_backend.device.SetProp(values[0], values[1])
device_configured = True
if not self._browser_backend.adb.device().FileExists(
if not self._browser_backend.device.FileExists(
self._DEFAULT_DEVICE_DIR):
self._browser_backend.adb.RunShellCommand(
self._browser_backend.device.RunShellCommand(
'mkdir -p ' + self._DEFAULT_DEVICE_DIR)
self._browser_backend.adb.RunShellCommand(
self._browser_backend.device.RunShellCommand(
'chmod 777 ' + self._DEFAULT_DEVICE_DIR)
device_configured = True
if device_configured:
......@@ -56,12 +56,12 @@ class _TCMallocHeapProfilerAndroid(object):
def CollectProfile(self):
try:
self._browser_backend.adb.device().PullFile(
self._browser_backend.device.PullFile(
self._DEFAULT_DEVICE_DIR, self._output_path)
except:
logging.exception('New exception caused by DeviceUtils conversion')
raise
self._browser_backend.adb.RunShellCommand(
self._browser_backend.device.RunShellCommand(
'rm ' + os.path.join(self._DEFAULT_DEVICE_DIR, '*'))
if os.path.exists(self._output_path):
logging.info('TCMalloc dumps pulled to %s', self._output_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