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 time | 6 import time |
7 | 7 |
8 from pylib import flag_changer | 8 from pylib import flag_changer |
9 from pylib.base import base_test_result | 9 from pylib.base import base_test_result |
10 from pylib.base import test_run | 10 from pylib.base import test_run |
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
97 #override | 97 #override |
98 def _GetTests(self): | 98 def _GetTests(self): |
99 return self._test_instance.GetTests() | 99 return self._test_instance.GetTests() |
100 | 100 |
101 #override | 101 #override |
102 def _GetTestName(self, test): | 102 def _GetTestName(self, test): |
103 return '%s#%s' % (test['class'], test['method']) | 103 return '%s#%s' % (test['class'], test['method']) |
104 | 104 |
105 #override | 105 #override |
106 def _RunTest(self, device, test): | 106 def _RunTest(self, device, test): |
107 test_name = self._GetTestName(test) | 107 if isinstance(test, list): |
| 108 def name_and_timeout(t): |
| 109 n = self._GetTestName(t) |
| 110 i = self._GetTimeoutFromAnnotations(t['annotations'], n) |
| 111 return (n, i) |
| 112 |
| 113 test_names, timeouts = zip(*(name_and_timeout(t) for t in test)) |
| 114 test_name = ','.join(test_names) |
| 115 timeout = sum(timeouts) |
| 116 else: |
| 117 test_name = self._GetTestName(test) |
| 118 timeout = self._GetTimeoutFromAnnotations(test['annotatoins'], test_name) |
| 119 |
108 logging.info('preparing to run %s: %s' % (test_name, test)) | 120 logging.info('preparing to run %s: %s' % (test_name, test)) |
109 | 121 |
110 extras = { | 122 extras = { |
111 'class': test_name, | 123 'class': test_name |
112 'org.chromium.chrome.test.ChromeInstrumentationTestRunner' | |
113 '.EnableTestHttpServer': '', | |
114 } | 124 } |
115 timeout = self._GetTimeoutFromAnnotations(test['annotations'], test_name) | 125 extras.update(self._test_instance.GetHttpServerEnvironmentVars()) |
116 | 126 |
117 time_ms = lambda: int(time.time() * 1e3) | 127 time_ms = lambda: int(time.time() * 1e3) |
118 start_ms = time_ms() | 128 start_ms = time_ms() |
119 output = device.StartInstrumentation( | 129 output = device.StartInstrumentation( |
120 '%s/%s' % (self._test_instance.test_package, | 130 '%s/%s' % (self._test_instance.test_package, |
121 self._test_instance.test_runner), | 131 self._test_instance.test_runner), |
122 raw=True, extras=extras, timeout=timeout, retries=0) | 132 raw=True, extras=extras, timeout=timeout, retries=0) |
123 duration_ms = time_ms() - start_ms | 133 duration_ms = time_ms() - start_ms |
124 | 134 |
125 # TODO(jbudorick): Make instrumentation tests output a JSON so this | 135 # TODO(jbudorick): Make instrumentation tests output a JSON so this |
(...skipping 27 matching lines...) Expand all Loading... |
153 | 163 |
154 try: | 164 try: |
155 scale = int(annotations.get('TimeoutScale', 1)) | 165 scale = int(annotations.get('TimeoutScale', 1)) |
156 except ValueError as e: | 166 except ValueError as e: |
157 logging.warning("Non-integer value of TimeoutScale ignored. (%s)", str(e)) | 167 logging.warning("Non-integer value of TimeoutScale ignored. (%s)", str(e)) |
158 scale = 1 | 168 scale = 1 |
159 timeout *= scale | 169 timeout *= scale |
160 | 170 |
161 return timeout | 171 return timeout |
162 | 172 |
OLD | NEW |