Manual merge of runtest fixes in donut and new account test def add in master.
commit 8a101cb057c1d1d5397b988b6a3f4c3add879008
Author: Brett Chabot <brettchabot@google.com>
Date: Tue May 5 12:56:39 2009 -0700
runtest.py bug fixes.
Improved error handling, and added support for "size" and "package" arguments.
Removed deprecated runtest shell script.
diff --git a/testrunner/adb_interface.py b/testrunner/adb_interface.py
index ad1b2c9..dd8d6f4 100755
--- a/testrunner/adb_interface.py
+++ b/testrunner/adb_interface.py
@@ -64,7 +64,7 @@
string output of command
Raises:
- WaitForResponseTimedOutError if device does not respond to command
+ WaitForResponseTimedOutError if device does not respond to command within time
"""
adb_cmd = "adb %s %s" % (self._target_arg, command_string)
logger.SilentLog("about to run %s" % adb_cmd)
@@ -327,32 +327,30 @@
Raises:
WaitForResponseTimedOutError if package manager does not respond
+ AbortError if unrecoverable error occurred
"""
- output = self.SendCommand("sync", retry_count=retry_count)
+ output = ""
+ error = None
+ try:
+ output = self.SendCommand("sync", retry_count=retry_count)
+ except errors.AbortError, e:
+ error = e
+ output = e.msg
if "Read-only file system" in output:
logger.SilentLog(output)
logger.Log("Remounting read-only filesystem")
self.SendCommand("remount")
output = self.SendCommand("sync", retry_count=retry_count)
- if "No space left on device" in output:
+ elif "No space left on device" in output:
logger.SilentLog(output)
logger.Log("Restarting device runtime")
self.SendShellCommand("stop", retry_count=retry_count)
output = self.SendCommand("sync", retry_count=retry_count)
self.SendShellCommand("start", retry_count=retry_count)
-
+ elif error is not None:
+ # exception occurred that cannot be recovered from
+ raise error
logger.SilentLog(output)
self.WaitForDevicePm()
return output
-
- def IsDevicePresent(self):
- """Check if targeted device is present.
- Returns:
- True if device is present, False otherwise.
- """
- output = self.SendShellCommand("ls", retry_count=0)
- if output.startswith("error:"):
- return False
- else:
- return True
diff --git a/testrunner/errors.py b/testrunner/errors.py
index 6d606ec..e240899 100755
--- a/testrunner/errors.py
+++ b/testrunner/errors.py
@@ -34,6 +34,9 @@
"""Generic exception that indicates a fatal error has occurred and program
execution should be aborted."""
+ def __init__(self, msg="AbortError"):
+ self.msg = msg
+
class ParseError(Exception):
"""Raised when xml data to parse has unrecognized format."""
diff --git a/testrunner/run_command.py b/testrunner/run_command.py
index 4449945..a98a943 100755
--- a/testrunner/run_command.py
+++ b/testrunner/run_command.py
@@ -58,10 +58,11 @@
start_time = time.time()
so = []
pid = []
- global _abort_on_error
+ global _abort_on_error, error_occurred
error_occurred = False
def Run():
+ global error_occurred
if return_output:
output_dest = subprocess.PIPE
else:
@@ -83,8 +84,8 @@
logger.Log(e)
so.append("ERROR")
error_occurred = True
- if pipe.returncode < 0:
- logger.SilentLog("Error: %s was terminated by signal %d" %(cmd,
+ if pipe.returncode != 0:
+ logger.SilentLog("Error: %s returned %d error code" %(cmd,
pipe.returncode))
error_occurred = True
@@ -111,9 +112,9 @@
time.sleep(0.1)
t.join()
-
+ output = "".join(so)
if _abort_on_error and error_occurred:
- raise errors.AbortError
+ raise errors.AbortError(msg=output)
return "".join(so)
diff --git a/testrunner/runtest.py b/testrunner/runtest.py
index fe6dfad..fde67ad 100755
--- a/testrunner/runtest.py
+++ b/testrunner/runtest.py
@@ -95,6 +95,10 @@
help="Restrict test to a specific class")
parser.add_option("-m", "--test-method", dest="test_method",
help="Restrict test to a specific method")
+ parser.add_option("-p", "--test-package", dest="test_package",
+ help="Restrict test to a specific java package")
+ parser.add_option("-z", "--size", dest="test_size",
+ help="Restrict test to a specific test size")
parser.add_option("-u", "--user-tests-file", dest="user_tests_file",
metavar="FILE", default=user_test_default,
help="Alternate source of user test definitions")
@@ -252,6 +256,10 @@
instrumentation_args = {}
if test_class is not None:
instrumentation_args["class"] = test_class
+ if self._options.test_package:
+ instrumentation_args["package"] = self._options.test_package
+ if self._options.test_size:
+ instrumentation_args["size"] = self._options.test_size
if self._options.wait_for_debugger:
instrumentation_args["debug"] = "true"
if self._options.suite_assign_mode:
@@ -386,10 +394,6 @@
self._DumpTests()
return
- if not self._adb.IsDevicePresent():
- logger.Log("Error: specified device cannot be found")
- return
-
if not self._options.skip_build:
self._DoBuild()
@@ -400,7 +404,8 @@
self._RunTest(test_suite)
except KeyboardInterrupt:
logger.Log("Exiting...")
- except errors.AbortError:
+ except errors.AbortError, e:
+ logger.Log(e.msg)
logger.SilentLog("Exiting due to AbortError...")
except errors.WaitForResponseTimedOutError:
logger.Log("Timed out waiting for response")
diff --git a/testrunner/test_defs.xml b/testrunner/test_defs.xml
index 8508b34..1565945 100644
--- a/testrunner/test_defs.xml
+++ b/testrunner/test_defs.xml
@@ -100,6 +100,12 @@
coverage_target="framework"
continuous="true" />
+<test name="account"
+ build_path="frameworks/base/tests/AndroidTests"
+ package="com.android.unit_tests"
+ class="com.android.unit_tests.accounts.AccountManagerServiceTest"
+ coverage_target="framework" />
+
<test name="smoke"
build_path="frameworks/base/tests/SmokeTest"
package="com.android.smoketest.tests"