| 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 """Dispatches tests, either sharding or replicating them. |    5 """Dispatches tests, either sharding or replicating them. | 
|    6  |    6  | 
|    7 To dispatch, performs the following steps: |    7 To dispatch, performs the following steps: | 
|    8 * Create a test collection factory, using the given tests |    8 * Create a test collection factory, using the given tests | 
|    9   - If sharding: test collection factory returns the same shared test collection |    9   - If sharding: test collection factory returns the same shared test collection | 
|   10     to all test runners |   10     to all test runners | 
|   11   - If replciating: test collection factory returns a unique test collection to |   11   - If replciating: test collection factory returns a unique test collection to | 
|   12     each test runner, with the same set of tests in each. |   12     each test runner, with the same set of tests in each. | 
|   13 * Get the list of devices to run on |   13 * Get the list of devices to run on | 
|   14 * Create test runners |   14 * Create test runners | 
|   15 * Run each test runner in its own thread, pulling tests from the test collection |   15 * Run each test runner in its own thread, pulling tests from the test collection | 
|   16   generated from the test collection factory until there are no tests left. |   16   generated from the test collection factory until there are no tests left. | 
|   17 """ |   17 """ | 
|   18  |   18  | 
|   19 import logging |   19 import logging | 
|   20 import threading |   20 import threading | 
|   21  |   21  | 
|   22 from pylib import android_commands |   22 from pylib import android_commands | 
|   23 from pylib import constants |   23 from pylib import constants | 
 |   24 from pylib import forwarder | 
|   24 from pylib.utils import reraiser_thread |   25 from pylib.utils import reraiser_thread | 
|   25 from pylib.utils import watchdog_timer |   26 from pylib.utils import watchdog_timer | 
|   26  |   27  | 
|   27 import base_test_result |   28 import base_test_result | 
|   28  |   29  | 
|   29  |   30  | 
|   30 DEFAULT_TIMEOUT = 7 * 60  # seven minutes |   31 DEFAULT_TIMEOUT = 7 * 60  # seven minutes | 
|   31  |   32  | 
|   32  |   33  | 
|   33 class _ThreadSafeCounter(object): |   34 class _ThreadSafeCounter(object): | 
| (...skipping 339 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|  373     tag_results_with_device = False |  374     tag_results_with_device = False | 
|  374   else: |  375   else: | 
|  375     # Generate a unique _TestCollection object for each test runner, but use |  376     # Generate a unique _TestCollection object for each test runner, but use | 
|  376     # the same set of tests. |  377     # the same set of tests. | 
|  377     test_collection_factory = lambda: _TestCollection([_Test(t) for t in tests]) |  378     test_collection_factory = lambda: _TestCollection([_Test(t) for t in tests]) | 
|  378     tag_results_with_device = True |  379     tag_results_with_device = True | 
|  379  |  380  | 
|  380   devices = _GetAttachedDevices(wait_for_debugger, test_device) |  381   devices = _GetAttachedDevices(wait_for_debugger, test_device) | 
|  381  |  382  | 
|  382   logging.info('Will run %d tests: %s', len(tests), str(tests)) |  383   logging.info('Will run %d tests: %s', len(tests), str(tests)) | 
|  383  |  384   forwarder.Forwarder.KillHost(build_type) | 
|  384   runners = _CreateRunners(runner_factory, devices, setup_timeout) |  385   runners = _CreateRunners(runner_factory, devices, setup_timeout) | 
|  385   try: |  386   try: | 
|  386     return _RunAllTests(runners, test_collection_factory, |  387     return _RunAllTests(runners, test_collection_factory, | 
|  387                         num_retries, test_timeout, tag_results_with_device) |  388                         num_retries, test_timeout, tag_results_with_device) | 
|  388   finally: |  389   finally: | 
|  389     try: |  390     try: | 
|  390       _TearDownRunners(runners, setup_timeout) |  391       _TearDownRunners(runners, setup_timeout) | 
|  391     except android_commands.errors.DeviceUnresponsiveError as e: |  392     except android_commands.errors.DeviceUnresponsiveError as e: | 
|  392       logging.warning('Device unresponsive during TearDown: [%s]', e) |  393       logging.warning('Device unresponsive during TearDown: [%s]', e) | 
 |  394     finally: | 
 |  395       forwarder.Forwarder.KillHost(build_type) | 
| OLD | NEW |