summaryrefslogtreecommitdiff
path: root/test/profile/Linux/coverage_test.cpp
diff options
context:
space:
mode:
authorDimitry Andric <dim@FreeBSD.org>2016-07-23 20:45:36 +0000
committerDimitry Andric <dim@FreeBSD.org>2016-07-23 20:45:36 +0000
commit6f08730ec5f639f05f2f15354171e4a3c9af9dc1 (patch)
tree7374e9d4448083010ada98d17976199c7e945d47 /test/profile/Linux/coverage_test.cpp
parentc003a57e2e4a1ad9be0338806bc1038b6987155f (diff)
Notes
Diffstat (limited to 'test/profile/Linux/coverage_test.cpp')
-rw-r--r--test/profile/Linux/coverage_test.cpp35
1 files changed, 35 insertions, 0 deletions
diff --git a/test/profile/Linux/coverage_test.cpp b/test/profile/Linux/coverage_test.cpp
new file mode 100644
index 0000000000000..9b4ba073cf0a6
--- /dev/null
+++ b/test/profile/Linux/coverage_test.cpp
@@ -0,0 +1,35 @@
+// RUN: %clang_profgen -fuse-ld=gold -O2 -fdata-sections -ffunction-sections -fcoverage-mapping -Wl,--gc-sections -o %t %s
+// RUN: env LLVM_PROFILE_FILE=%t.profraw %run %t
+// RUN: llvm-profdata merge -o %t.profdata %t.profraw
+// RUN: llvm-cov show %t -instr-profile %t.profdata -filename-equivalence 2>&1 | FileCheck %s
+// BFD linker older than 2.26 has a bug that per-func profile data will be wrongly garbage collected when GC is turned on. We only do end-to-end test here without GC:
+// RUN: %clang_profgen -O2 -fcoverage-mapping -o %t.2 %s
+// RUN: env LLVM_PROFILE_FILE=%t.2.profraw %run %t.2
+// RUN: llvm-profdata merge -o %t.2.profdata %t.2.profraw
+// RUN: llvm-cov show %t.2 -instr-profile %t.2.profdata -filename-equivalence 2>&1 | FileCheck %s
+// Check covmap is not garbage collected when GC is turned on with BFD linker. Due to the bug mentioned above, we can only
+// do the check with objdump:
+// RUN: %clang_profgen -O2 -fcoverage-mapping -Wl,--gc-sections -o %t.3 %s
+// RUN: llvm-objdump -h %t.3 | FileCheck --check-prefix COVMAP %s
+// Check PIE option
+// RUN: %clang_profgen -fuse-ld=gold -O2 -fdata-sections -ffunction-sections -fPIE -pie -fcoverage-mapping -Wl,--gc-sections -o %t.pie %s
+// RUN: env LLVM_PROFILE_FILE=%t.pie.profraw %run %t.pie
+// RUN: llvm-profdata merge -o %t.pie.profdata %t.pie.profraw
+// RUN: llvm-cov show %t.pie -instr-profile %t.pie.profdata -filename-equivalence 2>&1 | FileCheck %s
+
+void foo(bool cond) { // CHECK: 1| [[@LINE]]|void foo(
+ if (cond) { // CHECK: 1| [[@LINE]]| if (cond) {
+ } // CHECK: 0| [[@LINE]]| }
+} // CHECK: 1| [[@LINE]]|}
+void bar() { // CHECK: 1| [[@LINE]]|void bar() {
+} // CHECK: 1| [[@LINE]]|}
+void func() { // CHECK: 0| [[@LINE]]|void func(
+} // CHECK: 0| [[@LINE]]|}
+int main() { // CHECK: 1| [[@LINE]]|int main(
+ foo(false); // CHECK: 1| [[@LINE]]| foo(
+ bar(); // CHECK: 1| [[@LINE]]| bar(
+ return 0; // CHECK: 1| [[@LINE]]| return
+} // CHECK: 1| [[@LINE]]|}
+
+// COVMAP: __llvm_covmap {{.*}}
+