summaryrefslogtreecommitdiffstats
path: root/testrunner/test_defs
diff options
context:
space:
mode:
authorSantos Cordon <santoscordon@google.com>2015-05-21 12:25:05 -0700
committerSantos Cordon <santoscordon@google.com>2015-05-21 15:46:59 -0700
commit4e0ad8f8102fd2908ca34893b3acafaf518c4fac (patch)
treeefff8f055db26a5810cade25e0c70e48aaba840f /testrunner/test_defs
parent19b0ecb1201ada24ac780a404ca6a769e3ba3b9d (diff)
downloadandroid_development-4e0ad8f8102fd2908ca34893b3acafaf518c4fac.tar.gz
android_development-4e0ad8f8102fd2908ca34893b3acafaf518c4fac.tar.bz2
android_development-4e0ad8f8102fd2908ca34893b3acafaf518c4fac.zip
Add flag to grant permissions when running tests.
This change automatically adds -g to all adb install commands for runtest. It also allows users to: 1) Specify '-k' as a command line arg to avoid granting permissions. 2) Declare a test suite as 'requiring permissions' within test_defs Also fixes a potential bug where continuous="false" would translate to True in the python code. Bug: 21327566 Change-Id: I62d14e8106174861397b3fd8caa3e567e3538713
Diffstat (limited to 'testrunner/test_defs')
-rw-r--r--testrunner/test_defs/test_suite.py9
-rw-r--r--testrunner/test_defs/xml_suite_helper.py6
2 files changed, 15 insertions, 0 deletions
diff --git a/testrunner/test_defs/test_suite.py b/testrunner/test_defs/test_suite.py
index d0bd9eef7..5bd9a1972 100644
--- a/testrunner/test_defs/test_suite.py
+++ b/testrunner/test_defs/test_suite.py
@@ -33,6 +33,7 @@ class AbstractTestSuite(object):
self._description = ''
self._extra_build_args = ''
self._is_full_make = False
+ self._is_granted_permissions = True
def GetName(self):
return self._name
@@ -65,6 +66,14 @@ class AbstractTestSuite(object):
self._is_continuous = continuous
return self._is_continuous
+ def IsGrantedPermissions(self):
+ """Return true if the test should be granted runtime permissions on install."""
+ return self._is_granted_permissions
+
+ def SetIsGrantedPermissions(self, is_granted_permissions):
+ self._is_granted_permissions = is_granted_permissions
+ return self._is_granted_permissions
+
def GetSuite(self):
"""Returns the name of test' suite, or None."""
return self._suite
diff --git a/testrunner/test_defs/xml_suite_helper.py b/testrunner/test_defs/xml_suite_helper.py
index 6cf2e6c8d..6805fcd27 100644
--- a/testrunner/test_defs/xml_suite_helper.py
+++ b/testrunner/test_defs/xml_suite_helper.py
@@ -40,6 +40,7 @@ class XmlSuiteParser(object):
_DESCRIPTION_ATTR = 'description'
_EXTRA_BUILD_ARGS_ATTR = 'extra_build_args'
_FULL_MAKE_ATTR = 'full_make'
+ _GRANTED_PERMISSIONS_ATTR = 'granted_permissions'
def Parse(self, element):
"""Populates common suite attributes from given suite xml element.
@@ -72,6 +73,9 @@ class XmlSuiteParser(object):
test_suite.SetContinuous(self._ParseAttribute(suite_element,
self._CONTINUOUS_ATTR,
False, default_value=False))
+ test_suite.SetIsGrantedPermissions(self._ParseAttribute(suite_element,
+ self._GRANTED_PERMISSIONS_ATTR,
+ False, default_value=True))
test_suite.SetSuite(self._ParseAttribute(suite_element, self._SUITE_ATTR, False,
default_value=None))
test_suite.SetDescription(self._ParseAttribute(suite_element,
@@ -88,6 +92,8 @@ class XmlSuiteParser(object):
default_value=None):
if suite_element.hasAttribute(attribute_name):
value = suite_element.getAttribute(attribute_name)
+ if default_value in (True, False):
+ value = value.lower() == "true"
elif mandatory:
error_msg = ('Could not find attribute %s in %s' %
(attribute_name, self.TAG_NAME))