| OLD | NEW |
| 1 #! /usr/bin/env python | 1 #! /usr/bin/env python |
| 2 # Copyright (c) 2015 The Chromium Authors. All rights reserved. | 2 # Copyright (c) 2015 The Chromium Authors. All rights reserved. |
| 3 # Use of this source code is governed by a BSD-style license that can be | 3 # Use of this source code is governed by a BSD-style license that can be |
| 4 # found in the LICENSE file. | 4 # found in the LICENSE file. |
| 5 | 5 |
| 6 """Utility library for running a startup profile on an Android device. | 6 """Utility library for running a startup profile on an Android device. |
| 7 | 7 |
| 8 Sets up a device for cygprofile, disables sandboxing permissions, and sets up | 8 Sets up a device for cygprofile, disables sandboxing permissions, and sets up |
| 9 support for web page replay, device forwarding, and fake certificate authority | 9 support for web page replay, device forwarding, and fake certificate authority |
| 10 to make runs repeatable. | 10 to make runs repeatable. |
| (...skipping 212 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 223 Args: | 223 Args: |
| 224 path_to_tests: The location on the host machine with the compiled | 224 path_to_tests: The location on the host machine with the compiled |
| 225 cygprofile test binary. | 225 cygprofile test binary. |
| 226 Returns: | 226 Returns: |
| 227 The exit code for the tests. | 227 The exit code for the tests. |
| 228 """ | 228 """ |
| 229 device_path = '/data/local/tmp/cygprofile_unittests' | 229 device_path = '/data/local/tmp/cygprofile_unittests' |
| 230 self._device.PushChangedFiles([(self._cygprofile_tests, device_path)]) | 230 self._device.PushChangedFiles([(self._cygprofile_tests, device_path)]) |
| 231 try: | 231 try: |
| 232 self._device.RunShellCommand(device_path, check_return=True) | 232 self._device.RunShellCommand(device_path, check_return=True) |
| 233 except device_errors.CommandFailedError: | 233 except (device_errors.CommandFailedError, |
| 234 device_errors.DeviceUnreachableError): |
| 234 # TODO(jbudorick): Let the exception propagate up once clients can | 235 # TODO(jbudorick): Let the exception propagate up once clients can |
| 235 # handle it. | 236 # handle it. |
| 236 logging.exception('Failure while running cygprofile_unittests:') | 237 logging.exception('Failure while running cygprofile_unittests:') |
| 237 return 1 | 238 return 1 |
| 238 return 0 | 239 return 0 |
| 239 | 240 |
| 240 def CollectProfile(self, apk, package_info): | 241 def CollectProfile(self, apk, package_info): |
| 241 """Run a profile and collect the log files. | 242 """Run a profile and collect the log files. |
| 242 | 243 |
| 243 Args: | 244 Args: |
| (...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 409 raise Exception('Unable to determine package info for %s' % args.apk_path) | 410 raise Exception('Unable to determine package info for %s' % args.apk_path) |
| 410 | 411 |
| 411 profiler = AndroidProfileTool( | 412 profiler = AndroidProfileTool( |
| 412 args.output_directory, host_cyglog_dir=args.trace_directory) | 413 args.output_directory, host_cyglog_dir=args.trace_directory) |
| 413 profiler.CollectProfile(args.apk_path, package_info) | 414 profiler.CollectProfile(args.apk_path, package_info) |
| 414 return 0 | 415 return 0 |
| 415 | 416 |
| 416 | 417 |
| 417 if __name__ == '__main__': | 418 if __name__ == '__main__': |
| 418 sys.exit(main()) | 419 sys.exit(main()) |
| OLD | NEW |