aboutsummaryrefslogtreecommitdiffstats
path: root/test/tools/llvm-cov
diff options
context:
space:
mode:
authorStephen Hines <srhines@google.com>2014-12-01 14:51:49 -0800
committerStephen Hines <srhines@google.com>2014-12-02 16:08:10 -0800
commit37ed9c199ca639565f6ce88105f9e39e898d82d0 (patch)
tree8fb36d3910e3ee4c4e1b7422f4f017108efc52f5 /test/tools/llvm-cov
parentd2327b22152ced7bc46dc629fc908959e8a52d03 (diff)
downloadexternal_llvm-37ed9c199ca639565f6ce88105f9e39e898d82d0.zip
external_llvm-37ed9c199ca639565f6ce88105f9e39e898d82d0.tar.gz
external_llvm-37ed9c199ca639565f6ce88105f9e39e898d82d0.tar.bz2
Update aosp/master LLVM for rebase to r222494.
Change-Id: Ic787f5e0124df789bd26f3f24680f45e678eef2d
Diffstat (limited to 'test/tools/llvm-cov')
-rw-r--r--test/tools/llvm-cov/Inputs/README22
-rw-r--r--test/tools/llvm-cov/Inputs/highlightedRanges.covmappingbin0 -> 355 bytes
-rw-r--r--test/tools/llvm-cov/Inputs/highlightedRanges.profdatabin0 -> 848 bytes
-rw-r--r--test/tools/llvm-cov/Inputs/lineExecutionCounts.covmappingbin0 -> 162 bytes
-rw-r--r--test/tools/llvm-cov/Inputs/lineExecutionCounts.profdatabin0 -> 656 bytes
-rw-r--r--test/tools/llvm-cov/Inputs/regionMarkers.covmappingbin0 -> 194 bytes
-rw-r--r--test/tools/llvm-cov/Inputs/regionMarkers.profdatabin0 -> 656 bytes
-rw-r--r--test/tools/llvm-cov/Inputs/report.covmappingbin0 -> 256 bytes
-rw-r--r--test/tools/llvm-cov/Inputs/report.profdatabin0 -> 800 bytes
-rw-r--r--test/tools/llvm-cov/Inputs/showExpansions.covmappingbin0 -> 194 bytes
-rw-r--r--test/tools/llvm-cov/Inputs/showExpansions.profdatabin0 -> 672 bytes
-rw-r--r--test/tools/llvm-cov/Inputs/templateInstantiations.covmappingbin0 -> 244 bytes
-rw-r--r--test/tools/llvm-cov/Inputs/templateInstantiations.profdatabin0 -> 768 bytes
-rw-r--r--test/tools/llvm-cov/lit.local.cfg4
-rw-r--r--test/tools/llvm-cov/report.cpp24
-rw-r--r--test/tools/llvm-cov/showExpansions.cpp29
-rw-r--r--test/tools/llvm-cov/showHighlightedRanges.cpp48
-rw-r--r--test/tools/llvm-cov/showLineExecutionCounts.cpp30
-rw-r--r--test/tools/llvm-cov/showRegionMarkers.cpp26
-rw-r--r--test/tools/llvm-cov/showTemplateInstantiations.cpp43
20 files changed, 222 insertions, 4 deletions
diff --git a/test/tools/llvm-cov/Inputs/README b/test/tools/llvm-cov/Inputs/README
index 2cfb191..3773ba3 100644
--- a/test/tools/llvm-cov/Inputs/README
+++ b/test/tools/llvm-cov/Inputs/README
@@ -1,7 +1,21 @@
These inputs were pre-generated to allow for easier testing of llvm-cov.
-test.gcno and test.gcda were create by running clang:
- clang++ -g -ftest-coverage -fprofile-arcs test.cpp
+The files used to test the gcov compatible code coverage tool were generated
+using the following method:
-test.cpp.gcov was created by running gcov 4.2.1:
- gcov test.cpp
+ test.gcno and test.gcda were create by running clang:
+ clang++ -g -ftest-coverage -fprofile-arcs test.cpp
+
+ test.cpp.gcov was created by running gcov 4.2.1:
+ gcov test.cpp
+
+The 'covmapping' files that are used to test llvm-cov contain raw sections
+with the coverage mapping data generated by the compiler and linker. They are
+created by running clang and llvm-cov:
+ clang++ -fprofile-instr-generate -fcoverage-mapping -o test test.cpp
+ llvm-cov convert-for-testing -o test.covmapping test
+
+The 'profdata' files were generated by running an instrumented version of the
+program and merging the raw profile data using llvm-profdata.
+ ./test
+ llvm-profdata merge -o test.profdata default.profraw
diff --git a/test/tools/llvm-cov/Inputs/highlightedRanges.covmapping b/test/tools/llvm-cov/Inputs/highlightedRanges.covmapping
new file mode 100644
index 0000000..20eb0d7
--- /dev/null
+++ b/test/tools/llvm-cov/Inputs/highlightedRanges.covmapping
Binary files differ
diff --git a/test/tools/llvm-cov/Inputs/highlightedRanges.profdata b/test/tools/llvm-cov/Inputs/highlightedRanges.profdata
new file mode 100644
index 0000000..b465b00
--- /dev/null
+++ b/test/tools/llvm-cov/Inputs/highlightedRanges.profdata
Binary files differ
diff --git a/test/tools/llvm-cov/Inputs/lineExecutionCounts.covmapping b/test/tools/llvm-cov/Inputs/lineExecutionCounts.covmapping
new file mode 100644
index 0000000..9774b89
--- /dev/null
+++ b/test/tools/llvm-cov/Inputs/lineExecutionCounts.covmapping
Binary files differ
diff --git a/test/tools/llvm-cov/Inputs/lineExecutionCounts.profdata b/test/tools/llvm-cov/Inputs/lineExecutionCounts.profdata
new file mode 100644
index 0000000..8712227
--- /dev/null
+++ b/test/tools/llvm-cov/Inputs/lineExecutionCounts.profdata
Binary files differ
diff --git a/test/tools/llvm-cov/Inputs/regionMarkers.covmapping b/test/tools/llvm-cov/Inputs/regionMarkers.covmapping
new file mode 100644
index 0000000..3ebcb07
--- /dev/null
+++ b/test/tools/llvm-cov/Inputs/regionMarkers.covmapping
Binary files differ
diff --git a/test/tools/llvm-cov/Inputs/regionMarkers.profdata b/test/tools/llvm-cov/Inputs/regionMarkers.profdata
new file mode 100644
index 0000000..8712227
--- /dev/null
+++ b/test/tools/llvm-cov/Inputs/regionMarkers.profdata
Binary files differ
diff --git a/test/tools/llvm-cov/Inputs/report.covmapping b/test/tools/llvm-cov/Inputs/report.covmapping
new file mode 100644
index 0000000..32d84bc
--- /dev/null
+++ b/test/tools/llvm-cov/Inputs/report.covmapping
Binary files differ
diff --git a/test/tools/llvm-cov/Inputs/report.profdata b/test/tools/llvm-cov/Inputs/report.profdata
new file mode 100644
index 0000000..aa47be0
--- /dev/null
+++ b/test/tools/llvm-cov/Inputs/report.profdata
Binary files differ
diff --git a/test/tools/llvm-cov/Inputs/showExpansions.covmapping b/test/tools/llvm-cov/Inputs/showExpansions.covmapping
new file mode 100644
index 0000000..b8c7d97
--- /dev/null
+++ b/test/tools/llvm-cov/Inputs/showExpansions.covmapping
Binary files differ
diff --git a/test/tools/llvm-cov/Inputs/showExpansions.profdata b/test/tools/llvm-cov/Inputs/showExpansions.profdata
new file mode 100644
index 0000000..7925c60
--- /dev/null
+++ b/test/tools/llvm-cov/Inputs/showExpansions.profdata
Binary files differ
diff --git a/test/tools/llvm-cov/Inputs/templateInstantiations.covmapping b/test/tools/llvm-cov/Inputs/templateInstantiations.covmapping
new file mode 100644
index 0000000..d243736
--- /dev/null
+++ b/test/tools/llvm-cov/Inputs/templateInstantiations.covmapping
Binary files differ
diff --git a/test/tools/llvm-cov/Inputs/templateInstantiations.profdata b/test/tools/llvm-cov/Inputs/templateInstantiations.profdata
new file mode 100644
index 0000000..6ccf526
--- /dev/null
+++ b/test/tools/llvm-cov/Inputs/templateInstantiations.profdata
Binary files differ
diff --git a/test/tools/llvm-cov/lit.local.cfg b/test/tools/llvm-cov/lit.local.cfg
index 56c6f1f..650bc02 100644
--- a/test/tools/llvm-cov/lit.local.cfg
+++ b/test/tools/llvm-cov/lit.local.cfg
@@ -1 +1,5 @@
config.suffixes = ['.test', '.m', '.cpp']
+
+# http://llvm.org/bugs/show_bug.cgi?id=20979
+if 'ubsan' in config.available_features:
+ config.unsupported = True
diff --git a/test/tools/llvm-cov/report.cpp b/test/tools/llvm-cov/report.cpp
new file mode 100644
index 0000000..297322a
--- /dev/null
+++ b/test/tools/llvm-cov/report.cpp
@@ -0,0 +1,24 @@
+// RUN: llvm-cov report %S/Inputs/report.covmapping -instr-profile %S/Inputs/report.profdata -no-colors 2>&1 | FileCheck %s
+
+// CHECK: Filename Regions Miss Cover Functions Executed
+// CHECK: TOTAL 5 2 60.00% 4 75.00%
+
+void foo(bool cond) {
+ if (cond) {
+ }
+}
+
+void bar() {
+}
+
+void func() {
+}
+
+int main() {
+ foo(false);
+ bar();
+ return 0;
+}
+
+// llvm-cov doesn't work on big endian yet
+// XFAIL: powerpc64-, s390x, mips-, mips64-, sparc
diff --git a/test/tools/llvm-cov/showExpansions.cpp b/test/tools/llvm-cov/showExpansions.cpp
new file mode 100644
index 0000000..30edd90
--- /dev/null
+++ b/test/tools/llvm-cov/showExpansions.cpp
@@ -0,0 +1,29 @@
+// RUN: llvm-cov show %S/Inputs/showExpansions.covmapping -instr-profile %S/Inputs/showExpansions.profdata -dump -show-expansions -filename-equivalence %s 2>&1 | FileCheck %s
+
+#define DO_SOMETHING_ELSE() \
+ do { \
+ } while (0)
+#define ANOTHER_THING() \
+ do { \
+ if (0) { \
+ } \
+ } while (0)
+
+#define DO_SOMETHING(x) \
+ do { \
+ if (x) \
+ DO_SOMETHING_ELSE(); \
+ else \
+ ANOTHER_THING(); \
+ } while (0)
+// CHECK-DAG: Expansion at line [[@LINE-4]], 7 -> 24
+// CHECK-DAG: Expansion at line [[@LINE-3]], 7 -> 20
+
+int main(int argc, const char *argv[]) {
+ for (int i = 0; i < 100; ++i)
+ DO_SOMETHING(i); // CHECK-DAG: Expansion at line [[@LINE]], 5 -> 17
+ return 0;
+}
+
+// llvm-cov doesn't work on big endian yet
+// XFAIL: powerpc64-, s390x, mips-, mips64-, sparc
diff --git a/test/tools/llvm-cov/showHighlightedRanges.cpp b/test/tools/llvm-cov/showHighlightedRanges.cpp
new file mode 100644
index 0000000..cec7308
--- /dev/null
+++ b/test/tools/llvm-cov/showHighlightedRanges.cpp
@@ -0,0 +1,48 @@
+// RUN: llvm-cov show %S/Inputs/highlightedRanges.covmapping -instr-profile %S/Inputs/highlightedRanges.profdata -dump -filename-equivalence %s 2>&1 | FileCheck %s
+
+void func() {
+ return;
+ int i = 0; // CHECK: Highlighted line [[@LINE]], 3 -> 12
+}
+
+void func2(int x) {
+ if(x > 5) {
+ while(x >= 9) {
+ return;
+ --x; // CHECK: Highlighted line [[@LINE]], 7 -> 10
+ }
+ int i = 0; // CHECK: Highlighted line [[@LINE]], 5 -> 14
+ }
+}
+
+void test() {
+ int x = 0;
+
+ if (x) { // CHECK: Highlighted line [[@LINE]], 10 -> ?
+ x = 0; // CHECK: Highlighted line [[@LINE]], 1 -> ?
+ } else { // CHECK: Highlighted line [[@LINE]], 1 -> 4
+ x = 1;
+ }
+
+ // CHECK: Highlighted line [[@LINE+1]], 26 -> 29
+ for (int i = 0; i < 0; ++i) { // CHECK: Highlighted line [[@LINE]], 31 -> ?
+ x = 1; // CHECK: Highlighted line [[@LINE]], 1 -> ?
+ } // CHECK: Highlighted line [[@LINE]], 1 -> 4
+
+ x = x < 10 ? x +
+ 1
+ : x - 1; // CHECK: Highlighted line [[@LINE]], 16 -> 21
+ x = x > 10 ? x + // CHECK: Highlighted line [[@LINE]], 16 -> ?
+ 1 // CHECK: Highlighted line [[@LINE]], 1 -> 17
+ : x - 1;
+}
+
+int main() {
+ test();
+ func();
+ func2(9);
+ return 0;
+}
+
+// llvm-cov doesn't work on big endian yet
+// XFAIL: powerpc64-, s390x, mips-, mips64-, sparc
diff --git a/test/tools/llvm-cov/showLineExecutionCounts.cpp b/test/tools/llvm-cov/showLineExecutionCounts.cpp
new file mode 100644
index 0000000..34baa57
--- /dev/null
+++ b/test/tools/llvm-cov/showLineExecutionCounts.cpp
@@ -0,0 +1,30 @@
+// RUN: llvm-cov show %S/Inputs/lineExecutionCounts.covmapping -instr-profile %S/Inputs/lineExecutionCounts.profdata -no-colors -filename-equivalence %s | FileCheck -check-prefix=CHECK -check-prefix=WHOLE-FILE %s
+// RUN: llvm-cov show %S/Inputs/lineExecutionCounts.covmapping -instr-profile %S/Inputs/lineExecutionCounts.profdata -no-colors -filename-equivalence -name=main %s | FileCheck -check-prefix=CHECK -check-prefix=FILTER %s
+
+// before any coverage // WHOLE-FILE: | [[@LINE]]|// before
+ // FILTER-NOT: | [[@LINE-1]]|// before
+int main() { // CHECK: 1| [[@LINE]]|int main(
+ int x = 0; // CHECK: 1| [[@LINE]]| int x
+ // CHECK: 1| [[@LINE]]|
+ if (x) { // CHECK: 0| [[@LINE]]| if (x)
+ x = 0; // CHECK: 0| [[@LINE]]| x = 0
+ } else { // CHECK: 1| [[@LINE]]| } else
+ x = 1; // CHECK: 1| [[@LINE]]| x = 1
+ } // CHECK: 1| [[@LINE]]| }
+ // CHECK: 1| [[@LINE]]|
+ for (int i = 0; i < 100; ++i) { // CHECK: 100| [[@LINE]]| for (
+ x = 1; // CHECK: 100| [[@LINE]]| x = 1
+ } // CHECK: 100| [[@LINE]]| }
+ // CHECK: 1| [[@LINE]]|
+ x = x < 10 ? x + 1 : x - 1; // CHECK: 0| [[@LINE]]| x =
+ x = x > 10 ? // CHECK: 1| [[@LINE]]| x =
+ x - 1: // CHECK: 0| [[@LINE]]| x
+ x + 1; // CHECK: 1| [[@LINE]]| x
+ // CHECK: 1| [[@LINE]]|
+ return 0; // CHECK: 1| [[@LINE]]| return
+} // CHECK: 1| [[@LINE]]|}
+// after coverage // WHOLE-FILE: | [[@LINE]]|// after
+ // FILTER-NOT: | [[@LINE-1]]|// after
+
+// llvm-cov doesn't work on big endian yet
+// XFAIL: powerpc64-, s390x, mips-, mips64-, sparc
diff --git a/test/tools/llvm-cov/showRegionMarkers.cpp b/test/tools/llvm-cov/showRegionMarkers.cpp
new file mode 100644
index 0000000..136c3bf
--- /dev/null
+++ b/test/tools/llvm-cov/showRegionMarkers.cpp
@@ -0,0 +1,26 @@
+// RUN: llvm-cov show %S/Inputs/regionMarkers.covmapping -instr-profile %S/Inputs/regionMarkers.profdata -show-regions -dump -filename-equivalence %s 2>&1 | FileCheck %s
+
+int main() { // CHECK: Marker at [[@LINE]]:12 = 1
+ int x = 0;
+
+ if (x) { // CHECK: Marker at [[@LINE]]:10 = 0
+ x = 0;
+ } else { // CHECK: Marker at [[@LINE]]:10 = 1
+ x = 1;
+ }
+ // CHECK: Marker at [[@LINE+2]]:19 = 101
+ // CHECK: Marker at [[@LINE+1]]:28 = 100
+ for (int i = 0; i < 100; ++i) { // CHECK: Marker at [[@LINE]]:33 = 100
+ x = 1;
+ }
+ // CHECK: Marker at [[@LINE+1]]:16 = 1
+ x = x < 10 ? x + 1 : x - 1; // CHECK: Marker at [[@LINE]]:24 = 0
+ x = x > 10 ?
+ x - 1: // CHECK: Marker at [[@LINE]]:9 = 0
+ x + 1; // CHECK: Marker at [[@LINE]]:9 = 1
+
+ return 0;
+}
+
+// llvm-cov doesn't work on big endian yet
+// XFAIL: powerpc64-, s390x, mips-, mips64-, sparc
diff --git a/test/tools/llvm-cov/showTemplateInstantiations.cpp b/test/tools/llvm-cov/showTemplateInstantiations.cpp
new file mode 100644
index 0000000..2b72d83
--- /dev/null
+++ b/test/tools/llvm-cov/showTemplateInstantiations.cpp
@@ -0,0 +1,43 @@
+// RUN: llvm-cov show %S/Inputs/templateInstantiations.covmapping -instr-profile %S/Inputs/templateInstantiations.profdata -no-colors -filename-equivalence %s | FileCheck -check-prefix=CHECK -check-prefix=ALL %s
+// RUN: llvm-cov show %S/Inputs/templateInstantiations.covmapping -instr-profile %S/Inputs/templateInstantiations.profdata -no-colors -filename-equivalence -name=_Z4funcIbEiT_ %s | FileCheck -check-prefix=CHECK -check-prefix=FILTER %s
+
+// before coverage // WHOLE-FILE: | [[@LINE]]|// before
+ // FILTER-NOT: | [[@LINE-1]]|// before
+template<typename T> // ALL: | [[@LINE]]|template<typename T>
+int func(T x) { // ALL-NEXT: 2| [[@LINE]]|int func(T x) {
+ if(x) // ALL-NEXT: 2| [[@LINE]]| if(x)
+ return 0; // ALL-NEXT: 1| [[@LINE]]| return 0;
+ else // ALL-NEXT: 1| [[@LINE]]| else
+ return 1; // ALL-NEXT: 1| [[@LINE]]| return 1;
+ int j = 1; // ALL-NEXT: 0| [[@LINE]]| int j = 1;
+} // ALL-NEXT: 1| [[@LINE]]|}
+
+ // CHECK: {{^ *(\| )?}}_Z4funcIbEiT_:
+ // CHECK-NEXT: 1| [[@LINE-9]]|int func(T x) {
+ // CHECK-NEXT: 1| [[@LINE-9]]| if(x)
+ // CHECK-NEXT: 1| [[@LINE-9]]| return 0;
+ // CHECK-NEXT: 1| [[@LINE-9]]| else
+ // CHECK-NEXT: 0| [[@LINE-9]]| return 1;
+ // CHECK-NEXT: 0| [[@LINE-9]]| int j = 1;
+ // CHECK-NEXT: 1| [[@LINE-9]]|}
+
+ // ALL: {{^ *}}| _Z4funcIiEiT_:
+ // FILTER-NOT: {{^ *(\| )?}} _Z4funcIiEiT_:
+ // ALL-NEXT: 1| [[@LINE-19]]|int func(T x) {
+ // ALL-NEXT: 1| [[@LINE-19]]| if(x)
+ // ALL-NEXT: 0| [[@LINE-19]]| return 0;
+ // ALL-NEXT: 1| [[@LINE-19]]| else
+ // ALL-NEXT: 1| [[@LINE-19]]| return 1;
+ // ALL-NEXT: 0| [[@LINE-19]]| int j = 1;
+ // ALL-NEXT: 1| [[@LINE-19]]|}
+
+int main() { // ALL: 1| [[@LINE]]|int main() {
+ func<int>(0); // ALL-NEXT: 1| [[@LINE]]| func<int>(0);
+ func<bool>(true); // ALL-NEXT: 1| [[@LINE]]| func<bool>(true);
+ return 0; // ALL-NEXT: 1| [[@LINE]]| return 0;
+} // ALL-NEXT: 1| [[@LINE]]|}
+// after coverage // ALL-NEXT: | [[@LINE]]|// after
+ // FILTER-NOT: | [[@LINE-1]]|// after
+
+// llvm-cov doesn't work on big endian yet
+// XFAIL: powerpc64-, s390x, mips-, mips64-, sparc