From 49b77117feb1d1a0efeae9498cf898a2e1e3ccfd Mon Sep 17 00:00:00 2001 From: Brett Chabot Date: Tue, 2 Jun 2009 11:46:04 -0700 Subject: [PATCH] Initial change to add cts tests to runtest. Adds cts test definitions to the testrunner/test_defs.xml. Adds support for runtest --cts arg, which will run all cts tests. This temporarily relies on the addition of a 'cts' attribute to the test definition - a new xml format may be defined later that changes how cts tests are identified. This change is based on previous unsubmitted CL https://android-git.corp.google.com/g/Gerrit#change,1702. The only delta wrt to that change is the use of InstrumentationCtsTestRunner. Update: rebased to latest donut. --- testrunner/errors.py | 2 +- testrunner/runtest.py | 16 +++- testrunner/test_defs.py | 18 +++++ testrunner/test_defs.xml | 158 +++++++++++++++++++++++++++++++++++++++ testrunner/test_defs.xsd | 1 + 5 files changed, 190 insertions(+), 5 deletions(-) diff --git a/testrunner/errors.py b/testrunner/errors.py index e24089918..c04fd012c 100755 --- a/testrunner/errors.py +++ b/testrunner/errors.py @@ -34,7 +34,7 @@ class AbortError(Exception): """Generic exception that indicates a fatal error has occurred and program execution should be aborted.""" - def __init__(self, msg="AbortError"): + def __init__(self, msg=""): self.msg = msg diff --git a/testrunner/runtest.py b/testrunner/runtest.py index 046eb7c31..e66b8def5 100755 --- a/testrunner/runtest.py +++ b/testrunner/runtest.py @@ -115,7 +115,10 @@ class TestRunner(object): parser.add_option("--timeout", dest="timeout", default=300, help="Set a timeout limit (in sec) for " "running native tests on a device (default: 300 secs)") - + parser.add_option("--cts", dest="cts_tests", + default=False, action="store_true", + help="Run all tests defined as part of the " + "compatibility test suite") group = optparse.OptionGroup( parser, "Targets", "Use these options to direct tests to a specific " "Android target") @@ -129,8 +132,11 @@ class TestRunner(object): self._options, self._test_args = parser.parse_args() - if (not self._options.only_list_tests and not self._options.all_tests - and not self._options.continuous_tests and len(self._test_args) < 1): + if (not self._options.only_list_tests + and not self._options.all_tests + and not self._options.continuous_tests + and not self._options.cts_tests + and len(self._test_args) < 1): parser.print_help() logger.SilentLog("at least one test name must be specified") raise errors.AbortError @@ -229,8 +235,10 @@ class TestRunner(object): """Get a list of TestSuite objects to run, based on command line args.""" if self._options.all_tests: return self._known_tests.GetTests() - if self._options.continuous_tests: + elif self._options.continuous_tests: return self._known_tests.GetContinuousTests() + elif self._options.cts_tests: + return self._known_tests.GetCtsTests() tests = [] for name in self._test_args: test = self._known_tests.GetTest(name) diff --git a/testrunner/test_defs.py b/testrunner/test_defs.py index 2cdcfa87c..0542a053d 100644 --- a/testrunner/test_defs.py +++ b/testrunner/test_defs.py @@ -144,6 +144,14 @@ class TestDefinitions(object): con_tests.append(test) return con_tests + def GetCtsTests(self): + """Return list of cts tests.""" + cts_tests = [] + for test in self.GetTests(): + if test.IsCts(): + cts_tests.append(test) + return cts_tests + def GetTest(self, name): return self._testname_map.get(name, None) @@ -157,6 +165,7 @@ class TestSuite(object): _TARGET_ATTR = "coverage_target" _BUILD_ATTR = "build_path" _CONTINUOUS_ATTR = "continuous" + _CTS_ATTR = "cts" _DESCRIPTION_ATTR = "description" _EXTRA_MAKE_ARGS_ATTR = "extra_make_args" @@ -199,6 +208,11 @@ class TestSuite(object): self._continuous = suite_element.getAttribute(self._CONTINUOUS_ATTR) else: self._continuous = False + if suite_element.hasAttribute(self._CTS_ATTR): + self._cts = suite_element.getAttribute(self._CTS_ATTR) + else: + self._cts = False + if suite_element.hasAttribute(self._DESCRIPTION_ATTR): self._description = suite_element.getAttribute(self._DESCRIPTION_ATTR) else: @@ -236,6 +250,10 @@ class TestSuite(object): """Returns true if test is flagged as being part of the continuous tests""" return self._continuous + def IsCts(self): + """Returns true if test is part of the compatibility test suite""" + return self._cts + def IsNative(self): """Returns true if test is a native one.""" return self._native diff --git a/testrunner/test_defs.xml b/testrunner/test_defs.xml index 4121f7b90..e1d9cc54c 100644 --- a/testrunner/test_defs.xml +++ b/testrunner/test_defs.xml @@ -42,6 +42,8 @@ JAVA/application tests: continuous: Optional boolean. Default is false. Set to true if tests are known to be reliable, and should be included in a continuous test system. false if they are under development. + cts: Optional boolean. Default is false. Set to true if test is included in + compatibility test suite. description: Optional string. Default is empty. Short description (typically less than 60 characters) about this test. @@ -166,6 +168,162 @@ Native tests: coverage_target="framework" continuous="true" /> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +