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 | |
25 from pylib.utils import reraiser_thread | 24 from pylib.utils import reraiser_thread |
26 from pylib.utils import watchdog_timer | 25 from pylib.utils import watchdog_timer |
27 | 26 |
28 import base_test_result | 27 import base_test_result |
29 | 28 |
30 | 29 |
31 DEFAULT_TIMEOUT = 7 * 60 # seven minutes | 30 DEFAULT_TIMEOUT = 7 * 60 # seven minutes |
32 | 31 |
33 | 32 |
34 class _ThreadSafeCounter(object): | 33 class _ThreadSafeCounter(object): |
(...skipping 339 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
374 tag_results_with_device = False | 373 tag_results_with_device = False |
375 else: | 374 else: |
376 # Generate a unique _TestCollection object for each test runner, but use | 375 # Generate a unique _TestCollection object for each test runner, but use |
377 # the same set of tests. | 376 # the same set of tests. |
378 test_collection_factory = lambda: _TestCollection([_Test(t) for t in tests]) | 377 test_collection_factory = lambda: _TestCollection([_Test(t) for t in tests]) |
379 tag_results_with_device = True | 378 tag_results_with_device = True |
380 | 379 |
381 devices = _GetAttachedDevices(wait_for_debugger, test_device) | 380 devices = _GetAttachedDevices(wait_for_debugger, test_device) |
382 | 381 |
383 logging.info('Will run %d tests: %s', len(tests), str(tests)) | 382 logging.info('Will run %d tests: %s', len(tests), str(tests)) |
384 forwarder.Forwarder.KillHost(build_type) | |
385 runners = _CreateRunners(runner_factory, devices, setup_timeout) | 383 runners = _CreateRunners(runner_factory, devices, setup_timeout) |
386 try: | 384 try: |
387 return _RunAllTests(runners, test_collection_factory, | 385 return _RunAllTests(runners, test_collection_factory, |
388 num_retries, test_timeout, tag_results_with_device) | 386 num_retries, test_timeout, tag_results_with_device) |
389 finally: | 387 finally: |
390 try: | 388 try: |
391 _TearDownRunners(runners, setup_timeout) | 389 _TearDownRunners(runners, setup_timeout) |
392 except android_commands.errors.DeviceUnresponsiveError as e: | 390 except android_commands.errors.DeviceUnresponsiveError as e: |
393 logging.warning('Device unresponsive during TearDown: [%s]', e) | 391 logging.warning('Device unresponsive during TearDown: [%s]', e) |
394 finally: | |
395 forwarder.Forwarder.KillHost(build_type) | |
OLD | NEW |