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_path = None | |
148 | 147 |
149 # GYP: | 148 self._exe_path = os.path.join(constants.GetOutDirectory(), |
150 if args.executable_path: | 149 self._suite) |
151 self._exe_path = os.path.abspath(args.executable_path) | |
152 else: | |
153 # TODO(agrieve): Remove hardcoding after recipes are updated. | |
154 if self._suite == 'sandbox_linux_unittests': | |
155 exe_path = os.path.join(constants.GetOutDirectory(), 'obj', 'sandbox', | |
156 'linux', 'sandbox_linux_unittests', | |
157 'sandbox_linux_unittests') | |
158 elif self._suite == 'breakpad_unittests': | |
159 exe_path = os.path.join(constants.GetOutDirectory(), 'obj', 'breakpad', | |
160 'breakpad_unittests', 'breakpad_unittests') | |
161 else: | |
162 exe_path = None | |
163 | |
164 if exe_path and os.path.exists(exe_path): | |
165 self._exe_path = exe_path | |
166 else: | |
167 # GYP location: | |
168 exe_path = os.path.join(constants.GetOutDirectory(), self._suite) | |
169 if os.path.exists(exe_path): | |
170 self._exe_path = exe_path | |
171 | 150 |
172 incremental_part = '' | 151 incremental_part = '' |
173 if args.test_apk_incremental_install_script: | 152 if args.test_apk_incremental_install_script: |
174 incremental_part = '_incremental' | 153 incremental_part = '_incremental' |
175 | 154 |
176 apk_path = os.path.join( | 155 apk_path = os.path.join( |
177 constants.GetOutDirectory(), '%s_apk' % self._suite, | 156 constants.GetOutDirectory(), '%s_apk' % self._suite, |
178 '%s-debug%s.apk' % (self._suite, incremental_part)) | 157 '%s-debug%s.apk' % (self._suite, incremental_part)) |
179 self._test_apk_incremental_install_script = ( | 158 self._test_apk_incremental_install_script = ( |
180 args.test_apk_incremental_install_script) | 159 args.test_apk_incremental_install_script) |
181 if not os.path.exists(apk_path): | 160 if not os.path.exists(apk_path): |
182 self._apk_helper = None | 161 self._apk_helper = None |
183 else: | 162 else: |
184 self._apk_helper = apk_helper.ApkHelper(apk_path) | 163 self._apk_helper = apk_helper.ApkHelper(apk_path) |
185 self._extras = { | 164 self._extras = { |
186 _EXTRA_NATIVE_TEST_ACTIVITY: self._apk_helper.GetActivityName(), | 165 _EXTRA_NATIVE_TEST_ACTIVITY: self._apk_helper.GetActivityName(), |
187 } | 166 } |
188 if self._suite in RUN_IN_SUB_THREAD_TEST_SUITES: | 167 if self._suite in RUN_IN_SUB_THREAD_TEST_SUITES: |
189 self._extras[_EXTRA_RUN_IN_SUB_THREAD] = 1 | 168 self._extras[_EXTRA_RUN_IN_SUB_THREAD] = 1 |
190 if self._suite in BROWSER_TEST_SUITES: | 169 if self._suite in BROWSER_TEST_SUITES: |
191 self._extras[_EXTRA_SHARD_SIZE_LIMIT] = 1 | 170 self._extras[_EXTRA_SHARD_SIZE_LIMIT] = 1 |
192 self._extras[EXTRA_SHARD_NANO_TIMEOUT] = int(1e9 * self._shard_timeout) | 171 self._extras[EXTRA_SHARD_NANO_TIMEOUT] = int(1e9 * self._shard_timeout) |
193 self._shard_timeout = 900 | 172 self._shard_timeout = 900 |
194 | 173 |
| 174 if not os.path.exists(self._exe_path): |
| 175 self._exe_path = None |
195 if not self._apk_helper and not self._exe_path: | 176 if not self._apk_helper and not self._exe_path: |
196 error_func('Could not find apk or executable for %s' % self._suite) | 177 error_func('Could not find apk or executable for %s' % self._suite) |
197 | 178 |
198 self._data_deps = [] | 179 self._data_deps = [] |
199 if args.test_filter: | 180 if args.test_filter: |
200 self._gtest_filter = args.test_filter | 181 self._gtest_filter = args.test_filter |
201 elif args.test_filter_file: | 182 elif args.test_filter_file: |
202 with open(args.test_filter_file, 'r') as f: | 183 with open(args.test_filter_file, 'r') as f: |
203 self._gtest_filter = ':'.join(l.strip() for l in f) | 184 self._gtest_filter = ':'.join(l.strip() for l in f) |
204 else: | 185 else: |
(...skipping 211 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
416 result_type = None | 397 result_type = None |
417 | 398 |
418 return results | 399 return results |
419 | 400 |
420 #override | 401 #override |
421 def TearDown(self): | 402 def TearDown(self): |
422 """Clear the mappings created by SetUp.""" | 403 """Clear the mappings created by SetUp.""" |
423 if self._isolate_delegate: | 404 if self._isolate_delegate: |
424 self._isolate_delegate.Clear() | 405 self._isolate_delegate.Clear() |
425 | 406 |
OLD | NEW |