| Index: build/android/pylib/host_driven/test_runner.py
|
| diff --git a/build/android/pylib/host_driven/test_runner.py b/build/android/pylib/host_driven/test_runner.py
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..cccc8f7682446ce26712b6b8da5e0dab8b0751d5
|
| --- /dev/null
|
| +++ b/build/android/pylib/host_driven/test_runner.py
|
| @@ -0,0 +1,74 @@
|
| +# Copyright (c) 2012 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.
|
| +
|
| +"""Runs host-driven tests on a particular device."""
|
| +
|
| +from pylib.base import base_test_runner
|
| +
|
| +import test_case
|
| +
|
| +
|
| +class HostDrivenTestRunner(base_test_runner.BaseTestRunner):
|
| + """Thin wrapper around a list of HostDrivenTestCase instances.
|
| +
|
| + This is meant to be a long-lived object which can run multiple host-driven
|
| + tests within its lifetime. Tests will receive the device_id and shard_index.
|
| +
|
| + The shard index affords the ability to create unique port numbers (e.g.
|
| + DEFAULT_PORT + shard_index) if the test so wishes.
|
| + """
|
| +
|
| + #override
|
| + def __init__(self, device, shard_index, tool, build_type, push_deps,
|
| + cleanup_test_files):
|
| + """Create a new HostDrivenTestRunner
|
| +
|
| + Args:
|
| + device: Attached android device.
|
| + shard_index: Shard index.
|
| + tool: Name of the Valgrind tool.
|
| + build_type: 'Release' or 'Debug'.
|
| + push_deps: If True, push all dependencies to the device.
|
| + cleanup_test_files: Whether or not to cleanup test files on device.
|
| + """
|
| +
|
| + super(HostDrivenTestRunner, self).__init__(device, tool, build_type,
|
| + push_deps, cleanup_test_files)
|
| + self.shard_index = shard_index
|
| +
|
| + #override
|
| + def RunTest(self, test):
|
| + """Sets up and runs a test case.
|
| +
|
| + Args:
|
| + test: An object which is ostensibly a subclass of HostDrivenTestCase.
|
| +
|
| + Returns:
|
| + A TestRunResults object which contains the result produced by the test
|
| + and, in the case of a failure, the test that should be retried.
|
| + """
|
| +
|
| + assert(isinstance(test, test_case.HostDrivenTestCase))
|
| + test.SetUp(self.device, self.shard_index, self.build_type, self._push_deps,
|
| + self._cleanup_test_files)
|
| + try:
|
| + exception_thrown = False
|
| + results = test.Run()
|
| + except:
|
| + # Set a flag to make sure exceptions in Run() take priority
|
| + exception_thrown = True
|
| + raise
|
| + finally:
|
| + try:
|
| + test.TearDown()
|
| + except:
|
| + # Re-raise only if Run() didn't fail, since exceptions in Run() take
|
| + # priority for reporting.
|
| + if not exception_thrown:
|
| + raise
|
| +
|
| + if not results.DidRunPass():
|
| + return results, test
|
| + else:
|
| + return results, None
|
|
|