| Index: build/android/run_monkey_test.py
|
| diff --git a/build/android/run_monkey_test.py b/build/android/run_monkey_test.py
|
| index 3160641684c020be0cd9bbab7e8dd5cfef9ec522..961eaa7ef1cd9f8a103d4d36edafe92144662a92 100755
|
| --- a/build/android/run_monkey_test.py
|
| +++ b/build/android/run_monkey_test.py
|
| @@ -10,6 +10,7 @@ import random
|
| import sys
|
|
|
| from pylib import android_commands
|
| +from pylib import dispatch
|
| from pylib.base import base_test_result
|
| from pylib.host_driven import python_test_base
|
| from pylib.host_driven import python_test_sharder
|
| @@ -87,37 +88,27 @@ class MonkeyTest(python_test_base.PythonTestBase):
|
| return self.adb.RunShellCommand(' '.join(cmd), timeout_time=timeout_ms)
|
|
|
|
|
| -def DispatchPythonTests(options):
|
| - """Dispatches the Monkey tests, sharding it if there multiple devices."""
|
| +def RunMonkeyTests(options):
|
| + """Runs the Monkey tests, replicating it if there multiple devices."""
|
| logger = logging.getLogger()
|
| logger.setLevel(logging.DEBUG)
|
| - attached_devices = android_commands.GetAttachedDevices()
|
| - if not attached_devices:
|
| - raise Exception('You have no devices attached or visible!')
|
|
|
| # Actually run the tests.
|
| logging.debug('Running monkey tests.')
|
| - # TODO(frankf): This is a stop-gap solution. Come up with a
|
| - # general way for running tests on every devices.
|
| - available_tests = []
|
| - for k in range(len(attached_devices)):
|
| - new_method = 'testMonkey%d' % k
|
| - setattr(MonkeyTest, new_method, MonkeyTest.testMonkey)
|
| - available_tests.append(MonkeyTest(new_method))
|
| - options.ensure_value('shard_retries', 1)
|
| - sharder = python_test_sharder.PythonTestSharder(
|
| - attached_devices, available_tests, options)
|
| - results = sharder.RunShardedTests()
|
| + available_tests = [MonkeyTest('testMonkey')]
|
| +
|
| + def TestRunnerFactory(device, shard_index):
|
| + return python_test_sharder.PythonTestRunner(options, device, shard_index)
|
| +
|
| + results, exit_code = dispatch.Dispatch(
|
| + options, available_tests, TestRunnerFactory, distribution='replicate')
|
| report_results.LogFull(
|
| results=results,
|
| test_type='Monkey',
|
| test_package='Monkey',
|
| build_type=options.build_type)
|
| - # TODO(gkanwar): After the host-driven tests have been refactored, they sould
|
| - # use the comment exit code system (part of pylib/base/shard.py)
|
| - if not results.DidRunPass():
|
| - return 1
|
| - return 0
|
| +
|
| + return exit_code
|
|
|
|
|
| def main():
|
| @@ -156,7 +147,7 @@ def main():
|
| if options.category:
|
| options.category = options.category.split(',')
|
|
|
| - DispatchPythonTests(options)
|
| + RunMonkeyTests(options)
|
|
|
|
|
| if __name__ == '__main__':
|
|
|