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