| 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 271 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 282 tests, bool(gtest_filter), bool(gtest_filter)) | 282 tests, bool(gtest_filter), bool(gtest_filter)) |
| 283 tests = unittest_util.FilterTestNames( | 283 tests = unittest_util.FilterTestNames( |
| 284 tests, _GetDisabledTestsFilterFromFile(suite_name)) | 284 tests, _GetDisabledTestsFilterFromFile(suite_name)) |
| 285 | 285 |
| 286 if gtest_filter: | 286 if gtest_filter: |
| 287 tests = unittest_util.FilterTestNames(tests, gtest_filter) | 287 tests = unittest_util.FilterTestNames(tests, gtest_filter) |
| 288 | 288 |
| 289 return tests | 289 return tests |
| 290 | 290 |
| 291 | 291 |
| 292 def Setup(use_exe_test_runner, suite_name, test_arguments, timeout, | 292 def Setup(test_options): |
| 293 cleanup_test_files, tool, build_type, push_deps, | |
| 294 gtest_filter): | |
| 295 """Create the test runner factory and tests. | 293 """Create the test runner factory and tests. |
| 296 | 294 |
| 297 Args: | 295 Args: |
| 298 use_exe_test_runner: If True, use the executable-based test runner. | 296 test_options: A GTestOptions object containing all options relevant to |
| 299 suite_name: The suite name specified on the command line. | 297 running gtests. |
| 300 test_arguments: Additional arguments to pass to the test binary. | |
| 301 timeout: Timeout for each test. | |
| 302 cleanup_test_files: Whether or not to cleanup test files on device. | |
| 303 tool: Name of the Valgrind tool. | |
| 304 build_type: 'Release' or 'Debug'. | |
| 305 push_deps: If True, push all dependencies to the device. | |
| 306 gtest_filter: Filter for tests. | |
| 307 | 298 |
| 308 Returns: | 299 Returns: |
| 309 A tuple of (TestRunnerFactory, tests). | 300 A tuple of (TestRunnerFactory, tests). |
| 310 """ | 301 """ |
| 311 | 302 |
| 312 if not ports.ResetTestServerPortAllocation(): | 303 if not ports.ResetTestServerPortAllocation(): |
| 313 raise Exception('Failed to reset test server port.') | 304 raise Exception('Failed to reset test server port.') |
| 314 | 305 |
| 315 suite_path = _GetSuitePath(use_exe_test_runner, suite_name, build_type) | 306 suite_path = _GetSuitePath(test_options.exe, |
| 307 test_options.suite_name, |
| 308 test_options.build_type) |
| 316 | 309 |
| 317 # TODO(gkanwar): This breaks the abstraction of having test_dispatcher.py deal | 310 # TODO(gkanwar): This breaks the abstraction of having test_dispatcher.py deal |
| 318 # entirely with the devices. Can we do this another way? | 311 # entirely with the devices. Can we do this another way? |
| 319 attached_devices = android_commands.GetAttachedDevices() | 312 attached_devices = android_commands.GetAttachedDevices() |
| 320 | 313 |
| 321 deps_dir = _GenerateDepsDirUsingIsolate(suite_name, build_type) | |
| 322 # Constructs a new TestRunner with the current options. | 314 # Constructs a new TestRunner with the current options. |
| 323 def TestRunnerFactory(device, shard_index): | 315 def TestRunnerFactory(device, shard_index): |
| 324 return test_runner.TestRunner( | 316 return test_runner.TestRunner( |
| 317 test_options, |
| 318 suite_path, |
| 325 device, | 319 device, |
| 326 suite_path, | |
| 327 test_arguments, | |
| 328 timeout, | |
| 329 cleanup_test_files, | |
| 330 tool, | |
| 331 build_type, | |
| 332 push_deps, | |
| 333 constants.GTEST_TEST_PACKAGE_NAME, | 320 constants.GTEST_TEST_PACKAGE_NAME, |
| 334 constants.GTEST_TEST_ACTIVITY_NAME, | 321 constants.GTEST_TEST_ACTIVITY_NAME, |
| 335 constants.GTEST_COMMAND_LINE_FILE) | 322 constants.GTEST_COMMAND_LINE_FILE) |
| 336 | 323 |
| 337 # Get tests and split them up based on the number of devices. | 324 # Get tests and split them up based on the number of devices. |
| 338 tests = GetTestsFiltered(suite_name, gtest_filter, | 325 tests = GetTestsFiltered(test_options.suite_name, |
| 326 test_options.gtest_filter, |
| 339 TestRunnerFactory, attached_devices) | 327 TestRunnerFactory, attached_devices) |
| 340 num_devices = len(attached_devices) | 328 num_devices = len(attached_devices) |
| 341 tests = [':'.join(tests[i::num_devices]) for i in xrange(num_devices)] | 329 tests = [':'.join(tests[i::num_devices]) for i in xrange(num_devices)] |
| 342 tests = [t for t in tests if t] | 330 tests = [t for t in tests if t] |
| 343 | 331 |
| 344 return (TestRunnerFactory, tests) | 332 return (TestRunnerFactory, tests) |
| OLD | NEW |