OLD | NEW |
1 # Copyright 2014 The Chromium Authors. All rights reserved. | 1 # Copyright 2014 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 re | 7 import re |
8 import tempfile | 8 import tempfile |
9 | 9 |
10 from devil.android import apk_helper | 10 from devil.android import apk_helper |
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
137 | 137 |
138 def __init__(self, args, isolate_delegate, error_func): | 138 def __init__(self, args, isolate_delegate, error_func): |
139 super(GtestTestInstance, self).__init__() | 139 super(GtestTestInstance, self).__init__() |
140 # TODO(jbudorick): Support multiple test suites. | 140 # TODO(jbudorick): Support multiple test suites. |
141 if len(args.suite_name) > 1: | 141 if len(args.suite_name) > 1: |
142 raise ValueError('Platform mode currently supports only 1 gtest suite') | 142 raise ValueError('Platform mode currently supports only 1 gtest suite') |
143 self._extract_test_list_from_filter = args.extract_test_list_from_filter | 143 self._extract_test_list_from_filter = args.extract_test_list_from_filter |
144 self._shard_timeout = args.shard_timeout | 144 self._shard_timeout = args.shard_timeout |
145 self._skip_clear_data = args.skip_clear_data | 145 self._skip_clear_data = args.skip_clear_data |
146 self._suite = args.suite_name[0] | 146 self._suite = args.suite_name[0] |
| 147 self._exe_dist_dir = None |
147 | 148 |
148 self._exe_path = os.path.join(constants.GetOutDirectory(), | 149 # GYP: |
149 self._suite) | 150 if args.executable_dist_dir: |
| 151 self._exe_dist_dir = os.path.abspath(args.executable_dist_dir) |
| 152 else: |
| 153 # TODO(agrieve): Remove auto-detection once recipes pass flag explicitly. |
| 154 exe_dist_dir = os.path.join(constants.GetOutDirectory(), |
| 155 '%s__dist' % self._suite) |
| 156 |
| 157 if os.path.exists(exe_dist_dir): |
| 158 self._exe_dist_dir = exe_dist_dir |
150 | 159 |
151 incremental_part = '' | 160 incremental_part = '' |
152 if args.test_apk_incremental_install_script: | 161 if args.test_apk_incremental_install_script: |
153 incremental_part = '_incremental' | 162 incremental_part = '_incremental' |
154 | 163 |
155 apk_path = os.path.join( | 164 apk_path = os.path.join( |
156 constants.GetOutDirectory(), '%s_apk' % self._suite, | 165 constants.GetOutDirectory(), '%s_apk' % self._suite, |
157 '%s-debug%s.apk' % (self._suite, incremental_part)) | 166 '%s-debug%s.apk' % (self._suite, incremental_part)) |
158 self._test_apk_incremental_install_script = ( | 167 self._test_apk_incremental_install_script = ( |
159 args.test_apk_incremental_install_script) | 168 args.test_apk_incremental_install_script) |
160 if not os.path.exists(apk_path): | 169 if not os.path.exists(apk_path): |
161 self._apk_helper = None | 170 self._apk_helper = None |
162 else: | 171 else: |
163 self._apk_helper = apk_helper.ApkHelper(apk_path) | 172 self._apk_helper = apk_helper.ApkHelper(apk_path) |
164 self._extras = { | 173 self._extras = { |
165 _EXTRA_NATIVE_TEST_ACTIVITY: self._apk_helper.GetActivityName(), | 174 _EXTRA_NATIVE_TEST_ACTIVITY: self._apk_helper.GetActivityName(), |
166 } | 175 } |
167 if self._suite in RUN_IN_SUB_THREAD_TEST_SUITES: | 176 if self._suite in RUN_IN_SUB_THREAD_TEST_SUITES: |
168 self._extras[_EXTRA_RUN_IN_SUB_THREAD] = 1 | 177 self._extras[_EXTRA_RUN_IN_SUB_THREAD] = 1 |
169 if self._suite in BROWSER_TEST_SUITES: | 178 if self._suite in BROWSER_TEST_SUITES: |
170 self._extras[_EXTRA_SHARD_SIZE_LIMIT] = 1 | 179 self._extras[_EXTRA_SHARD_SIZE_LIMIT] = 1 |
171 self._extras[EXTRA_SHARD_NANO_TIMEOUT] = int(1e9 * self._shard_timeout) | 180 self._extras[EXTRA_SHARD_NANO_TIMEOUT] = int(1e9 * self._shard_timeout) |
172 self._shard_timeout = 900 | 181 self._shard_timeout = 900 |
173 | 182 |
174 if not os.path.exists(self._exe_path): | 183 if not self._apk_helper and not self._exe_dist_dir: |
175 self._exe_path = None | |
176 if not self._apk_helper and not self._exe_path: | |
177 error_func('Could not find apk or executable for %s' % self._suite) | 184 error_func('Could not find apk or executable for %s' % self._suite) |
178 | 185 |
179 self._data_deps = [] | 186 self._data_deps = [] |
180 if args.test_filter: | 187 if args.test_filter: |
181 self._gtest_filter = args.test_filter | 188 self._gtest_filter = args.test_filter |
182 elif args.test_filter_file: | 189 elif args.test_filter_file: |
183 with open(args.test_filter_file, 'r') as f: | 190 with open(args.test_filter_file, 'r') as f: |
184 self._gtest_filter = ':'.join(l.strip() for l in f) | 191 self._gtest_filter = ':'.join(l.strip() for l in f) |
185 else: | 192 else: |
186 self._gtest_filter = None | 193 self._gtest_filter = None |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
227 | 234 |
228 @property | 235 @property |
229 def app_file_dir(self): | 236 def app_file_dir(self): |
230 return self._app_data_file_dir | 237 return self._app_data_file_dir |
231 | 238 |
232 @property | 239 @property |
233 def app_files(self): | 240 def app_files(self): |
234 return self._app_data_files | 241 return self._app_data_files |
235 | 242 |
236 @property | 243 @property |
237 def exe(self): | 244 def exe_dist_dir(self): |
238 return self._exe_path | 245 return self._exe_dist_dir |
239 | 246 |
240 @property | 247 @property |
241 def extras(self): | 248 def extras(self): |
242 return self._extras | 249 return self._extras |
243 | 250 |
244 @property | 251 @property |
245 def gtest_filter(self): | 252 def gtest_filter(self): |
246 return self._gtest_filter | 253 return self._gtest_filter |
247 | 254 |
248 @property | 255 @property |
(...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
397 result_type = None | 404 result_type = None |
398 | 405 |
399 return results | 406 return results |
400 | 407 |
401 #override | 408 #override |
402 def TearDown(self): | 409 def TearDown(self): |
403 """Clear the mappings created by SetUp.""" | 410 """Clear the mappings created by SetUp.""" |
404 if self._isolate_delegate: | 411 if self._isolate_delegate: |
405 self._isolate_delegate.Clear() | 412 self._isolate_delegate.Clear() |
406 | 413 |
OLD | NEW |