xref: /llvm-project/llvm/test/tools/llvm-cov/sources-specified.test (revision e92eeaf3c21923151cf86c706e396b613145f142)
1RUN: llvm-cov report -instr-profile %S/Inputs/sources_specified/main.profdata \
2RUN:   -path-equivalence=/tmp,%S/Inputs \
3RUN:   %S/Inputs/sources_specified/main.covmapping \
4RUN:   %S/Inputs/sources_specified/main.cc %S/Inputs/sources_specified/extra \
5RUN:   | FileCheck -check-prefix=REPORT %s
6
7RUN: llvm-cov show -instr-profile %S/Inputs/sources_specified/main.profdata \
8RUN:   -path-equivalence=/tmp,%S/Inputs \
9RUN:   %S/Inputs/sources_specified/main.covmapping \
10RUN:   %S/Inputs/sources_specified/main.cc %S/Inputs/sources_specified/extra \
11RUN:   | FileCheck -check-prefix=SHOW %s
12
13# Don't include all source files when provided source files are filtered out.
14RUN: llvm-cov show -instr-profile %S/Inputs/sources_specified/main.profdata \
15RUN:   -path-equivalence=/tmp,%S/Inputs \
16RUN:   %S/Inputs/sources_specified/main.covmapping \
17RUN:   --ignore-filename-regex='.*' \
18RUN:   %S/Inputs/sources_specified/main.cc %S/Inputs/sources_specified/extra \
19RUN:   | FileCheck -allow-empty -check-prefix=IGNORE %s
20
21IGNORE-NOT: {{.*}}main.cc{{.*}}
22IGNORE-NOT: {{.*}}inc.h{{.*}}
23IGNORE-NOT: {{.*}}dec.h{{.*}}
24
25# Order of files may differ, check the total values calculated.
26REPORT-NOT: {{.*}}abs.h{{.*}}
27REPORT: {{^}}TOTAL 3{{.*}}72.73%
28
29# Order of files may differ, check that there are 3 files and not abs.h.
30SHOW-NOT: {{.*}}abs.h{{.*}}
31SHOW: {{.*}}sources_specified{{.*}}
32SHOW: {{.*}}sources_specified{{.*}}
33SHOW: {{.*}}sources_specified{{.*}}
34
35
36# Test "export" command. Use a temp .json file as output is a single line.
37RUN: llvm-cov export -instr-profile %S/Inputs/sources_specified/main.profdata \
38RUN:   -path-equivalence=/tmp,%S/Inputs \
39RUN:   %S/Inputs/sources_specified/main.covmapping \
40RUN:   %S/Inputs/sources_specified/main.cc %S/Inputs/sources_specified/extra \
41RUN:   > %t.export.json
42
43RUN: FileCheck -check-prefix=NO-EXPORT %s < %t.export.json
44RUN: FileCheck -check-prefix=EXPORT %s < %t.export.json
45
46NO-EXPORT-NOT: {{"filename":"(/|\\\\)tmp(/|\\\\)sources_specified(/|\\\\)abs.h"}}
47EXPORT-DAG: {{"filename":"(/|\\\\)tmp(/|\\\\)sources_specified(/|\\\\)main.cc"}}
48EXPORT-DAG: {{"filename":"(/|\\\\)tmp(/|\\\\)sources_specified(/|\\\\)extra(/|\\\\)dec.h"}}
49EXPORT-DAG: {{"filename":"(/|\\\\)tmp(/|\\\\)sources_specified(/|\\\\)extra(/|\\\\)inc.h"}}
50
51Instructions for regenerating the test:
52
53# cd %S/Inputs/sources_specified
54cp -r . /tmp/sources_specified
55
56clang -mllvm -enable-name-compression=false -fprofile-instr-generate \
57    -fcoverage-mapping /tmp/sources_specified/main.cc -o main
58
59LLVM_PROFILE_FILE="main.raw" ./main
60llvm-profdata merge main.raw -o main.profdata
61llvm-cov convert-for-testing ./main -o ./main.covmapping
62rm main main.raw
63