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

View File

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

View File

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

View File

@@ -109,13 +109,9 @@ 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 GetTestsInSuite(self, suite):
"""Return list of tests in given suite."""
return [t for t in self.GetTests() if t.GetSuite() == suite]
def GetTest(self, name):
return self._testname_map.get(name, None)

View File

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

View File

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

View File

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