code coverage improvement
* automatically detect if emma is on device
* build emma into libcore if necessary
* stop runtime before adb sync and restart afterwards
Change-Id: I6f1beacdd266310c481351165a054dca8f8657b2
diff --git a/testrunner/runtest.py b/testrunner/runtest.py
index 8975303..6b03c79 100755
--- a/testrunner/runtest.py
+++ b/testrunner/runtest.py
@@ -157,7 +157,6 @@
group.add_option("-s", "--serial", dest="serial",
help="use specific serial")
parser.add_option_group(group)
-
self._options, self._test_args = parser.parse_args()
if (not self._options.only_list_tests
@@ -231,9 +230,23 @@
for test_suite in tests:
self._AddBuildTarget(test_suite, target_set, extra_args_set)
+ rebuild_libcore = False
if target_set:
if self._options.coverage:
coverage.EnableCoverageBuild()
+ # hack to remove core library intermediates
+ # hack is needed because:
+ # 1. EMMA_INSTRUMENT changes what source files to include in libcore
+ # but it does not trigger a rebuild
+ # 2. there's no target (like "clear-intermediates") to remove the files
+ # decently
+ rebuild_libcore = not coverage.TestDeviceCoverageSupport(self._adb)
+ if rebuild_libcore:
+ cmd = "rm -rf %s" % os.path.join(
+ self._root_path,
+ "out/target/common/obj/JAVA_LIBRARIES/core_intermediates/")
+ logger.Log(cmd)
+ run_command.RunCommand(cmd, return_output=False)
target_build_string = ' '.join(list(target_set))
extra_args_string = ' '.join(list(extra_args_set))
@@ -249,9 +262,11 @@
# run
logger.Log("adb sync")
else:
- run_command.RunCommand(cmd, return_output=False)
+ # set timeout for build to 10 minutes, since libcore may need to
+ # be rebuilt
+ run_command.RunCommand(cmd, return_output=False, timeout_time=600)
logger.Log("Syncing to device...")
- self._adb.Sync()
+ self._adb.Sync(runtime_restart=rebuild_libcore)
def _DoFullBuild(self, tests):
"""If necessary, run a full 'make' command for the tests that need it."""