Runtest support for tests that need 'make' not 'mmm' to build.

Change-Id: I0508db2578826249f9bf4756d5adc6f95e841231
This commit is contained in:
Brett Chabot
2010-04-15 15:43:04 -07:00
parent 90218acfdf
commit 8dc9eb8ba6
5 changed files with 63 additions and 23 deletions

View File

@@ -222,9 +222,12 @@ class TestRunner(object):
def _DoBuild(self):
logger.SilentLog("Building tests...")
tests = self._GetTestsToRun()
self._DoFullBuild(tests)
target_set = Set()
extra_args_set = Set()
tests = self._GetTestsToRun()
for test_suite in tests:
self._AddBuildTarget(test_suite, target_set, extra_args_set)
@@ -232,21 +235,8 @@ class TestRunner(object):
if self._options.coverage:
coverage.EnableCoverageBuild()
# hack to build cts dependencies
# TODO: remove this when build dependency support added to runtest or
# cts dependencies are removed
if self._IsCtsTests(tests):
# need to use make since these fail building with ONE_SHOT_MAKEFILE
cmd = ('make -j%s CtsTestStubs android.core.tests.runner' %
self._options.make_jobs)
logger.Log(cmd)
if not self._options.preview:
old_dir = os.getcwd()
os.chdir(self._root_path)
run_command.RunCommand(cmd, return_output=False)
os.chdir(old_dir)
target_build_string = " ".join(list(target_set))
extra_args_string = " ".join(list(extra_args_set))
target_build_string = ' '.join(list(target_set))
extra_args_string = ' '.join(list(extra_args_set))
# mmm cannot be used from python, so perform a similar operation using
# ONE_SHOT_MAKEFILE
cmd = 'ONE_SHOT_MAKEFILE="%s" make -j%s -C "%s" files %s' % (
@@ -263,12 +253,43 @@ class TestRunner(object):
logger.Log("Syncing to device...")
self._adb.Sync()
def _DoFullBuild(self, tests):
"""If necessary, run a full 'make' command for the tests that need it."""
extra_args_set = Set()
# hack to build cts dependencies
# TODO: remove this when cts dependencies are removed
if self._IsCtsTests(tests):
# need to use make since these fail building with ONE_SHOT_MAKEFILE
extra_args_set.add('CtsTestStubs')
extra_args_set.add('android.core.tests.runner')
for test in tests:
if test.IsFullMake():
if test.GetExtraBuildArgs():
# extra args contains the args to pass to 'make'
extra_args_set.add(test.GetExtraBuildArgs())
else:
logger.Log("Warning: test %s needs a full build but does not specify"
" extra_build_args" % test.GetName())
# check if there is actually any tests that required a full build
if extra_args_set:
cmd = ('make -j%s %s' % (self._options.make_jobs,
' '.join(list(extra_args_set))))
logger.Log(cmd)
if not self._options.preview:
old_dir = os.getcwd()
os.chdir(self._root_path)
run_command.RunCommand(cmd, return_output=False)
os.chdir(old_dir)
def _AddBuildTarget(self, test_suite, target_set, extra_args_set):
build_dir = test_suite.GetBuildPath()
if self._AddBuildTargetPath(build_dir, target_set):
extra_args_set.add(test_suite.GetExtraBuildArgs())
for path in test_suite.GetBuildDependencies(self._options):
self._AddBuildTargetPath(path, target_set)
if not test_suite.IsFullMake():
build_dir = test_suite.GetBuildPath()
if self._AddBuildTargetPath(build_dir, target_set):
extra_args_set.add(test_suite.GetExtraBuildArgs())
for path in test_suite.GetBuildDependencies(self._options):
self._AddBuildTargetPath(path, target_set)
def _AddBuildTargetPath(self, build_dir, target_set):
if build_dir is not None: