Replace runtest --cts option with more generic --suite option.

This will allow you to run a the set of test_defs with attribute suite="foo"
like this:
  runtest --suite foo

Bug 2401250
This commit is contained in:
Brett Chabot
2010-02-18 20:01:11 -08:00
parent 0459299ce3
commit 4a5d9f1ba7
7 changed files with 55 additions and 56 deletions

View File

@@ -138,10 +138,9 @@ class TestRunner(object):
parser.add_option("--timeout", dest="timeout", parser.add_option("--timeout", dest="timeout",
default=300, help="Set a timeout limit (in sec) for " default=300, help="Set a timeout limit (in sec) for "
"running native tests on a device (default: 300 secs)") "running native tests on a device (default: 300 secs)")
parser.add_option("--cts", dest="cts_tests", parser.add_option("--suite", dest="suite",
default=False, action="store_true",
help="Run all tests defined as part of the " help="Run all tests defined as part of the "
"compatibility test suite") "the given test suite")
group = optparse.OptionGroup( group = optparse.OptionGroup(
parser, "Targets", "Use these options to direct tests to a specific " parser, "Targets", "Use these options to direct tests to a specific "
"Android target") "Android target")
@@ -158,7 +157,7 @@ class TestRunner(object):
if (not self._options.only_list_tests if (not self._options.only_list_tests
and not self._options.all_tests and not self._options.all_tests
and not self._options.continuous_tests and not self._options.continuous_tests
and not self._options.cts_tests and not self._options.suite
and not self._options.test_path and not self._options.test_path
and len(self._test_args) < 1): and len(self._test_args) < 1):
parser.print_help() parser.print_help()
@@ -285,8 +284,9 @@ class TestRunner(object):
self._tests_to_run = self._known_tests.GetTests() self._tests_to_run = self._known_tests.GetTests()
elif self._options.continuous_tests: elif self._options.continuous_tests:
self._tests_to_run = self._known_tests.GetContinuousTests() self._tests_to_run = self._known_tests.GetContinuousTests()
elif self._options.cts_tests: elif self._options.suite:
self._tests_to_run = self._known_tests.GetCtsTests() self._tests_to_run = \
self._known_tests.GetTestsInSuite(self._options.suite)
elif self._options.test_path: elif self._options.test_path:
walker = test_walker.TestWalker() walker = test_walker.TestWalker()
self._tests_to_run = walker.FindTests(self._options.test_path) self._tests_to_run = walker.FindTests(self._options.test_path)
@@ -303,7 +303,7 @@ class TestRunner(object):
def _IsCtsTests(self, test_list): def _IsCtsTests(self, test_list):
"""Check if any cts tests are included in given list of tests to run.""" """Check if any cts tests are included in given list of tests to run."""
for test in test_list: for test in test_list:
if test.IsCts(): if test.GetSuite() == 'cts':
return True return True
return False return False

View File

