[Android] Upstream changes to android_testrunner.

1. Add option to suppress logging to omit sensitive information.
2. Change debug output to longMsg to aid debugging.

BUG=137853


Review URL: https://chromiumcodereview.appspot.com/10823093

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@149204 0039d316-1c4b-4281-b951-d872f2087c98
parent af551a68
...@@ -9,8 +9,10 @@ This package is the scripts used to run the unit test for Android and from ...@@ -9,8 +9,10 @@ This package is the scripts used to run the unit test for Android and from
Android Gingerbread. Android Gingerbread.
Local Modifications: Local Modifications:
There are no local modifications, all files were copied from 1. Added |silent_log| argument to |StartInstrumentation| so that output can be
<android_gingerbread_tree>/development/testrunner/ suppressed.
2. Changed error message handling in |StartInstrumentation| from |shortMsg| to
|longMsg| to provide more information when debugging.
Here is the detail steps Here is the detail steps
1. Checkout Android source code 1. Checkout Android source code
......
...@@ -176,7 +176,7 @@ class AdbInterface: ...@@ -176,7 +176,7 @@ class AdbInterface:
def StartInstrumentation( def StartInstrumentation(
self, instrumentation_path, timeout_time=60*10, no_window_animation=False, self, instrumentation_path, timeout_time=60*10, no_window_animation=False,
profile=False, instrumentation_args={}): profile=False, instrumentation_args={}, silent_log=False):
"""Runs an instrumentation class on the target. """Runs an instrumentation class on the target.
...@@ -195,6 +195,8 @@ class AdbInterface: ...@@ -195,6 +195,8 @@ class AdbInterface:
profile: If True, profiling will be turned on for the instrumentation. profile: If True, profiling will be turned on for the instrumentation.
instrumentation_args: Dictionary of key value bundle arguments to pass to instrumentation_args: Dictionary of key value bundle arguments to pass to
instrumentation. instrumentation.
silent_log: If True, the invocation of the instrumentation test runner
will not be logged.
Returns: Returns:
(test_results, inst_finished_bundle) (test_results, inst_finished_bundle)
...@@ -217,22 +219,26 @@ class AdbInterface: ...@@ -217,22 +219,26 @@ class AdbInterface:
instrumentation_path, no_window_animation=no_window_animation, instrumentation_path, no_window_animation=no_window_animation,
profile=profile, raw_mode=True, profile=profile, raw_mode=True,
instrumentation_args=instrumentation_args) instrumentation_args=instrumentation_args)
if silent_log:
logger.SilentLog(command_string)
else:
logger.Log(command_string) logger.Log(command_string)
(test_results, inst_finished_bundle) = ( (test_results, inst_finished_bundle) = (
am_instrument_parser.ParseAmInstrumentOutput( am_instrument_parser.ParseAmInstrumentOutput(
self.SendShellCommand(command_string, timeout_time=timeout_time, self.SendShellCommand(command_string, timeout_time=timeout_time,
retry_count=2))) retry_count=2)))
if "code" not in inst_finished_bundle: if "code" not in inst_finished_bundle:
logger.Log('No code available. inst_finished_bundle contains: %s '
% inst_finished_bundle)
raise errors.InstrumentationError("no test results... device setup " raise errors.InstrumentationError("no test results... device setup "
"correctly?") "correctly?")
if inst_finished_bundle["code"] == "0": if inst_finished_bundle["code"] == "0":
short_msg_result = "no error message" long_msg_result = "no error message"
if "shortMsg" in inst_finished_bundle: if "longMsg" in inst_finished_bundle:
short_msg_result = inst_finished_bundle["shortMsg"] long_msg_result = inst_finished_bundle["longMsg"]
logger.Log("Error! Test run failed: %s" % short_msg_result) logger.Log("Error! Test run failed: %s" % long_msg_result)
raise errors.InstrumentationError(short_msg_result) raise errors.InstrumentationError(long_msg_result)
if "INSTRUMENTATION_ABORTED" in inst_finished_bundle: if "INSTRUMENTATION_ABORTED" in inst_finished_bundle:
logger.Log("INSTRUMENTATION ABORTED!") logger.Log("INSTRUMENTATION ABORTED!")
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment