From 84dc971ee2bc444a41d01051dba5b83d103ad952 Mon Sep 17 00:00:00 2001 From: Ying Yi Date: Wed, 24 Aug 2016 14:27:23 +0000 Subject: [llvm-cov] Add the project summary to each source file coverage report. This patch includes the following changes: - Included header "Code coverage report" and include the date that the report was created. - Included title (as specified in a command line option, (i.e llvm-cov -project-title="Simple Test") - In the summary, list the elf files that the source code file has contributed to. - Used column heading for "Line No.", "Count No.", Source". Differential Revision: https://reviews.llvm.org/D23345 llvm-svn: 279628 --- .../llvm-cov/Inputs/showProjectSummary.covmapping | Bin 0 -> 144 bytes .../llvm-cov/Inputs/showProjectSummary.proftext | 10 +++++ llvm/test/tools/llvm-cov/showProjectSummary.cpp | 46 +++++++++++++++++++++ .../tools/llvm-cov/showTemplateInstantiations.cpp | 8 ++-- 4 files changed, 60 insertions(+), 4 deletions(-) create mode 100644 llvm/test/tools/llvm-cov/Inputs/showProjectSummary.covmapping create mode 100644 llvm/test/tools/llvm-cov/Inputs/showProjectSummary.proftext create mode 100644 llvm/test/tools/llvm-cov/showProjectSummary.cpp (limited to 'llvm/test') diff --git a/llvm/test/tools/llvm-cov/Inputs/showProjectSummary.covmapping b/llvm/test/tools/llvm-cov/Inputs/showProjectSummary.covmapping new file mode 100644 index 00000000000..d95caf27f2b Binary files /dev/null and b/llvm/test/tools/llvm-cov/Inputs/showProjectSummary.covmapping differ diff --git a/llvm/test/tools/llvm-cov/Inputs/showProjectSummary.proftext b/llvm/test/tools/llvm-cov/Inputs/showProjectSummary.proftext new file mode 100644 index 00000000000..b3cdcc72565 --- /dev/null +++ b/llvm/test/tools/llvm-cov/Inputs/showProjectSummary.proftext @@ -0,0 +1,10 @@ +main +# Func Hash: +266 +# Num Counters: +3 +# Counter Values: +1 +20 +0 + diff --git a/llvm/test/tools/llvm-cov/showProjectSummary.cpp b/llvm/test/tools/llvm-cov/showProjectSummary.cpp new file mode 100644 index 00000000000..bfe4c0d19c7 --- /dev/null +++ b/llvm/test/tools/llvm-cov/showProjectSummary.cpp @@ -0,0 +1,46 @@ +// RUN: llvm-profdata merge -o %t.profdata %S/Inputs/showProjectSummary.proftext + +int main(int argc, char ** argv) { + int x=0; + for (int i = 0; i < 20; ++i) + x *= 2; + if (x >= 100) + x = x / 2; + else + x = x * 2; + return x; +} + +// Test console output. +// RUN: llvm-cov show %S/Inputs/showProjectSummary.covmapping -instr-profile %t.profdata -filename-equivalence %s | FileCheck -check-prefixes=TEXT,TEXT-FILE,TEXT-HEADER %s +// RUN: llvm-cov show %S/Inputs/showProjectSummary.covmapping -instr-profile %t.profdata -project-title "Test Suite" -filename-equivalence %s | FileCheck -check-prefixes=TEXT-TITLE,TEXT,TEXT-FILE,TEXT-HEADER %s +// RUN: llvm-cov show %S/Inputs/showProjectSummary.covmapping -instr-profile %t.profdata -project-title "Test Suite" -name=main -filename-equivalence %s | FileCheck -check-prefixes=TEXT-FUNCTION,TEXT-HEADER %s +// TEXT-TITLE: Test Suite +// TEXT: Code Coverage Report +// TEXT: Created: +// TEXT-FILE: showProjectSummary.cpp: +// TEXT-FILE: showProjectSummary.covmapping: +// TEXT-FUNCTION: main: + +// Test html output. +// RUN: llvm-cov show %S/Inputs/showProjectSummary.covmapping -format=html -o %t.dir -instr-profile %t.profdata -filename-equivalence %s +// RUN: FileCheck -check-prefixes=HTML,HTML-FILE,HTML-HEADER -input-file %t.dir/coverage/tmp/showProjectSummary.cpp.html %s +// RUN: llvm-cov show %S/Inputs/showProjectSummary.covmapping -format=html -o %t.dir -instr-profile %t.profdata -project-title "Test Suite" -filename-equivalence %s +// RUN: FileCheck -check-prefixes=HTML-TITLE,HTML,HTML-FILE,HTML-HEADER -input-file %t.dir/coverage/tmp/showProjectSummary.cpp.html %s +// RUN: FileCheck -check-prefixes=HTML-TITLE,HTML -input-file %t.dir/index.html %s +// RUN: llvm-cov show %S/Inputs/showProjectSummary.covmapping -format=html -o %t.dir -instr-profile %t.profdata -project-title "Test Suite" -filename-equivalence -name=main %s +// RUN: FileCheck -check-prefixes=HTML-FUNCTION,HTML-HEADER -input-file %t.dir/functions.html %s +// HTML-TITLE:
+// HTML-TITLE: Test Suite +// HTML:
+// HTML: Code Coverage Report +// HTML:
+// HTML: Created: +// HTML-FILE:
Source:
+// HTML-FILE: showProjectSummary.cpp
+// HTML-FILE:
Binary:
+// HTML-FILE: showProjectSummary.covmapping
+// HTML-FUNCTION:
Function: main
+// HTML-HEADER:
Line No.
+// HTML-HEADER:
Count No.
+// HTML-HEADER:
Source
diff --git a/llvm/test/tools/llvm-cov/showTemplateInstantiations.cpp b/llvm/test/tools/llvm-cov/showTemplateInstantiations.cpp index 198ebd3b199..5a656db9809 100644 --- a/llvm/test/tools/llvm-cov/showTemplateInstantiations.cpp +++ b/llvm/test/tools/llvm-cov/showTemplateInstantiations.cpp @@ -13,7 +13,7 @@ int func(T x) { // ALL-NEXT: [[@LINE]]| 2|int func(T x) { } // ALL-NEXT: [[@LINE]]| 2|} // SHARED: {{^ *(\| )?}}_Z4funcIbEiT_: - // SHARED-NEXT: [[@LINE-9]]| 1|int func(T x) { + // SHARED: [[@LINE-9]]| 1|int func(T x) { // SHARED-NEXT: [[@LINE-9]]| 1| if(x) // SHARED-NEXT: [[@LINE-9]]| 1| return 0; // SHARED-NEXT: [[@LINE-9]]| 1| else @@ -23,7 +23,7 @@ int func(T x) { // ALL-NEXT: [[@LINE]]| 2|int func(T x) { // ALL: {{^ *}}| _Z4funcIiEiT_: // FILTER-NOT: {{^ *(\| )?}} _Z4funcIiEiT_: - // ALL-NEXT: [[@LINE-19]]| 1|int func(T x) { + // ALL: [[@LINE-19]]| 1|int func(T x) { // ALL-NEXT: [[@LINE-19]]| 1| if(x) // ALL-NEXT: [[@LINE-19]]| 0| return 0; // ALL-NEXT: [[@LINE-19]]| 1| else @@ -56,7 +56,7 @@ int main() { // ALL: [[@LINE]]| 1|int main() { // HTML-ALL:
[[@LINE-44]]
0
 // HTML-ALL: 
[[@LINE-44]]
2
}
 
-// HTML-SHARED: 
_Z4funcIbEiT_
+// HTML-SHARED:
Function: _Z4funcIbEiT_
// HTML-SHARED:
[[@LINE-53]]
1
int func(T x) {
 // HTML-SHARED: 
[[@LINE-53]]
1
  if(x)
 // HTML-SHARED: 
[[@LINE-53]]
1
    ret
@@ -65,7 +65,7 @@ int main() {         // ALL:         [[@LINE]]| 1|int main() {
 // HTML-SHARED: 
[[@LINE-53]]
0
 // HTML-SHARED: 
[[@LINE-53]]
1
}
 
-// HTML-ALL: 
_Z4funcIiEiT_
+// HTML-ALL:
Function: _Z4funcIiEiT_
// HTML-FILTER-NOT:
_Z4funcIiEiT_
// HTML-ALL:
[[@LINE-63]]
1
int func(T x) {
 // HTML-ALL: 
[[@LINE-63]]
1
  if(x)
-- 
cgit v1.2.3