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
This commit is contained in:
Guang Zhu
2010-04-15 10:48:26 -07:00
parent 5a076f43d5
commit 8aff3602e7
4 changed files with 88 additions and 33 deletions

View File

@@ -62,28 +62,6 @@ class CoverageGenerator(object):
self._adb = adb_interface
self._targets_manifest = self._ReadTargets()
def TestDeviceCoverageSupport(self):
"""Check if device has support for generating code coverage metrics.
Currently this will check if the emma.jar file is on the device's boot
classpath.
Returns:
True if device can support code coverage. False otherwise.
"""
try:
output = self._adb.SendShellCommand("cat init.rc | grep BOOTCLASSPATH | "
"grep emma.jar")
if len(output) > 0:
return True
except errors.AbortError:
pass
logger.Log("Error: Targeted device does not have emma.jar on its "
"BOOTCLASSPATH.")
logger.Log("Modify the BOOTCLASSPATH entry in system/core/rootdir/init.rc"
" to add emma.jar")
return False
def ExtractReport(self, test_suite,
device_coverage_path,
output_path=None,
@@ -311,6 +289,25 @@ def EnableCoverageBuild():
os.environ["EMMA_INSTRUMENT"] = "true"
def TestDeviceCoverageSupport(adb):
"""Check if device has support for generating code coverage metrics.
This tries to dump emma help information on device, a response containing
help information will indicate that emma is already on system class path.
Returns:
True if device can support code coverage. False otherwise.
"""
try:
output = adb.SendShellCommand("exec app_process / emma -h")
if output.find('emma usage:') == 0:
return True
except errors.AbortError:
pass
return False
def Run():
"""Does coverage operations based on command line args."""
# TODO: do we want to support combining coverage for a single target