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

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

Issue 607583002: [Android] Fix UIAutomator test running. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 3 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
« no previous file with comments | « no previous file | build/android/pylib/instrumentation/test_runner_test.py » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: build/android/pylib/instrumentation/test_runner.py
diff --git a/build/android/pylib/instrumentation/test_runner.py b/build/android/pylib/instrumentation/test_runner.py
index ff0dcbdd3c54b0c2fe537baad94f416fd8f920cd..d70f3ec12c1f6834a80ac177d0e0563948f4558c 100644
--- a/build/android/pylib/instrumentation/test_runner.py
+++ b/build/android/pylib/instrumentation/test_runner.py
@@ -339,44 +339,26 @@ class TestRunner(base_test_runner.BaseTestRunner):
"1 minute for timeout.").format(test))
return 1 * 60
- def RunInstrumentationTest(self, test, test_package, instr_args, timeout):
+ def _RunTest(self, test, timeout):
"""Runs a single instrumentation test.
Args:
test: Test class/method.
- test_package: Package name of test apk.
- instr_args: Extra key/value to pass to am instrument.
timeout: Timeout time in seconds.
Returns:
- An instance of InstrumentationTestResult
+ The raw output of am instrument as a list of lines.
"""
# Build the 'am instrument' command
instrumentation_path = (
- '%s/%s' % (test_package, self.options.test_runner))
+ '%s/%s' % (self.test_pkg.GetPackageName(), self.options.test_runner))
cmd = ['am', 'instrument', '-r']
- for k, v in instr_args.iteritems():
+ for k, v in self._GetInstrumentationArgs().iteritems():
cmd.extend(['-e', k, "'%s'" % v])
cmd.extend(['-e', 'class', "'%s'" % test])
cmd.extend(['-w', instrumentation_path])
-
- time_ms = lambda: int(time.time() * 1000)
-
- # Run the test.
- start_ms = time_ms()
- try:
- instr_output = self.device.RunShellCommand(
- cmd, timeout=timeout, retries=0)
- except device_errors.CommandTimeoutError:
- return test_result.InstrumentationTestResult(
- test, base_test_result.ResultType.TIMEOUT, start_ms,
- time_ms() - start_ms)
- duration_ms = time_ms() - start_ms
-
- # Parse the test output
- _, _, statuses = self._ParseAmInstrumentRawOutput(instr_output)
- return self._GenerateTestResult(test, statuses, start_ms, duration_ms)
+ return self.device.RunShellCommand(cmd, timeout=timeout, retries=0)
@staticmethod
def _ParseAmInstrumentRawOutput(raw_output):
@@ -502,19 +484,32 @@ class TestRunner(base_test_runner.BaseTestRunner):
timeout = (self._GetIndividualTestTimeoutSecs(test) *
self._GetIndividualTestTimeoutScale(test) *
self.tool.GetTimeoutScale())
+
+ start_ms = 0
+ duration_ms = 0
try:
self.TestSetup(test)
- result = self.RunInstrumentationTest(
- test, self.test_pkg.GetPackageName(), self._GetInstrumentationArgs(),
- timeout)
+
+ time_ms = lambda: int(time.time() * 1000)
+ start_ms = time_ms()
+ raw_output = self._RunTest(test, timeout)
+ duration_ms = time_ms() - start_ms
+
+ # Parse the test output
+ _, _, statuses = self._ParseAmInstrumentRawOutput(raw_output)
+ result = self._GenerateTestResult(test, statuses, start_ms, duration_ms)
results.AddResult(result)
except (device_errors.CommandTimeoutError,
device_errors.DeviceUnreachableError) as e:
message = str(e)
if not message:
- message = 'No information.'
+ message = 'No information'
+ result_type = base_test_result.ResultType.UNKNOWN
+ if isinstance(e, device_errors.CommandTimeoutError):
craigdh 2014/09/25 19:59:47 Handle different error types by having multiple ex
jbudorick 2014/09/25 20:07:00 I was between the two, since the code is otherwise
+ result_type = base_test_result.ResultType.TIMEOUT
+ elif isinstance(e, device_errors.DeviceUnreachableError):
+ result_type = base_test_result.ResultType.CRASH
results.AddResult(test_result.InstrumentationTestResult(
- test, base_test_result.ResultType.CRASH, int(time.time() * 1000), 0,
- log=message))
+ test, result_type, start_ms, duration_ms, log=message))
self.TestTeardown(test, results)
return (results, None if results.DidRunPass() else test)
« no previous file with comments | « no previous file | build/android/pylib/instrumentation/test_runner_test.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698