@@ -187,7 +187,7 @@ See test_defs.xsd for more information.
runner="android.test.InstrumentationTestRunner" runner="android.test.InstrumentationTestRunner"
coverage_target="framework" coverage_target="framework"
continuous="true" continuous="true"
cts="true" /> suite="cts" />
<test name="cts-permission2" <test name="cts-permission2"
build_path="cts/tests/tests/permission2" build_path="cts/tests/tests/permission2"
@@ -201,173 +201,173 @@ See test_defs.xsd for more information.
build_path="cts/tests/tests/process" build_path="cts/tests/tests/process"
package="com.android.cts.process" package="com.android.cts.process"
coverage_target="framework" coverage_target="framework"
cts="true" /> suite="cts" />
<test name="cts-api-signature" <test name="cts-api-signature"
build_path="cts/tests/SignatureTest" build_path="cts/tests/SignatureTest"
package="android.tests.sigtest" package="android.tests.sigtest"
runner=".InstrumentationRunner" runner=".InstrumentationRunner"
cts="true" /> suite="cts" />
<test name="cts-api-signature-func" <test name="cts-api-signature-func"
build_path="cts/tests/SignatureTest" build_path="cts/tests/SignatureTest"
package="android.tests.sigtest.tests" package="android.tests.sigtest.tests"
cts="true" /> suite="cts" />
<test name="cts-apidemos" <test name="cts-apidemos"
build_path="cts/tests/ApiDemosReferenceTest" build_path="cts/tests/ApiDemosReferenceTest"
package="android.apidemos.cts" package="android.apidemos.cts"
coverage_target="ApiDemos" coverage_target="ApiDemos"
cts="true" /> suite="cts" />
<test name="cts-app" <test name="cts-app"
build_path="cts/tests/tests/app" build_path="cts/tests/tests/app"
package="com.android.cts.app" package="com.android.cts.app"
runner="android.test.InstrumentationCtsTestRunner" runner="android.test.InstrumentationCtsTestRunner"
coverage_target="framework" coverage_target="framework"
cts="true" /> suite="cts" />
<test name="cts-content" <test name="cts-content"
build_path="cts/tests/tests/content" build_path="cts/tests/tests/content"
package="com.android.cts.content" package="com.android.cts.content"
runner="android.test.InstrumentationTestRunner" runner="android.test.InstrumentationTestRunner"
coverage_target="framework" coverage_target="framework"
cts="true" /> suite="cts" />
<test name="cts-database" <test name="cts-database"
build_path="cts/tests/tests/database" build_path="cts/tests/tests/database"
package="com.android.cts.database" package="com.android.cts.database"
runner="android.test.InstrumentationCtsTestRunner" runner="android.test.InstrumentationCtsTestRunner"
coverage_target="framework" coverage_target="framework"
cts="true" /> suite="cts" />
<test name="cts-gesture" <test name="cts-gesture"
build_path="cts/tests/tests/gesture" build_path="cts/tests/tests/gesture"
package="com.android.cts.gesture" package="com.android.cts.gesture"
runner="android.test.InstrumentationTestRunner" runner="android.test.InstrumentationTestRunner"
coverage_target="framework" coverage_target="framework"
cts="true" /> suite="cts" />
<test name="cts-graphics" <test name="cts-graphics"
build_path="cts/tests/tests/graphics" build_path="cts/tests/tests/graphics"
package="com.android.cts.graphics" package="com.android.cts.graphics"
runner="android.test.InstrumentationCtsTestRunner" runner="android.test.InstrumentationCtsTestRunner"
coverage_target="framework" coverage_target="framework"
cts="true" /> suite="cts" />
<test name="cts-hardware" <test name="cts-hardware"
build_path="cts/tests/tests/hardware" build_path="cts/tests/tests/hardware"
package="com.android.cts.hardware" package="com.android.cts.hardware"
runner="android.test.InstrumentationCtsTestRunner" runner="android.test.InstrumentationCtsTestRunner"
coverage_target="framework" coverage_target="framework"
cts="true" /> suite="cts" />
<test name="cts-location" <test name="cts-location"
build_path="cts/tests/tests/location" build_path="cts/tests/tests/location"
package="com.android.cts.location" package="com.android.cts.location"
runner="android.test.InstrumentationCtsTestRunner" runner="android.test.InstrumentationCtsTestRunner"
coverage_target="framework" coverage_target="framework"
cts="true" /> suite="cts" />
<test name="cts-media" <test name="cts-media"
build_path="cts/tests/tests/media" build_path="cts/tests/tests/media"
package="com.android.cts.media" package="com.android.cts.media"
runner="android.test.InstrumentationCtsTestRunner" runner="android.test.InstrumentationCtsTestRunner"
coverage_target="framework" coverage_target="framework"
cts="true" /> suite="cts" />
<test name="cts-net" <test name="cts-net"
build_path="cts/tests/tests/net" build_path="cts/tests/tests/net"
package="com.android.cts.net" package="com.android.cts.net"
runner="android.test.InstrumentationCtsTestRunner" runner="android.test.InstrumentationCtsTestRunner"
coverage_target="framework" coverage_target="framework"
cts="true" /> suite="cts" />
<test name="cts-os" <test name="cts-os"
build_path="cts/tests/tests/os" build_path="cts/tests/tests/os"
package="com.android.cts.os" package="com.android.cts.os"
runner="android.test.InstrumentationCtsTestRunner" runner="android.test.InstrumentationCtsTestRunner"
coverage_target="framework" coverage_target="framework"
cts="true" /> suite="cts" />
<test name="cts-perf1" <test name="cts-perf1"
build_path="cts/tests/tests/performance" build_path="cts/tests/tests/performance"
package="com.android.cts.performance" package="com.android.cts.performance"
runner="android.test.InstrumentationCtsTestRunner" runner="android.test.InstrumentationCtsTestRunner"
cts="true" /> suite="cts" />
<test name="cts-perf2" <test name="cts-perf2"
build_path="cts/tests/tests/performance2" build_path="cts/tests/tests/performance2"
package="com.android.cts.performance2" package="com.android.cts.performance2"
runner="android.test.InstrumentationCtsTestRunner" runner="android.test.InstrumentationCtsTestRunner"
cts="true" /> suite="cts" />
<test name="cts-perf3" <test name="cts-perf3"
build_path="cts/tests/tests/performance3" build_path="cts/tests/tests/performance3"
package="com.android.cts.performance3" package="com.android.cts.performance3"
runner="android.test.InstrumentationCtsTestRunner" runner="android.test.InstrumentationCtsTestRunner"
cts="true" /> suite="cts" />
<test name="cts-perf4" <test name="cts-perf4"
build_path="cts/tests/tests/performance4" build_path="cts/tests/tests/performance4"
package="com.android.cts.performance4" package="com.android.cts.performance4"
runner="android.test.InstrumentationCtsTestRunner" runner="android.test.InstrumentationCtsTestRunner"
cts="true" /> suite="cts" />
<test name="cts-perf5" <test name="cts-perf5"
build_path="cts/tests/tests/performance5" build_path="cts/tests/tests/performance5"
package="com.android.cts.performance5" package="com.android.cts.performance5"
runner="android.test.InstrumentationCtsTestRunner" runner="android.test.InstrumentationCtsTestRunner"
cts="true" /> suite="cts" />
<test name="cts-provider" <test name="cts-provider"
build_path="cts/tests/tests/provider" build_path="cts/tests/tests/provider"
package="com.android.cts.provider" package="com.android.cts.provider"
runner="android.test.InstrumentationCtsTestRunner" runner="android.test.InstrumentationCtsTestRunner"
coverage_target="framework" coverage_target="framework"
cts="true" /> suite="cts" />
<test name="cts-text" <test name="cts-text"
build_path="cts/tests/tests/text" build_path="cts/tests/tests/text"
package="com.android.cts.text" package="com.android.cts.text"
runner="android.test.InstrumentationCtsTestRunner" runner="android.test.InstrumentationCtsTestRunner"
coverage_target="framework" coverage_target="framework"
cts="true" /> suite="cts" />
<test name="cts-telephony" <test name="cts-telephony"
build_path="cts/tests/tests/telephony" build_path="cts/tests/tests/telephony"
package="com.android.cts.telephony" package="com.android.cts.telephony"
runner="android.test.InstrumentationCtsTestRunner" runner="android.test.InstrumentationCtsTestRunner"
coverage_target="framework" coverage_target="framework"
cts="true" /> suite="cts" />
<test name="cts-util" <test name="cts-util"
build_path="cts/tests/tests/util" build_path="cts/tests/tests/util"
package="com.android.cts.util" package="com.android.cts.util"
runner="android.test.InstrumentationCtsTestRunner" runner="android.test.InstrumentationCtsTestRunner"
coverage_target="framework" coverage_target="framework"
cts="true" /> suite="cts" />
<test name="cts-view" <test name="cts-view"
build_path="cts/tests/tests/view" build_path="cts/tests/tests/view"
package="com.android.cts.view" package="com.android.cts.view"
runner="android.test.InstrumentationCtsTestRunner" runner="android.test.InstrumentationCtsTestRunner"
coverage_target="framework" coverage_target="framework"
cts="true" /> suite="cts" />
<test name="cts-webkit" <test name="cts-webkit"
build_path="cts/tests/tests/webkit" build_path="cts/tests/tests/webkit"
package="com.android.cts.webkit" package="com.android.cts.webkit"
runner="android.test.InstrumentationCtsTestRunner" runner="android.test.InstrumentationCtsTestRunner"
coverage_target="framework" coverage_target="framework"
cts="true" /> suite="cts" />
<test name="cts-widget" <test name="cts-widget"
build_path="cts/tests/tests/widget" build_path="cts/tests/tests/widget"
package="com.android.cts.widget" package="com.android.cts.widget"
runner="android.test.InstrumentationCtsTestRunner" runner="android.test.InstrumentationCtsTestRunner"
coverage_target="framework" coverage_target="framework"
cts="true" /> suite="cts" />
<!-- end of cts tests --> <!-- end of cts tests -->
@@ -573,7 +573,7 @@ See test_defs.xsd for more information.
build_path="cts/tests/appsecurity-tests" build_path="cts/tests/appsecurity-tests"
class="com.android.cts.appsecurity.AppSecurityTests" class="com.android.cts.appsecurity.AppSecurityTests"
jar_name="CtsAppSecurityTests.jar" jar_name="CtsAppSecurityTests.jar"
cts="true" /> suite="cts" />
<test-host name="frameworks-core-host" <test-host name="frameworks-core-host"
build_path="frameworks/base/core/tests/hosttests" build_path="frameworks/base/core/tests/hosttests"

