| OLD | NEW |
| 1 # Copyright (c) 2015 The Chromium Authors. All rights reserved. | 1 # Copyright (c) 2015 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 """Utility library for running a startup profile on an Android device. | 5 """Utility library for running a startup profile on an Android device. |
| 6 | 6 |
| 7 Sets up a device for cygprofile, disables sandboxing permissions, and sets up | 7 Sets up a device for cygprofile, disables sandboxing permissions, and sets up |
| 8 support for web page replay, device forwarding, and fake certificate authority | 8 support for web page replay, device forwarding, and fake certificate authority |
| 9 to make runs repeatable. | 9 to make runs repeatable. |
| 10 """ | 10 """ |
| 11 | 11 |
| 12 import logging | 12 import logging |
| 13 import os | 13 import os |
| 14 import shutil | 14 import shutil |
| 15 import subprocess | 15 import subprocess |
| 16 import sys | 16 import sys |
| 17 import tempfile | 17 import tempfile |
| 18 import time | 18 import time |
| 19 | 19 |
| 20 sys.path.append(os.path.join(sys.path[0], '..', '..', 'build', 'android')) | 20 sys.path.append(os.path.join(sys.path[0], '..', '..', 'build', 'android')) |
| 21 from pylib import android_commands | |
| 22 from pylib import constants | 21 from pylib import constants |
| 23 from pylib import flag_changer | 22 from pylib import flag_changer |
| 24 from pylib import forwarder | 23 from pylib import forwarder |
| 25 from pylib.device import device_errors | 24 from pylib.device import device_errors |
| 26 from pylib.device import device_utils | 25 from pylib.device import device_utils |
| 27 from pylib.device import intent | 26 from pylib.device import intent |
| 28 | 27 |
| 29 sys.path.append(os.path.join(sys.path[0], '..', '..', 'tools', 'telemetry')) | 28 sys.path.append(os.path.join(sys.path[0], '..', '..', 'tools', 'telemetry')) |
| 30 from telemetry.core import webpagereplay | 29 from telemetry.core import webpagereplay |
| 31 | 30 |
| (...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 194 _DEVICE_CYGLOG_DIR = '/data/local/tmp/chrome/cyglog' | 193 _DEVICE_CYGLOG_DIR = '/data/local/tmp/chrome/cyglog' |
| 195 | 194 |
| 196 # TEST_URL must be a url in the WPR_ARCHIVE. | 195 # TEST_URL must be a url in the WPR_ARCHIVE. |
| 197 _TEST_URL = 'https://www.google.com/#hl=en&q=science' | 196 _TEST_URL = 'https://www.google.com/#hl=en&q=science' |
| 198 _WPR_ARCHIVE = os.path.join( | 197 _WPR_ARCHIVE = os.path.join( |
| 199 constants.DIR_SOURCE_ROOT, 'tools', 'perf', 'page_sets', 'data', | 198 constants.DIR_SOURCE_ROOT, 'tools', 'perf', 'page_sets', 'data', |
| 200 'top_10_mobile_002.wpr') | 199 'top_10_mobile_002.wpr') |
| 201 | 200 |
| 202 | 201 |
| 203 def __init__(self, output_directory): | 202 def __init__(self, output_directory): |
| 204 devices = android_commands.GetAttachedDevices() | 203 devices = device_utils.DeviceUtils.HealthyDevices() |
| 205 self._device = device_utils.DeviceUtils(devices[0]) | 204 self._device = devices[0] |
| 206 self._cygprofile_tests = os.path.join( | 205 self._cygprofile_tests = os.path.join( |
| 207 output_directory, 'cygprofile_unittests') | 206 output_directory, 'cygprofile_unittests') |
| 208 self._host_cyglog_dir = os.path.join( | 207 self._host_cyglog_dir = os.path.join( |
| 209 output_directory, 'cyglog_data') | 208 output_directory, 'cyglog_data') |
| 210 self._SetUpDevice() | 209 self._SetUpDevice() |
| 211 | 210 |
| 212 def RunCygprofileTests(self): | 211 def RunCygprofileTests(self): |
| 213 """Run the cygprofile unit tests suite on the device. | 212 """Run the cygprofile unit tests suite on the device. |
| 214 | 213 |
| 215 Args: | 214 Args: |
| (...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 349 print 'Pulling cyglog data...' | 348 print 'Pulling cyglog data...' |
| 350 self._SetUpHostFolders() | 349 self._SetUpHostFolders() |
| 351 self._device.old_interface.Adb().Pull( | 350 self._device.old_interface.Adb().Pull( |
| 352 self._DEVICE_CYGLOG_DIR, self._host_cyglog_dir) | 351 self._DEVICE_CYGLOG_DIR, self._host_cyglog_dir) |
| 353 files = os.listdir(self._host_cyglog_dir) | 352 files = os.listdir(self._host_cyglog_dir) |
| 354 | 353 |
| 355 if len(files) == 0: | 354 if len(files) == 0: |
| 356 raise NoCyglogDataError('No cyglog data was collected') | 355 raise NoCyglogDataError('No cyglog data was collected') |
| 357 | 356 |
| 358 return [os.path.join(self._host_cyglog_dir, x) for x in files] | 357 return [os.path.join(self._host_cyglog_dir, x) for x in files] |
| OLD | NEW |