From b5da3120b8ca99ad626af937eff0509ffa8e3440 Mon Sep 17 00:00:00 2001 From: Keith Smiley Date: Thu, 26 Aug 2021 23:36:49 -0700 Subject: [PATCH] [llvm-cov][NFC] Add test for coverage-prefix-map remappings This test covers acts as a regression test for these fixes: c75a0a1e9dc29be4e00d37d0d00288afc1a6153f dd388ba3e0b0a5f06565d0bcb6e1aebb5daac065 Differential Revision: https://reviews.llvm.org/D108805 --- .../llvm-cov/Inputs/coverage_prefix_map/bar.h | 3 +++ .../llvm-cov/Inputs/coverage_prefix_map/main.cc | 9 +++++++ .../Inputs/coverage_prefix_map/main.covmapping | Bin 0 -> 205 bytes .../Inputs/coverage_prefix_map/main.profdata | Bin 0 -> 760 bytes llvm/test/tools/llvm-cov/coverage-prefix-map.test | 27 +++++++++++++++++++++ 5 files changed, 39 insertions(+) create mode 100644 llvm/test/tools/llvm-cov/Inputs/coverage_prefix_map/bar.h create mode 100644 llvm/test/tools/llvm-cov/Inputs/coverage_prefix_map/main.cc create mode 100644 llvm/test/tools/llvm-cov/Inputs/coverage_prefix_map/main.covmapping create mode 100644 llvm/test/tools/llvm-cov/Inputs/coverage_prefix_map/main.profdata create mode 100644 llvm/test/tools/llvm-cov/coverage-prefix-map.test diff --git a/llvm/test/tools/llvm-cov/Inputs/coverage_prefix_map/bar.h b/llvm/test/tools/llvm-cov/Inputs/coverage_prefix_map/bar.h new file mode 100644 index 0000000..a4957da --- /dev/null +++ b/llvm/test/tools/llvm-cov/Inputs/coverage_prefix_map/bar.h @@ -0,0 +1,3 @@ +int bar() { + return 0; +} diff --git a/llvm/test/tools/llvm-cov/Inputs/coverage_prefix_map/main.cc b/llvm/test/tools/llvm-cov/Inputs/coverage_prefix_map/main.cc new file mode 100644 index 0000000..2f4ea0a --- /dev/null +++ b/llvm/test/tools/llvm-cov/Inputs/coverage_prefix_map/main.cc @@ -0,0 +1,9 @@ +#include "bar.h" + +int foo() { + return 1; +} + +int main() { + return bar(); +} diff --git a/llvm/test/tools/llvm-cov/Inputs/coverage_prefix_map/main.covmapping b/llvm/test/tools/llvm-cov/Inputs/coverage_prefix_map/main.covmapping new file mode 100644 index 0000000000000000000000000000000000000000..6f3062c20c57398c1fbf4f70150bca417c8fa31c GIT binary patch literal 205 zcmd1FDa%dHFUu`SEiOq(EJ+lb(Ae4_Ai@wIWt@~)RK^IT)AIAn7;_Ud^BAB&7)rAO zX=VWiMm<)bQoRgzkQ%+@WUy?C(=$d5AuT?Fvy`c~Vd19$b_WAPZenJh1e6U64H(S< z7q2$qI{v4lw;q;GV7lX@jMMV-%g_yg>SI6{kmB@=QA0@cBNhXa5{oblKz9MmAnd7v Uf#C&IgBmn~(_s+}a|s#^09~mkdH?_b literal 0 HcmV?d00001 diff --git a/llvm/test/tools/llvm-cov/coverage-prefix-map.test b/llvm/test/tools/llvm-cov/coverage-prefix-map.test new file mode 100644 index 0000000..eaebae3 --- /dev/null +++ b/llvm/test/tools/llvm-cov/coverage-prefix-map.test @@ -0,0 +1,27 @@ +# RUN: llvm-cov report -path-equivalence=.,%S/Inputs/coverage_prefix_map \ +# RUN: -instr-profile %S/Inputs/coverage_prefix_map/main.profdata \ +# RUN: %S/Inputs/coverage_prefix_map/main.covmapping \ +# RUN: %S/Inputs/coverage_prefix_map/bar.h \ +# RUN: | FileCheck --check-prefix=REPORT --implicit-check-not=main.c %s + +# RUN: llvm-cov export -format lcov -path-equivalence=.,%S/Inputs/coverage_prefix_map \ +# RUN: -instr-profile %S/Inputs/coverage_prefix_map/main.profdata \ +# RUN: %S/Inputs/coverage_prefix_map/main.covmapping \ +# RUN: %S/Inputs/coverage_prefix_map/bar.h \ +# RUN: | FileCheck --check-prefix=LCOV --implicit-check-not=main.c %s + +# REPORT: {{^}}bar.h{{.*}} +# REPORT: {{^}}TOTAL{{.*}}100.00% + +# LCOV: SF:.{{/|\\+}}bar.h +# LCOV-NOT: SF + +Instructions for regenerating the test: +# cd %S/Inputs/coverage_prefix_map +cp -r . /tmp/coverage_prefix_map + +clang -fprofile-instr-generate -mllvm -enable-name-compression=false -fcoverage-mapping -fcoverage-prefix-map=$PWD=. main.cc -o main +LLVM_PROFILE_FILE="main.raw" ./main +llvm-profdata merge main.raw -o main.profdata +llvm-cov convert-for-testing ./main -o ./main.covmapping +rm main main.raw -- 2.7.4