OLD | NEW |
1 # Copyright 2013 The Chromium Authors. All rights reserved. | 1 # Copyright 2013 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 """Generates test runner factory and tests for GTests.""" | 5 """Generates test runner factory and tests for GTests.""" |
6 | 6 |
7 import fnmatch | 7 import fnmatch |
8 import glob | 8 import glob |
9 import logging | 9 import logging |
10 import os | 10 import os |
(...skipping 239 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
250 tests, bool(gtest_filter), bool(gtest_filter)) | 250 tests, bool(gtest_filter), bool(gtest_filter)) |
251 tests = unittest_util.FilterTestNames( | 251 tests = unittest_util.FilterTestNames( |
252 tests, _GetDisabledTestsFilterFromFile(suite_name)) | 252 tests, _GetDisabledTestsFilterFromFile(suite_name)) |
253 | 253 |
254 if gtest_filter: | 254 if gtest_filter: |
255 tests = unittest_util.FilterTestNames(tests, gtest_filter) | 255 tests = unittest_util.FilterTestNames(tests, gtest_filter) |
256 | 256 |
257 return tests | 257 return tests |
258 | 258 |
259 | 259 |
260 def Setup(suite_name, test_arguments, timeout, | 260 def Setup(test_options): |
261 cleanup_test_files, tool, build_type, push_deps, | |
262 gtest_filter): | |
263 """Create the test runner factory and tests. | 261 """Create the test runner factory and tests. |
264 | 262 |
265 Args: | 263 Args: |
266 suite_name: The suite name specified on the command line. | 264 test_options: A GTestOptions object. |
267 test_arguments: Additional arguments to pass to the test binary. | |
268 timeout: Timeout for each test. | |
269 cleanup_test_files: Whether or not to cleanup test files on device. | |
270 tool: Name of the Valgrind tool. | |
271 build_type: 'Release' or 'Debug'. | |
272 push_deps: If True, push all dependencies to the device. | |
273 gtest_filter: Filter for tests. | |
274 | 265 |
275 Returns: | 266 Returns: |
276 A tuple of (TestRunnerFactory, tests). | 267 A tuple of (TestRunnerFactory, tests). |
277 """ | 268 """ |
278 | 269 |
279 if not ports.ResetTestServerPortAllocation(): | 270 if not ports.ResetTestServerPortAllocation(): |
280 raise Exception('Failed to reset test server port.') | 271 raise Exception('Failed to reset test server port.') |
281 | 272 |
282 test_package = test_package_apk.TestPackageApk(suite_name, build_type) | 273 test_package = test_package_apk.TestPackageApk(test_options.suite_name, |
| 274 test_options.build_type) |
283 if not os.path.exists(test_package.suite_path): | 275 if not os.path.exists(test_package.suite_path): |
284 test_package = test_package_exe.TestPackageExecutable( | 276 test_package = test_package_exe.TestPackageExecutable( |
285 suite_name, build_type) | 277 test_options.suite_name, test_options.build_type) |
286 if not os.path.exists(test_package.suite_path): | 278 if not os.path.exists(test_package.suite_path): |
287 raise Exception( | 279 raise Exception( |
288 'Did not find %s target. Ensure it has been built.' % suite_name) | 280 'Did not find %s target. Ensure it has been built.' |
| 281 % test_options.suite_name) |
289 logging.warning('Found target %s', test_package.suite_path) | 282 logging.warning('Found target %s', test_package.suite_path) |
290 | 283 |
291 _GenerateDepsDirUsingIsolate(suite_name, build_type) | 284 _GenerateDepsDirUsingIsolate(test_options.suite_name, |
| 285 test_options.build_type) |
292 | 286 |
293 # Constructs a new TestRunner with the current options. | 287 # Constructs a new TestRunner with the current options. |
294 def TestRunnerFactory(device, shard_index): | 288 def TestRunnerFactory(device, shard_index): |
295 return test_runner.TestRunner( | 289 return test_runner.TestRunner( |
| 290 test_options, |
296 device, | 291 device, |
297 test_package, | 292 test_package) |
298 test_arguments, | |
299 timeout, | |
300 cleanup_test_files, | |
301 tool, | |
302 build_type, | |
303 push_deps) | |
304 | 293 |
305 attached_devices = android_commands.GetAttachedDevices() | 294 attached_devices = android_commands.GetAttachedDevices() |
306 tests = _GetTestsFiltered(suite_name, gtest_filter, | 295 tests = _GetTestsFiltered(test_options.suite_name, test_options.gtest_filter, |
307 TestRunnerFactory, attached_devices) | 296 TestRunnerFactory, attached_devices) |
308 # Coalesce unit tests into a single test per device | 297 # Coalesce unit tests into a single test per device |
309 if suite_name != 'content_browsertests': | 298 if test_options.suite_name != 'content_browsertests': |
310 num_devices = len(attached_devices) | 299 num_devices = len(attached_devices) |
311 tests = [':'.join(tests[i::num_devices]) for i in xrange(num_devices)] | 300 tests = [':'.join(tests[i::num_devices]) for i in xrange(num_devices)] |
312 tests = [t for t in tests if t] | 301 tests = [t for t in tests if t] |
313 | 302 |
314 return (TestRunnerFactory, tests) | 303 return (TestRunnerFactory, tests) |
OLD | NEW |