View File

@@ -48,9 +48,8 @@
<xs:attribute name="continuous" type="xs:boolean" use="optional" <xs:attribute name="continuous" type="xs:boolean" use="optional"
default="false" /> default="false" />
<!-- Include test in compatibility test suite. --> <!-- Include test as part of named suite. -->
<xs:attribute name="cts" type="xs:boolean" use="optional" <xs:attribute name="suite" type="xs:string" use="optional" />
default="false" />
<!-- Short description (typically less than 60 characters) about this <!-- Short description (typically less than 60 characters) about this
test. --> test. -->

View File

@@ -109,13 +109,9 @@ class TestDefinitions(object):
con_tests.append(test) con_tests.append(test)
return con_tests return con_tests
def GetCtsTests(self): def GetTestsInSuite(self, suite):
"""Return list of cts tests.""" """Return list of tests in given suite."""
cts_tests = [] return [t for t in self.GetTests() if t.GetSuite() == suite]
for test in self.GetTests():
if test.IsCts():
cts_tests.append(test)
return cts_tests
def GetTest(self, name): def GetTest(self, name):
return self._testname_map.get(name, None) return self._testname_map.get(name, None)

View File

@@ -19,14 +19,17 @@
class AbstractTestSuite(object): class AbstractTestSuite(object):
"""Represents a generic test suite definition.""" """Represents a generic test suite definition.
TODO: rename this as AbstractTestDef.
"""
def __init__(self): def __init__(self):
self._name = None self._name = None
self._build_path = None self._build_path = None
self._build_dependencies = [] self._build_dependencies = []
self._is_continuous = False self._is_continuous = False
self._is_cts = False self._suite = None
self._description = '' self._description = ''
self._extra_build_args = '' self._extra_build_args = ''
@@ -61,12 +64,12 @@ class AbstractTestSuite(object):
self._is_continuous = continuous self._is_continuous = continuous
return self._is_continuous return self._is_continuous
def IsCts(self): def GetSuite(self):
"""Returns true if test is part of the compatibility test suite""" """Returns the name of test' suite, or None."""
return self._is_cts return self._suite
def SetCts(self, cts): def SetSuite(self, suite):
self._is_cts = cts self._suite = suite
return self return self
def GetDescription(self): def GetDescription(self):

