Index: build/android/pylib/gtest/dispatch.py |
diff --git a/build/android/pylib/gtest/dispatch.py b/build/android/pylib/gtest/dispatch.py |
index 3dfb2620c3f74c4af6bfd7813194933031ac0af5..8c1fcbd70fff6d6b535d5fc01364234300b3a226 100644 |
--- a/build/android/pylib/gtest/dispatch.py |
+++ b/build/android/pylib/gtest/dispatch.py |
@@ -2,7 +2,7 @@ |
# Use of this source code is governed by a BSD-style license that can be |
# found in the LICENSE file. |
-"""Dispatches GTests.""" |
+"""Runs GTests.""" |
import copy |
import fnmatch |
@@ -14,12 +14,12 @@ import shutil |
from pylib import android_commands |
from pylib import cmd_helper |
from pylib import constants |
+from pylib import dispatch |
from pylib import ports |
from pylib.base import base_test_result |
from pylib.base import shard |
from pylib.utils import emulator |
from pylib.utils import report_results |
-from pylib.utils import xvfb |
import gtest_config |
import test_runner |
@@ -207,8 +207,8 @@ def GetAllEnabledTests(runner_factory, devices): |
then filters it again using the disabled list on the host. |
Args: |
- runner_factory: callable that takes a devices and returns a TestRunner. |
- devices: list of devices. |
+ runner_factory: callable that takes devide and shard_index and returns |
frankf
2013/07/12 22:28:28
?
gkanwar
2013/07/12 22:53:34
s/devide/device/
Fixed.
|
+ a TestRunner. |
Returns: |
List of all enabled tests. |
@@ -245,21 +245,6 @@ def _RunATestSuite(options, suite_name): |
Exception: For various reasons including device failure or failing to reset |
the test server port. |
""" |
- attached_devices = [] |
- buildbot_emulators = [] |
- |
- if options.use_emulator: |
- buildbot_emulators = emulator.LaunchEmulators(options.emulator_count, |
- options.abi, |
- wait_for_boot=True) |
- attached_devices = [e.device for e in buildbot_emulators] |
- elif options.test_device: |
- attached_devices = [options.test_device] |
- else: |
- attached_devices = android_commands.GetAttachedDevices() |
- |
- if not attached_devices: |
- raise Exception('A device must be attached and online.') |
# Reset the test port allocation. It's important to do it before starting |
# to dispatch any tests. |
@@ -269,7 +254,7 @@ def _RunATestSuite(options, suite_name): |
deps_dir = _GenerateDepsDirUsingIsolate(suite_name, options.build_type) |
# Constructs a new TestRunner with the current options. |
- def RunnerFactory(device, shard_index): |
+ def TestRunnerFactory(device, shard_index): |
return test_runner.TestRunner( |
device, |
options.test_suite, |
@@ -285,19 +270,21 @@ def _RunATestSuite(options, suite_name): |
constants.GTEST_COMMAND_LINE_FILE, |
deps_dir=deps_dir) |
+ # TODO(gkanwar): This breaks the abstraction of having dispatch.Dispatch deal |
+ # entirely with the devices. Can we do this another way? |
+ attached_devices = android_commands.GetAttachedDevices() |
# Get tests and split them up based on the number of devices. |
if options.test_filter: |
all_tests = [t for t in options.test_filter.split(':') if t] |
else: |
- all_tests = GetAllEnabledTests(RunnerFactory, attached_devices) |
+ all_tests = GetAllEnabledTests(TestRunnerFactory, attached_devices) |
num_devices = len(attached_devices) |
tests = [':'.join(all_tests[i::num_devices]) for i in xrange(num_devices)] |
tests = [t for t in tests if t] |
# Run tests. |
- test_results, exit_code = shard.ShardAndRunTests( |
- RunnerFactory, attached_devices, tests, options.build_type, |
- test_timeout=None, num_retries=options.num_retries) |
+ test_results, exit_code = dispatch.Dispatch(options, tests, TestRunnerFactory, |
+ sharding='distribute') |
report_results.LogFull( |
results=test_results, |
@@ -306,8 +293,6 @@ def _RunATestSuite(options, suite_name): |
build_type=options.build_type, |
flakiness_server=options.flakiness_dashboard_server) |
- for buildbot_emulator in buildbot_emulators: |
- buildbot_emulator.Shutdown() |
return (test_results, exit_code) |
@@ -319,8 +304,8 @@ def _ListTestSuites(): |
print test_suite |
-def Dispatch(options): |
- """Dispatches the tests, sharding if possible. |
+def RunGTests(options): |
+ """Runs the tests, sharding if possible. |
If options.use_emulator is True, all tests will be run in new emulator |
instance. |
@@ -337,10 +322,6 @@ def Dispatch(options): |
_ListTestSuites() |
return (results, 0) |
- if options.use_xvfb: |
- framebuffer = xvfb.Xvfb() |
- framebuffer.Start() |
- |
all_test_suites = _FullyQualifiedTestSuites(options.exe, options.test_suite, |
options.build_type) |
exit_code = 0 |
@@ -353,7 +334,4 @@ def Dispatch(options): |
if test_exit_code and exit_code != constants.ERROR_EXIT_CODE: |
exit_code = test_exit_code |
- if options.use_xvfb: |
- framebuffer.Stop() |
- |
return (results, exit_code) |