runtest: introduce --user parameter

Currently runtest script installs and then runs test apks with default
"adb install" and "adb shell am instrument" behavior.  They are actually
different,  "adb install" uses USER_ALL, "am instrument" uses
USER_CURRENT.  This cl introduces a way to specify exactly which user a
test should run with in a multiple user environment.  This also provides
a work around for b/22976637 for now.

Bug: 19913735
Bug: 22976637
Change-Id: I65e2b2c79768734a8bc9261f8c4693c9f89016b1
This commit is contained in:
Xiaohui Chen
2015-08-20 09:45:48 -07:00
parent 6984d17aa7
commit 85586e0e03
3 changed files with 29 additions and 13 deletions

View File

@@ -172,6 +172,11 @@ class TestRunner(object):
parser.add_option("--suite", dest="suite",
help="Run all tests defined as part of the "
"the given test suite")
parser.add_option("--user", dest="user",
help="The user that test apks are installing to."
" This is the integer user id, e.g. 0 or 10."
" If no user is specified, apk will be installed with"
" adb's default behavior, which is currently all users.")
group = optparse.OptionGroup(
parser, "Targets", "Use these options to direct tests to a specific "
"Android target")
@@ -338,6 +343,8 @@ class TestRunner(object):
extra_flags = ""
if test_requires_permissions and not self._options.skip_permissions:
extra_flags = "-g"
if self._options.user:
extra_flags += " --user " + self._options.user
logger.Log("adb install -r %s %s" % (extra_flags, abs_install_path))
logger.Log(self._adb.Install(abs_install_path, extra_flags))
else: