Runtest support for tests that need 'make' not 'mmm' to build.
Change-Id: I0508db2578826249f9bf4756d5adc6f95e841231
diff --git a/testrunner/runtest.py b/testrunner/runtest.py
index d53312f..8975303 100755
--- a/testrunner/runtest.py
+++ b/testrunner/runtest.py
@@ -222,9 +222,12 @@
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 @@
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 @@
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: