| Index: build/android/pylib/local/device/local_device_test_run.py
|
| diff --git a/build/android/pylib/local/device/local_device_test_run.py b/build/android/pylib/local/device/local_device_test_run.py
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..bf2f8014cd1e178ada34a1a83e7d4b716a25ebf6
|
| --- /dev/null
|
| +++ b/build/android/pylib/local/device/local_device_test_run.py
|
| @@ -0,0 +1,63 @@
|
| +# Copyright 2014 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_result
|
| +from pylib.base import test_run
|
| +from pylib.base import test_collection
|
| +
|
| +
|
| +class LocalDeviceTestRun(test_run.TestRun):
|
| +
|
| + #override
|
| + def RunTests(self):
|
| + tests = self._GetTests()
|
| +
|
| + def run_tests_on_device(dev, tests):
|
| + r = base_test_result.TestRunResults()
|
| + for test in tests:
|
| + result = self._RunTest(dev, test)
|
| + if isinstance(result, base_test_result.BaseTestResult):
|
| + r.AddResult(result)
|
| + elif isinstance(result, list):
|
| + r.AddResults(result)
|
| + else:
|
| + raise Exception('Unexpected result type: %s' % type(result).__name__)
|
| + if isinstance(tests, test_collection.TestCollection):
|
| + tests.test_completed()
|
| + return r
|
| +
|
| + tries = 0
|
| + results = base_test_result.TestRunResults()
|
| + while tries < self._env.max_tries and tests:
|
| + if self._ShouldShard():
|
| + tests = test_collection.TestCollection(self._CreateShards(tests))
|
| + try_results = self._env.parallel_devices.pMap(
|
| + run_tests_on_device, tests).pGet(None)
|
| + fail_results = []
|
| + for try_result in try_results:
|
| + for result in try_result.GetAll():
|
| + if result.GetType() in (base_test_result.ResultType.PASS,
|
| + base_test_result.ResultType.SKIP):
|
| + results.AddResult(result)
|
| + else:
|
| + fail_results.append(result)
|
| + tests = [f.GetName() for f in fail_results]
|
| + tries += 1
|
| +
|
| + if fail_results:
|
| + results.AddTestResults(fail_results)
|
| + return results
|
| +
|
| + def _CreateShards(self, tests):
|
| + raise NotImplementedError
|
| +
|
| + def _GetTests(self):
|
| + raise NotImplementedError
|
| +
|
| + def _RunTest(self, device, test):
|
| + raise NotImplementedError
|
| +
|
| + def _ShouldShard(self):
|
| + raise NotImplementedError
|
|
|