View File

@@ -290,7 +290,8 @@ class TestWalker(object):
# package name, this is a cts test # package name, this is a cts test
# this logic can be removed altogether when cts tests no longer require # this logic can be removed altogether when cts tests no longer require
# custom build steps # custom build steps
suite.SetCts(suite.GetPackageName().startswith('com.android.cts')) if suite.GetPackageName().startswith('com.android.cts'):
suite.SetSuite('cts')
tests.append(suite) tests.append(suite)
return tests return tests

View File

@@ -36,7 +36,7 @@ class XmlSuiteParser(object):
_NAME_ATTR = 'name' _NAME_ATTR = 'name'
_BUILD_ATTR = 'build_path' _BUILD_ATTR = 'build_path'
_CONTINUOUS_ATTR = 'continuous' _CONTINUOUS_ATTR = 'continuous'
_CTS_ATTR = 'cts' _SUITE_ATTR = 'suite'
_DESCRIPTION_ATTR = 'description' _DESCRIPTION_ATTR = 'description'
_EXTRA_BUILD_ARGS_ATTR = 'extra_build_args' _EXTRA_BUILD_ARGS_ATTR = 'extra_build_args'
@@ -71,8 +71,8 @@ class XmlSuiteParser(object):
test_suite.SetContinuous(self._ParseAttribute(suite_element, test_suite.SetContinuous(self._ParseAttribute(suite_element,
self._CONTINUOUS_ATTR, self._CONTINUOUS_ATTR,
False, default_value=False)) False, default_value=False))
test_suite.SetCts(self._ParseAttribute(suite_element, self._CTS_ATTR, False, test_suite.SetSuite(self._ParseAttribute(suite_element, self._SUITE_ATTR, False,
default_value=False)) default_value=None))
test_suite.SetDescription(self._ParseAttribute(suite_element, test_suite.SetDescription(self._ParseAttribute(suite_element,
self._DESCRIPTION_ATTR, self._DESCRIPTION_ATTR,
False, False,