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 posixpath | |
6 import re | 7 import re |
7 import time | 8 import time |
8 | 9 |
9 from devil.android import device_errors | 10 from devil.android import device_errors |
10 from devil.android import flag_changer | 11 from devil.android import flag_changer |
11 from devil.utils import reraiser_thread | 12 from devil.utils import reraiser_thread |
12 from pylib import valgrind_tools | 13 from pylib import valgrind_tools |
13 from pylib.base import base_test_result | 14 from pylib.base import base_test_result |
14 from pylib.local.device import local_device_test_run | 15 from pylib.local.device import local_device_test_run |
15 | 16 |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
50 class LocalDeviceInstrumentationTestRun( | 51 class LocalDeviceInstrumentationTestRun( |
51 local_device_test_run.LocalDeviceTestRun): | 52 local_device_test_run.LocalDeviceTestRun): |
52 def __init__(self, env, test_instance): | 53 def __init__(self, env, test_instance): |
53 super(LocalDeviceInstrumentationTestRun, self).__init__(env, test_instance) | 54 super(LocalDeviceInstrumentationTestRun, self).__init__(env, test_instance) |
54 self._flag_changers = {} | 55 self._flag_changers = {} |
55 | 56 |
56 def TestPackage(self): | 57 def TestPackage(self): |
57 return self._test_instance.suite | 58 return self._test_instance.suite |
58 | 59 |
59 def SetUp(self): | 60 def SetUp(self): |
60 def substitute_external_storage(d, external_storage): | 61 def substitute_device_root(d, device_root): |
61 if not d: | 62 if not d: |
62 return external_storage | 63 return device_root |
63 elif isinstance(d, list): | 64 elif isinstance(d, list): |
64 return '/'.join(p if p else external_storage for p in d) | 65 return '/'.join(p if p else device_root for p in d) |
65 else: | 66 else: |
66 return d | 67 return d |
67 | 68 |
68 @local_device_test_run.handle_shard_failures_with( | 69 @local_device_test_run.handle_shard_failures_with( |
69 self._env.BlacklistDevice) | 70 self._env.BlacklistDevice) |
70 def individual_device_set_up(dev, host_device_tuples): | 71 def individual_device_set_up(dev, host_device_tuples): |
71 def install_apk(): | 72 def install_apk(): |
72 if self._test_instance.apk_under_test: | 73 if self._test_instance.apk_under_test: |
73 if self._test_instance.apk_under_test_incremental_install_script: | 74 if self._test_instance.apk_under_test_incremental_install_script: |
74 local_device_test_run.IncrementalInstall( | 75 local_device_test_run.IncrementalInstall( |
(...skipping 23 matching lines...) Expand all Loading... | |
98 if not self._test_instance.package_info: | 99 if not self._test_instance.package_info: |
99 logging.error("Couldn't set debug app: no package info") | 100 logging.error("Couldn't set debug app: no package info") |
100 elif not self._test_instance.package_info.package: | 101 elif not self._test_instance.package_info.package: |
101 logging.error("Couldn't set debug app: no package defined") | 102 logging.error("Couldn't set debug app: no package defined") |
102 else: | 103 else: |
103 dev.RunShellCommand(['am', 'set-debug-app', '--persistent', | 104 dev.RunShellCommand(['am', 'set-debug-app', '--persistent', |
104 self._test_instance.package_info.package], | 105 self._test_instance.package_info.package], |
105 check_return=True) | 106 check_return=True) |
106 | 107 |
107 def push_test_data(): | 108 def push_test_data(): |
108 external_storage = dev.GetExternalStoragePath() | 109 device_root = posixpath.join(dev.GetExternalStoragePath(), 'gtestdata') |
109 host_device_tuples_substituted = [ | 110 host_device_tuples_substituted = [ |
110 (h, substitute_external_storage(d, external_storage)) | 111 (h, substitute_device_root(d, device_root)) |
111 for h, d in host_device_tuples] | 112 for h, d in host_device_tuples] |
112 logging.info('instrumentation data deps:') | 113 logging.info('instrumentation data deps:') |
113 for h, d in host_device_tuples_substituted: | 114 for h, d in host_device_tuples_substituted: |
114 logging.info('%r -> %r', h, d) | 115 logging.info('%r -> %r', h, d) |
115 dev.PushChangedFiles(host_device_tuples_substituted) | 116 dev.PushChangedFiles(host_device_tuples_substituted, |
117 delete_device_stale=True) | |
118 if not host_device_tuples_substituted: | |
119 dev.RunShellCommand('r=%s;rm -rf $r;mkdir -p $r' % device_root) | |
jbudorick
2016/04/27 19:59:01
ditto
| |
116 | 120 |
117 def create_flag_changer(): | 121 def create_flag_changer(): |
118 if self._test_instance.flags: | 122 if self._test_instance.flags: |
119 if not self._test_instance.package_info: | 123 if not self._test_instance.package_info: |
120 logging.error("Couldn't set flags: no package info") | 124 logging.error("Couldn't set flags: no package info") |
121 elif not self._test_instance.package_info.cmdline_file: | 125 elif not self._test_instance.package_info.cmdline_file: |
122 logging.error("Couldn't set flags: no cmdline_file") | 126 logging.error("Couldn't set flags: no cmdline_file") |
123 else: | 127 else: |
124 self._CreateFlagChangerIfNeeded(dev) | 128 self._CreateFlagChangerIfNeeded(dev) |
125 logging.debug('Attempting to set flags: %r', | 129 logging.debug('Attempting to set flags: %r', |
(...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
295 timeout = v | 299 timeout = v |
296 break | 300 break |
297 else: | 301 else: |
298 logging.warning('Using default 1 minute timeout for %s', test_name) | 302 logging.warning('Using default 1 minute timeout for %s', test_name) |
299 timeout = 60 | 303 timeout = 60 |
300 | 304 |
301 timeout *= cls._GetTimeoutScaleFromAnnotations(annotations) | 305 timeout *= cls._GetTimeoutScaleFromAnnotations(annotations) |
302 | 306 |
303 return timeout | 307 return timeout |
304 | 308 |
OLD | NEW |