[llvm] b5da312 - [llvm-cov][NFC] Add test for coverage-prefix-map remappings

Keith Smiley via llvm-commits llvm-commits at lists.llvm.org
Mon Aug 30 17:20:13 PDT 2021


Author: Keith Smiley
Date: 2021-08-30T17:19:57-07:00
New Revision: b5da3120b8ca99ad626af937eff0509ffa8e3440

URL: https://github.com/llvm/llvm-project/commit/b5da3120b8ca99ad626af937eff0509ffa8e3440
DIFF: https://github.com/llvm/llvm-project/commit/b5da3120b8ca99ad626af937eff0509ffa8e3440.diff

LOG: [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

Added: 
    llvm/test/tools/llvm-cov/Inputs/coverage_prefix_map/bar.h
    llvm/test/tools/llvm-cov/Inputs/coverage_prefix_map/main.cc
    llvm/test/tools/llvm-cov/Inputs/coverage_prefix_map/main.covmapping
    llvm/test/tools/llvm-cov/Inputs/coverage_prefix_map/main.profdata
    llvm/test/tools/llvm-cov/coverage-prefix-map.test

Modified: 
    

Removed: 
    


################################################################################
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 0000000000000..a4957daad7e2a
--- /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 0000000000000..2f4ea0a8213ac
--- /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 0000000000000..6f3062c20c573
Binary files /dev/null and b/llvm/test/tools/llvm-cov/Inputs/coverage_prefix_map/main.covmapping 
diff er

diff  --git a/llvm/test/tools/llvm-cov/Inputs/coverage_prefix_map/main.profdata b/llvm/test/tools/llvm-cov/Inputs/coverage_prefix_map/main.profdata
new file mode 100644
index 0000000000000..352a1e234684c
Binary files /dev/null and b/llvm/test/tools/llvm-cov/Inputs/coverage_prefix_map/main.profdata 
diff er

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 0000000000000..eaebae3f0db77
--- /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


        


More information about the llvm-commits mailing list