diff options
| author | Xinliang David Li <davidxl@google.com> | 2016-01-14 18:15:54 +0000 | 
|---|---|---|
| committer | Xinliang David Li <davidxl@google.com> | 2016-01-14 18:15:54 +0000 | 
| commit | 944cd4d3188d48eaf09fea97f23e5dbde58dd7b8 (patch) | |
| tree | 29d47fe9b5a596e9722d7acd793d19ba20125651 | |
| parent | 5f04f926e9ba769606034a685fe5df3af9dd6bb7 (diff) | |
| download | bcm5719-llvm-944cd4d3188d48eaf09fea97f23e5dbde58dd7b8.tar.gz bcm5719-llvm-944cd4d3188d48eaf09fea97f23e5dbde58dd7b8.zip  | |
[Coverage] add test cases for coverage testing
1. One test covering coverage-mapping interfaction with linker GC
2. one test covering coverage-mapping with shared libaries
llvm-svn: 257782
| -rw-r--r-- | compiler-rt/test/profile/Inputs/instrprof-dynamic-a.cpp | 10 | ||||
| -rw-r--r-- | compiler-rt/test/profile/Linux/coverage_shared.test | 16 | ||||
| -rw-r--r-- | compiler-rt/test/profile/Linux/coverage_test.cpp | 28 | 
3 files changed, 49 insertions, 5 deletions
diff --git a/compiler-rt/test/profile/Inputs/instrprof-dynamic-a.cpp b/compiler-rt/test/profile/Inputs/instrprof-dynamic-a.cpp index 2ec484a5b38..5faa9c2b2a8 100644 --- a/compiler-rt/test/profile/Inputs/instrprof-dynamic-a.cpp +++ b/compiler-rt/test/profile/Inputs/instrprof-dynamic-a.cpp @@ -1,7 +1,7 @@  #include "instrprof-dynamic-header.h" -void a() { -  if (true) { -    bar<void>(1); -    bar<char>(1); -  } +void a() {                             // COV: 1| [[@LINE]]|void a +  if (true) {                          // COV: 1| [[@LINE]]|  if +    bar<void>(1);                      // COV: 1| [[@LINE]]|    bar +    bar<char>(1);                      // COV: 1| [[@LINE]]|    bar +  }                                    // COV: 1| [[@LINE]]|  }  } diff --git a/compiler-rt/test/profile/Linux/coverage_shared.test b/compiler-rt/test/profile/Linux/coverage_shared.test new file mode 100644 index 00000000000..e2b0e3e1160 --- /dev/null +++ b/compiler-rt/test/profile/Linux/coverage_shared.test @@ -0,0 +1,16 @@ +RUN: mkdir -p %t.d +RUN: %clang_profgen -fdata-sections -ffunction-sections -fcoverage-mapping -c -o %t.d/a.shared.o -fPIC  %S/../Inputs/instrprof-dynamic-a.cpp +RUN: %clang_profgen -fdata-sections -ffunction-sections -fuse-ld=gold -Wl,--gc-sections -fcoverage-mapping -o %t.d/a.shared -fPIC -shared %S/../Inputs/instrprof-dynamic-a.cpp +RUN: %clang_profgen -fdata-sections -ffunction-sections -fuse-ld=gold -Wl,--gc-sections -o %t-shared -fPIC -rpath %t.d %t.d/a.shared %S/../Inputs/instrprof-dynamic-b.cpp %S/../Inputs/instrprof-dynamic-main.cpp + +RUN: %clang_profgen -fdata-sections -ffunction-sections -fuse-ld=gold -Wl,--gc-sections -o %t-static %t.d/a.shared.o %S/../Inputs/instrprof-dynamic-b.cpp %S/../Inputs/instrprof-dynamic-main.cpp + +RUN: env LLVM_PROFILE_FILE=%t-static.profraw %run %t-static +RUN: env LLVM_PROFILE_FILE=%t-shared.profraw %run %t-shared + +RUN: llvm-profdata merge -o %t-static.profdata %t-static.profraw +RUN: llvm-profdata merge -o %t-shared.profdata %t-shared.profraw + +RUN: llvm-cov show -instr-profile %t-shared.profdata %t.d/a.shared | FileCheck --check-prefix=COV %S/../Inputs/instrprof-dynamic-a.cpp +RUN: llvm-cov show -instr-profile %t-static.profdata %t-static | FileCheck --check-prefix=COV %S/../Inputs/instrprof-dynamic-a.cpp + diff --git a/compiler-rt/test/profile/Linux/coverage_test.cpp b/compiler-rt/test/profile/Linux/coverage_test.cpp new file mode 100644 index 00000000000..1443279419c --- /dev/null +++ b/compiler-rt/test/profile/Linux/coverage_test.cpp @@ -0,0 +1,28 @@ +// RUN: %clang_profgen -fuse-ld=gold -O2 -fdata-sections -ffunction-sections -fprofile-instr-generate -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 +// +// RUN: %clang_profgen -fuse-ld=gold -O2 -fdata-sections -ffunction-sections -fPIE -pie -fprofile-instr-generate -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]]|} + + + + +  | 

