Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(29)

Side by Side Diff: tools/llvm_coverage_run.py

Issue 2353483003: Delete unused coverage recipe code. (Closed)
Patch Set: tools/ too Created 4 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « tools/llvm_coverage_build ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 #!/usr/bin/env python
2 # Copyright (c) 2015 The Chromium Authors. All rights reserved.
3 # Use of this source code is governed by a BSD-style license that can be
4 # found in the LICENSE file.
5
6
7 """Run the given command through LLVM's coverage tools."""
8
9
10 import argparse
11 import os
12 import subprocess
13
14
15 BUILDTYPE = 'Coverage'
16 PROFILE_DATA = 'default.profraw'
17 PROFILE_DATA_MERGED = 'prof_merged'
18 SKIA_OUT = 'SKIA_OUT'
19
20
21 def _get_out_dir():
22 """Determine the location for compiled binaries."""
23 return os.path.join(os.environ.get(SKIA_OUT, os.path.realpath('out')),
24 BUILDTYPE)
25
26
27 def run_coverage(cmd):
28 """Run the given command and return per-file coverage data.
29
30 Assumes that the binary has been built using llvm_coverage_build and that
31 LLVM 3.6 or newer is installed.
32 """
33 binary_path = os.path.join(_get_out_dir(), cmd[0])
34 subprocess.call([binary_path] + cmd[1:])
35 try:
36 subprocess.check_call(
37 ['llvm-profdata', 'merge', PROFILE_DATA,
38 '-output=%s' % PROFILE_DATA_MERGED])
39 finally:
40 os.remove(PROFILE_DATA)
41 try:
42 return subprocess.check_output(['llvm-cov', 'show', '-no-colors',
43 '-instr-profile', PROFILE_DATA_MERGED,
44 binary_path])
45 finally:
46 os.remove(PROFILE_DATA_MERGED)
47
48
49 def main():
50 """Run coverage and generate a report."""
51 # Parse args.
52 parser = argparse.ArgumentParser()
53 parser.add_argument('--outResultsFile')
54 args, cmd = parser.parse_known_args()
55
56 # Run coverage.
57 report = run_coverage(cmd)
58 with open(args.outResultsFile, 'w') as f:
59 f.write(report)
60
61
62 if __name__ == '__main__':
63 main()
OLDNEW
« no previous file with comments | « tools/llvm_coverage_build ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698