Skip to content

Commit

Permalink
Use -compilation-dir for llvm-cov
Browse files Browse the repository at this point in the history
https://reviews.llvm.org/D100232

coverage builds now have relative paths to source code from the build
directory, so llvm-cov is failing to find the source code.
`-compilation-dir` is now available to specify the build directory
for the relative paths.

Bug: 1216203, 1204920
Change-Id: I79bfd6461c315fa9dc555c0829854e612685f122
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2950169
Reviewed-by: Yuke Liao <liaoyuke@chromium.org>
Commit-Queue: Yuke Liao <liaoyuke@chromium.org>
Cr-Commit-Position: refs/heads/master@{#891281}
  • Loading branch information
tunz authored and Chromium LUCI CQ committed Jun 10, 2021
1 parent d7a44c0 commit 5675252
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 1 deletion.
1 change: 1 addition & 0 deletions docs/testing/code_coverage.md
Original file line number Diff line number Diff line change
Expand Up @@ -231,6 +231,7 @@ code coverage report:
```
$ llvm-cov show -output-dir=out/report -format=html \
-instr-profile=out/report/coverage.profdata \
-compilation-dir=out/coverage \
-object=out/coverage/url_unittests \
out/coverage/crypto_unittests
```
Expand Down
2 changes: 2 additions & 0 deletions tools/code_coverage/coverage.py
Original file line number Diff line number Diff line change
Expand Up @@ -232,6 +232,7 @@ def _GeneratePerFileLineByLineCoverageInFormat(binary_paths, profdata_file_path,

subprocess_cmd = [
LLVM_COV_PATH, 'show', '-format={}'.format(output_format),
'-compilation-dir={}'.format(BUILD_DIR),
'-output-dir={}'.format(OUTPUT_DIR),
'-instr-profile={}'.format(profdata_file_path), binary_paths[0]
]
Expand Down Expand Up @@ -617,6 +618,7 @@ def _GeneratePerFileCoverageSummary(binary_paths, profdata_file_path, filters,
logging.error("Binary %s does not exist", path)
subprocess_cmd = [
LLVM_COV_PATH, 'export', '-summary-only',
'-compilation-dir={}'.format(BUILD_DIR),
'-instr-profile=' + profdata_file_path, binary_paths[0]
]
subprocess_cmd.extend(
Expand Down
2 changes: 1 addition & 1 deletion tools/code_coverage/coverage_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -462,7 +462,7 @@ def GeneratePerFileCoverageSummary(self):

per_file_coverage_summary = {}
for file_coverage_data in files_coverage_data:
file_path = file_coverage_data['filename']
file_path = os.path.normpath(file_coverage_data['filename'])
assert file_path.startswith(self.src_root_dir), (
'File path "%s" in coverage summary is outside source checkout.' %
file_path)
Expand Down

0 comments on commit 5675252

Please sign in to comment.