| Index: build/android/pylib/browsertests/test_sharder.py
|
| diff --git a/build/android/pylib/browsertests/test_sharder.py b/build/android/pylib/browsertests/test_sharder.py
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..49d3a0577881cbd2bf7577e53f2784af87bf0004
|
| --- /dev/null
|
| +++ b/build/android/pylib/browsertests/test_sharder.py
|
| @@ -0,0 +1,48 @@
|
| +# Copyright (c) 2013 The Chromium Authors. All rights reserved.
|
| +# Use of this source code is governed by a BSD-style license that can be
|
| +# found in the LICENSE file.
|
| +
|
| +from pylib.base import base_test_sharder
|
| +
|
| +import test_runner
|
| +
|
| +class TestSharder(base_test_sharder.BaseTestSharder):
|
| + """Responsible for sharding the tests on the connected devices."""
|
| +
|
| + def __init__(self, attached_devices, test_suite, gtest_filter,
|
| + test_arguments, timeout, cleanup_test_files, tool,
|
| + build_type):
|
| + super(TestSharder, self).__init__(attached_devices, build_type)
|
| + self.test_suite = test_suite
|
| + self.gtest_filter = gtest_filter or ''
|
| + self.test_arguments = test_arguments
|
| + self.timeout = timeout
|
| + self.cleanup_test_files = cleanup_test_files
|
| + self.tool = tool
|
| + self.all_tests = []
|
| + if not self.gtest_filter:
|
| + # TODO(nileshagrawal): Add support to get all the tests.
|
| + raise Exception('You have not specified a test filter.')
|
| + self.tests = self.all_tests
|
| +
|
| + def CreateShardedTestRunner(self, device, index):
|
| + """Creates a suite-specific test runner.
|
| +
|
| + Args:
|
| + device: Device serial where this shard will run.
|
| + index: Index of this device in the pool.
|
| +
|
| + Returns:
|
| + A TestRunner object.
|
| + """
|
| + device_num = len(self.attached_devices)
|
| + shard_test_list = self.tests[index::device_num]
|
| + test_filter = ':'.join(shard_test_list) + self.gtest_filter
|
| + return test_runner.TestRunner(
|
| + device,
|
| + self.test_suite,
|
| + test_filter,
|
| + self.test_arguments,
|
| + self.timeout,
|
| + self.cleanup_test_files, self.tool, index,
|
| + self.build_type)
|
|
|