Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(3043)

Unified Diff: build/android/pylib/host_driven/test_runner.py

Issue 19537004: [Android] Converts host driven tests to common test_dispatcher (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@sharding_refactoring
Patch Set: Several minor changes to variable names / comments Created 7 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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

Powered by Google App Engine
This is Rietveld 408576698