| OLD | NEW |
| 1 # Copyright 2015 The Chromium Authors. All rights reserved. | 1 # Copyright 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 import logging | 5 import logging |
| 6 import os | 6 import os |
| 7 import posixpath | |
| 8 import re | 7 import re |
| 9 import time | 8 import time |
| 10 | 9 |
| 11 from devil.android import device_errors | 10 from devil.android import device_errors |
| 12 from devil.android import flag_changer | 11 from devil.android import flag_changer |
| 13 from devil.utils import reraiser_thread | 12 from devil.utils import reraiser_thread |
| 14 from pylib import valgrind_tools | 13 from pylib import valgrind_tools |
| 15 from pylib.base import base_test_result | 14 from pylib.base import base_test_result |
| 16 from pylib.local.device import local_device_test_run | 15 from pylib.local.device import local_device_test_run |
| 17 | 16 |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 52 class LocalDeviceInstrumentationTestRun( | 51 class LocalDeviceInstrumentationTestRun( |
| 53 local_device_test_run.LocalDeviceTestRun): | 52 local_device_test_run.LocalDeviceTestRun): |
| 54 def __init__(self, env, test_instance): | 53 def __init__(self, env, test_instance): |
| 55 super(LocalDeviceInstrumentationTestRun, self).__init__(env, test_instance) | 54 super(LocalDeviceInstrumentationTestRun, self).__init__(env, test_instance) |
| 56 self._flag_changers = {} | 55 self._flag_changers = {} |
| 57 | 56 |
| 58 def TestPackage(self): | 57 def TestPackage(self): |
| 59 return self._test_instance.suite | 58 return self._test_instance.suite |
| 60 | 59 |
| 61 def SetUp(self): | 60 def SetUp(self): |
| 62 def substitute_device_root(d, device_root): | 61 def substitute_external_storage(d, external_storage): |
| 63 if not d: | 62 if not d: |
| 64 return device_root | 63 return external_storage |
| 65 elif isinstance(d, list): | 64 elif isinstance(d, list): |
| 66 return posixpath.join(p if p else device_root for p in d) | 65 return '/'.join(p if p else external_storage for p in d) |
| 67 else: | 66 else: |
| 68 return d | 67 return d |
| 69 | 68 |
| 70 @local_device_test_run.handle_shard_failures_with( | 69 @local_device_test_run.handle_shard_failures_with( |
| 71 self._env.BlacklistDevice) | 70 self._env.BlacklistDevice) |
| 72 def individual_device_set_up(dev, host_device_tuples): | 71 def individual_device_set_up(dev, host_device_tuples): |
| 73 def install_apk(): | 72 def install_apk(): |
| 74 if self._test_instance.apk_under_test: | 73 if self._test_instance.apk_under_test: |
| 75 if self._test_instance.apk_under_test_incremental_install_script: | 74 if self._test_instance.apk_under_test_incremental_install_script: |
| 76 local_device_test_run.IncrementalInstall( | 75 local_device_test_run.IncrementalInstall( |
| (...skipping 23 matching lines...) Expand all Loading... |
| 100 if not self._test_instance.package_info: | 99 if not self._test_instance.package_info: |
| 101 logging.error("Couldn't set debug app: no package info") | 100 logging.error("Couldn't set debug app: no package info") |
| 102 elif not self._test_instance.package_info.package: | 101 elif not self._test_instance.package_info.package: |
| 103 logging.error("Couldn't set debug app: no package defined") | 102 logging.error("Couldn't set debug app: no package defined") |
| 104 else: | 103 else: |
| 105 dev.RunShellCommand(['am', 'set-debug-app', '--persistent', | 104 dev.RunShellCommand(['am', 'set-debug-app', '--persistent', |
| 106 self._test_instance.package_info.package], | 105 self._test_instance.package_info.package], |
| 107 check_return=True) | 106 check_return=True) |
| 108 | 107 |
| 109 def push_test_data(): | 108 def push_test_data(): |
| 110 device_root = posixpath.join(dev.GetExternalStoragePath(), | 109 external_storage = dev.GetExternalStoragePath() |
| 111 'chromium_tests_root') | |
| 112 host_device_tuples_substituted = [ | 110 host_device_tuples_substituted = [ |
| 113 (h, substitute_device_root(d, device_root)) | 111 (h, substitute_external_storage(d, external_storage)) |
| 114 for h, d in host_device_tuples] | 112 for h, d in host_device_tuples] |
| 115 logging.info('instrumentation data deps:') | 113 logging.info('instrumentation data deps:') |
| 116 for h, d in host_device_tuples_substituted: | 114 for h, d in host_device_tuples_substituted: |
| 117 logging.info('%r -> %r', h, d) | 115 logging.info('%r -> %r', h, d) |
| 118 dev.PushChangedFiles(host_device_tuples_substituted, | 116 dev.PushChangedFiles(host_device_tuples_substituted) |
| 119 delete_device_stale=True) | |
| 120 if not host_device_tuples_substituted: | |
| 121 dev.RunShellCommand(['rm', '-rf', device_root], check_return=True) | |
| 122 dev.RunShellCommand(['mkdir', '-p', device_root], check_return=True) | |
| 123 | 117 |
| 124 def create_flag_changer(): | 118 def create_flag_changer(): |
| 125 if self._test_instance.flags: | 119 if self._test_instance.flags: |
| 126 if not self._test_instance.package_info: | 120 if not self._test_instance.package_info: |
| 127 logging.error("Couldn't set flags: no package info") | 121 logging.error("Couldn't set flags: no package info") |
| 128 elif not self._test_instance.package_info.cmdline_file: | 122 elif not self._test_instance.package_info.cmdline_file: |
| 129 logging.error("Couldn't set flags: no cmdline_file") | 123 logging.error("Couldn't set flags: no cmdline_file") |
| 130 else: | 124 else: |
| 131 self._CreateFlagChangerIfNeeded(dev) | 125 self._CreateFlagChangerIfNeeded(dev) |
| 132 logging.debug('Attempting to set flags: %r', | 126 logging.debug('Attempting to set flags: %r', |
| (...skipping 198 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 331 timeout = v | 325 timeout = v |
| 332 break | 326 break |
| 333 else: | 327 else: |
| 334 logging.warning('Using default 1 minute timeout for %s', test_name) | 328 logging.warning('Using default 1 minute timeout for %s', test_name) |
| 335 timeout = 60 | 329 timeout = 60 |
| 336 | 330 |
| 337 timeout *= cls._GetTimeoutScaleFromAnnotations(annotations) | 331 timeout *= cls._GetTimeoutScaleFromAnnotations(annotations) |
| 338 | 332 |
| 339 return timeout | 333 return timeout |
| 340 | 334 |
| OLD | NEW |