summaryrefslogtreecommitdiffstats
path: root/tools/code_coverage
diff options
context:
space:
mode:
authormaruel@chromium.org <maruel@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-03-05 12:46:38 +0000
committermaruel@chromium.org <maruel@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-03-05 12:46:38 +0000
commitf0a51fb571f46531025fa09240bbc3e1af925e84 (patch)
tree558b4f0e737fda4b9ab60f252c9c23b8a4ca523e /tools/code_coverage
parent6390be368205705f49ead3cec40396519f13b889 (diff)
downloadchromium_src-f0a51fb571f46531025fa09240bbc3e1af925e84.zip
chromium_src-f0a51fb571f46531025fa09240bbc3e1af925e84.tar.gz
chromium_src-f0a51fb571f46531025fa09240bbc3e1af925e84.tar.bz2
Fixes CRLF and trailing white spaces.
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@10982 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'tools/code_coverage')
-rw-r--r--tools/code_coverage/coverage.py70
-rw-r--r--tools/code_coverage/process_coverage.py24
2 files changed, 47 insertions, 47 deletions
diff --git a/tools/code_coverage/coverage.py b/tools/code_coverage/coverage.py
index c28c03d..976fb86 100644
--- a/tools/code_coverage/coverage.py
+++ b/tools/code_coverage/coverage.py
@@ -6,12 +6,12 @@
"""Module to setup and generate code coverage data
-This module first sets up the environment for code coverage, instruments the
+This module first sets up the environment for code coverage, instruments the
binaries, runs the tests and collects the code coverage data.
Usage:
- coverage.py --upload=<upload_location>
+ coverage.py --upload=<upload_location>
--revision=<revision_number>
--src_root=<root_of_source_tree>
[--tools_path=<tools_path>]
@@ -50,13 +50,13 @@ windows_binaries = [#'chrome.exe',
'test_shell_tests.exe',
'test_shell.exe',
'activex_test_control.dll']
-
-# The list of [tests, args] that will be run.
+
+# The list of [tests, args] that will be run.
# Failing tests have been commented out.
# TODO(niranjan): Need to add layout tests that excercise the test shell.
windows_tests = [
['unit_tests.exe', ''],
-# ['automated_ui_tests.exe', ''],
+# ['automated_ui_tests.exe', ''],
['ui_tests.exe', '--no-sandbox'],
['installer_unittests.exe', ''],
['ipc_tests.exe', ''],
@@ -78,7 +78,7 @@ def IsWindows():
class Coverage(object):
"""Class to set up and generate code coverage.
- This class contains methods that are useful to set up the environment for
+ This class contains methods that are useful to set up the environment for
code coverage.
Attributes:
@@ -86,7 +86,7 @@ class Coverage(object):
instrumented.
"""
- def __init__(self,
+ def __init__(self,
revision,
src_path = None,
tools_path = None,
@@ -106,13 +106,13 @@ class Coverage(object):
self.src_path = src_path
self._dir = tempfile.mkdtemp()
self._archive = archive
-
-
+
+
def SetUp(self, binaries):
"""Set up the platform specific environment and instrument the binaries for
coverage.
- This method sets up the environment, instruments all the compiled binaries
+ This method sets up the environment, instruments all the compiled binaries
and sets up the code coverage counters.
Args:
@@ -127,7 +127,7 @@ class Coverage(object):
return False
if IsWindows():
# Stop all previous instance of VSPerfMon counters
- counters_command = ('%s -shutdown' %
+ counters_command = ('%s -shutdown' %
(os.path.join(self.tools_path, 'vsperfcmd.exe')))
(retcode, output) = proc.RunCommandFull(counters_command,
collect_output=True)
@@ -156,20 +156,20 @@ class Coverage(object):
# We are now ready to run tests and measure code coverage.
self.instrumented = True
return True
-
+
def TearDown(self):
"""Tear down method.
This method shuts down the counters, and cleans up all the intermediate
- artifacts.
+ artifacts.
"""
if self.instrumented == False:
return
-
+
if IsWindows():
# Stop counters
- counters_command = ('%s -shutdown' %
+ counters_command = ('%s -shutdown' %
(os.path.join(self.tools_path, 'vsperfcmd.exe')))
(retcode, output) = proc.RunCommandFull(counters_command,
collect_output=True)
@@ -187,12 +187,12 @@ class Coverage(object):
logging.info('Cleaned up temporary files and folders')
# Reset the instrumented flag.
self.instrumented = False
-
+
def RunTest(self, src_root, test):
"""Run tests and collect the .coverage file
- Args:
+ Args:
src_root: Path to the root of the source.
test: Path to the test to be run.
@@ -203,13 +203,13 @@ class Coverage(object):
# Generate the intermediate file name for the coverage results
test_name = os.path.split(test[0])[1].strip('.exe')
# test_command = binary + args
- test_command = '%s %s' % (os.path.join(src_root,
+ test_command = '%s %s' % (os.path.join(src_root,
'chrome',
'Release',
- test[0]),
+ test[0]),
test[1])
-
- coverage_file = os.path.join(self._dir, '%s_win32_%s.coverage' %
+
+ coverage_file = os.path.join(self._dir, '%s_win32_%s.coverage' %
(test_name, self.revision))
logging.info('.coverage file for test %s: %s' % (test_name, coverage_file))
@@ -221,16 +221,16 @@ class Coverage(object):
# VSPerfCmd spawns another process before terminating and this confuses
# the subprocess.Popen() used by RunCommandFull.
retcode = subprocess.call(counters_command)
-
+
# Run the test binary
logging.info('Executing test %s: ' % test_command)
(retcode, output) = proc.RunCommandFull(test_command, collect_output=True)
if retcode != 0: # Return error if the tests fail
logging.error('One or more tests failed in %s.' % test_command)
return None
-
+
# Stop the counters
- counters_command = ('%s -shutdown' %
+ counters_command = ('%s -shutdown' %
(os.path.join(self.tools_path, 'vsperfcmd.exe')))
(retcode, output) = proc.RunCommandFull(counters_command,
collect_output=True)
@@ -238,7 +238,7 @@ class Coverage(object):
# Return the intermediate .coverage file
return coverage_file
-
+
def Upload(self, list_coverage, upload_path, sym_path=None, src_root=None):
"""Upload the results to the dashboard.
@@ -251,7 +251,7 @@ class Coverage(object):
upload_path: Destination where the coverage data will be processed.
sym_path: Symbol path for the build (Win32 only)
src_root: Root folder of the source tree (Win32 only)
-
+
Returns:
True on success.
False on failure.
@@ -259,15 +259,15 @@ class Coverage(object):
if upload_path == None:
logging.info('Upload path not specified. Will not convert to LCOV')
return True
-
+
if IsWindows():
# Stop counters
- counters_command = ('%s -shutdown' %
+ counters_command = ('%s -shutdown' %
(os.path.join(self.tools_path, 'vsperfcmd.exe')))
(retcode, output) = proc.RunCommandFull(counters_command,
collect_output=True)
logging.info('Counters shut down: %s' % (output))
- lcov_file = os.path.join(upload_path, 'chrome_win32_%s.lcov' %
+ lcov_file = os.path.join(upload_path, 'chrome_win32_%s.lcov' %
(self.revision))
lcov = open(lcov_file, 'w')
for coverage_file in list_coverage:
@@ -276,8 +276,8 @@ class Coverage(object):
logging.error('Lcov converter tool not found')
return False
self.tools_path = self.tools_path.rstrip('\\')
- convert_command = ('%s -sym_path=%s -src_root=%s %s' %
- (os.path.join(self.tools_path,
+ convert_command = ('%s -sym_path=%s -src_root=%s %s' %
+ (os.path.join(self.tools_path,
'coverage_analyzer.exe'),
sym_path,
src_root,
@@ -333,12 +333,12 @@ def main():
help='Archive location of the intermediate .coverage data')
(options, args) = parser.parse_args()
-
+
if options.revision == None:
parser.error('Revision number not specified')
if options.src_root == None:
parser.error('Source root not specified')
-
+
if IsWindows():
# Initialize coverage
cov = Coverage(options.revision,
@@ -355,7 +355,7 @@ def main():
return 1
# Collect the intermediate file
list_coverage.append(coverage)
- else:
+ else:
logging.error('Error during instrumentation.')
sys.exit(1)
@@ -368,4 +368,4 @@ def main():
if __name__ == '__main__':
sys.exit(main())
-
+
diff --git a/tools/code_coverage/process_coverage.py b/tools/code_coverage/process_coverage.py
index e42e95b..a1f3c1e 100644
--- a/tools/code_coverage/process_coverage.py
+++ b/tools/code_coverage/process_coverage.py
@@ -54,7 +54,7 @@ win32_srcs_exclude = ['parse.y',
'cssgrammar.cpp',
'csspropertynames.gperf']
-# Number of lines of a new coverage data set
+# Number of lines of a new coverage data set
# to send at a time to the dashboard.
POST_CHUNK_SIZE = 50
@@ -190,7 +190,7 @@ def CleanWin32Lcov(lcov_path, src_root):
stderr=subprocess.STDOUT).communicate()[0]
if output.rfind('error:'):
return None
-
+
tmp_buf1 = output.split('=')
tmp_buf2 = tmp_buf1[len(tmp_buf1) - 2].split('x')[0].split(' ')
loc = tmp_buf2[len(tmp_buf2) - 2]
@@ -220,7 +220,7 @@ def ParseCoverageDataForDashboard(lcov_path):
Args:
lcov_path: File path to lcov coverage data.
-
+
Returns:
List of strings with comma separated source node and coverage.
"""
@@ -241,7 +241,7 @@ def ParseCoverageDataForDashboard(lcov_path):
instrumented_set = {}
executed_set = {}
srcfile_name = line[len('SF:'):]
-
+
# Mark coverage data points hashlist style for the current src file.
if line[:len('DA:')] == 'DA:':
line_info = line[len('DA:'):].split(',')
@@ -251,18 +251,18 @@ def ParseCoverageDataForDashboard(lcov_path):
# line_was_executed is '0' or '1'
if int(line_was_executed):
executed_set[line_num] = True
-
+
# Update results for the current src file at record end.
if line == 'end_of_record':
instrumented = len(instrumented_set.keys())
executed = len(executed_set.keys())
parent_directory = srcfile_name[:srcfile_name.rfind('/') + 1]
linecount_point = linecounts[srcfile_index].strip().split(',')
- assert(len(linecount_point) == 2,
+ assert(len(linecount_point) == 2,
'lintcount format unexpected - %s' % linecounts[srcfile_index])
(linecount_path, linecount_count) = linecount_point
srcfile_index += 1
-
+
# Sanity check that path names in the lcov and linecount are lined up.
if linecount_path[-10:] != srcfile_name[-10:]:
print 'NAME MISMATCH: %s :: %s' % (srcfile_name, linecount_path)
@@ -282,7 +282,7 @@ def ParseCoverageDataForDashboard(lcov_path):
# The first key (sorted) will be the base directory '/'
# but its full path may be '/mnt/chrome_src/src/'
# using this offset will ignore the part '/mnt/chrome_src/src'.
- # Offset is the last '/' that isn't the last character for the
+ # Offset is the last '/' that isn't the last character for the
# first directory name in results (position 1 in keys).
offset = len(keys[1][:keys[1][:-1].rfind('/')])
lines = []
@@ -299,7 +299,7 @@ def ParseCoverageDataForDashboard(lcov_path):
def AddResults(results, location, lines_total, lines_executed):
"""Add resulting line tallies to a location's total.
-
+
Args:
results: Map of node location to corresponding coverage data.
location: Source node string.
@@ -315,7 +315,7 @@ def AddResults(results, location, lines_total, lines_executed):
def PostResultsToDashboard(lcov_path, results, post_url):
"""Post coverage results to coverage dashboard.
-
+
Args:
lcov_path: File path for lcov data in the expected format:
<project>_<platform>_<cl#>.coverage.lcov
@@ -346,7 +346,7 @@ num_fails = 0
def SendPost(req):
"""Execute a post request and retry for up to MAX_FAILURES.
-
+
Args:
req: A urllib2 request object.
@@ -428,7 +428,7 @@ def main():
else:
print 'Unsupported platform'
os.exit(1)
-
+
# Prep coverage results for dashboard and post new set.
parsed_data = ParseCoverageDataForDashboard(options.lcov_path)
PostResultsToDashboard(options.lcov_path, parsed_data, options.post_url)