This is an archive of the discontinued LLVM Phabricator instance.

[llvm-cov] Add an option for "export" command to emit only file summary data.
ClosedPublic

Authored by Dor1s on Dec 11 2017, 12:42 PM.

Details

Summary

That allows to get the same data as produced by "llvm-cov report",
but in JSON format, which is better for further processing by end users.

Event Timeline

Dor1s created this revision.Dec 11 2017, 12:42 PM
Dor1s updated this revision to Diff 126424.Dec 11 2017, 12:45 PM

Minor changes for the doc text and code comments

Vedant, please take a look at this little change when you'll have a few minutes :) This change would simplify code coverage integration on OSS-Fuzz and Chromium side.

vsk accepted this revision.Dec 11 2017, 12:51 PM

Thanks Max! Lgtm with a basic test, e.g;

diff --git a/test/tools/llvm-cov/showLineExecutionCounts.cpp b/test/tools/llvm-cov/showLineExecutionCounts.cpp
index c4b76824aac..f4b0424cee4 100644
--- a/test/tools/llvm-cov/showLineExecutionCounts.cpp
+++ b/test/tools/llvm-cov/showLineExecutionCounts.cpp
@@ -39,6 +39,9 @@ int main() {                              // TEXT: [[@LINE]]|   161|int main(
 // RUN: FileCheck -input-file %t.export.json %S/Inputs/lineExecutionCounts.json
 // RUN: cat %t.export.json | %python -c "import json, sys; json.loads(sys.stdin.read())"
 //
+// RUN: llvm-cov export %S/Inputs/lineExecutionCounts.covmapping -instr-profile %t.profdata 2>/dev/null -summary-only > %t.export-summary.json
+// RUN: not grep '"name":"main"' %t.export-summary.json
+//
 // Test html output.
 // RUN: llvm-cov show %S/Inputs/lineExecutionCounts.covmapping -format html -o %t.html.dir -instr-profile %t.profdata -path-equivalence=/tmp,%S %s
 // RUN: llvm-cov show %S/Inputs/lineExecutionCounts.covmapping -format html -o %t.html.filtered.dir -instr-profile %t.profdata -path-equivalence=/tmp,%S -name=main %s
This revision is now accepted and ready to land.Dec 11 2017, 12:51 PM
Dor1s updated this revision to Diff 126459.Dec 11 2017, 3:17 PM

Adding the test

Dor1s added a comment.Dec 11 2017, 3:18 PM

Thanks Vedant for the super fast review and for the tests suggestion!

Dor1s closed this revision.Dec 11 2017, 3:18 PM
vsk added inline comments.Dec 11 2017, 3:36 PM
test/tools/llvm-cov/showLineExecutionCounts.cpp
74

This test case was a mess... I've simplified it in r320439, sorry for the trouble.

Dor1s added inline comments.Dec 12 2017, 7:34 AM
test/tools/llvm-cov/showLineExecutionCounts.cpp
74

Cool, thanks Vedant!