diff options
Diffstat (limited to 'build/android/pylib/python_test_sharder.py')
-rw-r--r-- | build/android/pylib/python_test_sharder.py | 23 |
1 files changed, 13 insertions, 10 deletions
diff --git a/build/android/pylib/python_test_sharder.py b/build/android/pylib/python_test_sharder.py index 7bab235..e27096d 100644 --- a/build/android/pylib/python_test_sharder.py +++ b/build/android/pylib/python_test_sharder.py @@ -4,6 +4,7 @@ """Takes care of sharding the python-drive tests in multiple devices.""" +import copy import logging import multiprocessing @@ -50,15 +51,13 @@ class PythonTestRunner(object): DEFAULT_PORT + shard_index) if the test so wishes. """ - def __init__(self, device_id, shard_index): + def __init__(self, options): """Constructor. Args: - device_id: ID of the device which this test will talk to. - shard_index: shard index, used to create such as unique port numbers. + options: Options to use for setting up tests. """ - self.device_id = device_id - self.shard_index = shard_index + self.options = options def RunTests(self): """Runs tests from the shared pool of tests, aggregating results. @@ -70,7 +69,7 @@ class PythonTestRunner(object): results = [] for t in tests: - res = CallPythonTest(t, self.device_id, self.shard_index) + res = CallPythonTest(t, self.options) results.append(res) return TestResults.FromTestResults(results) @@ -86,17 +85,18 @@ class PythonTestSharder(object): Args: attached_devices: a list of device IDs attached to the host. - shard_retries: number of retries for any given test. available_tests: a list of tests to run which subclass PythonTestBase. + options: Options to use for setting up tests. Returns: An aggregated list of test results. """ tests_container = None - def __init__(self, attached_devices, shard_retries, available_tests): + def __init__(self, attached_devices, available_tests, options): + self.options = options self.attached_devices = attached_devices - self.retries = shard_retries + self.retries = options.shard_retries self.tests = available_tests def _SetupSharding(self, tests): @@ -178,7 +178,10 @@ class PythonTestSharder(object): logging.warning('*' * 80) # Bind the PythonTestRunner to a device & shard index. Give it the # runnable which it will use to actually execute the tests. - test_runner = PythonTestRunner(device, index) + test_options = copy.deepcopy(self.options) + test_options.ensure_value('device_id', device) + test_options.ensure_value('shard_index', index) + test_runner = PythonTestRunner(test_options) test_runners.append(test_runner) return test_runners |