summaryrefslogtreecommitdiffstats
path: root/llvm/test
diff options
context:
space:
mode:
authorMax Moroz <mmoroz@chromium.org>2017-10-13 14:44:51 +0000
committerMax Moroz <mmoroz@chromium.org>2017-10-13 14:44:51 +0000
commit4a4bfa4e2759ca0c9740187a26d703ef17f4bb3e (patch)
tree79edf2c8de7b1b547ce518b99e42f1138c14bdaa /llvm/test
parent614fab4bd89085b9f10253924b671ec2f650fae1 (diff)
downloadbcm5719-llvm-4a4bfa4e2759ca0c9740187a26d703ef17f4bb3e.tar.gz
bcm5719-llvm-4a4bfa4e2759ca0c9740187a26d703ef17f4bb3e.zip
[llvm-cov] Generate "report" for given source paths if sources are specified.
Summary: Documentation says that user can specify sources for both "show" and "report" commands. "Show" command respects specified sources, but "report" does not. It is useful to have both "show" and "report" generated for specified sources. Also added tests to for both commands with sources specified. Reviewers: vsk, kcc Reviewed By: vsk Differential Revision: https://reviews.llvm.org/D38860 llvm-svn: 315685
Diffstat (limited to 'llvm/test')
-rw-r--r--llvm/test/tools/llvm-cov/Inputs/sources_specified/abs.h5
-rw-r--r--llvm/test/tools/llvm-cov/Inputs/sources_specified/extra/dec.h3
-rw-r--r--llvm/test/tools/llvm-cov/Inputs/sources_specified/extra/inc.h3
-rw-r--r--llvm/test/tools/llvm-cov/Inputs/sources_specified/main.cc9
-rw-r--r--llvm/test/tools/llvm-cov/Inputs/sources_specified/main.covmappingbin0 -> 624 bytes
-rw-r--r--llvm/test/tools/llvm-cov/Inputs/sources_specified/main.profdatabin0 -> 880 bytes
-rw-r--r--llvm/test/tools/llvm-cov/sources-specified.test28
7 files changed, 48 insertions, 0 deletions
diff --git a/llvm/test/tools/llvm-cov/Inputs/sources_specified/abs.h b/llvm/test/tools/llvm-cov/Inputs/sources_specified/abs.h
new file mode 100644
index 00000000000..f13c5177c58
--- /dev/null
+++ b/llvm/test/tools/llvm-cov/Inputs/sources_specified/abs.h
@@ -0,0 +1,5 @@
+int abs(int x) {
+ if (x < 0)
+ return -x;
+ return x;
+}
diff --git a/llvm/test/tools/llvm-cov/Inputs/sources_specified/extra/dec.h b/llvm/test/tools/llvm-cov/Inputs/sources_specified/extra/dec.h
new file mode 100644
index 00000000000..178e1ea8c26
--- /dev/null
+++ b/llvm/test/tools/llvm-cov/Inputs/sources_specified/extra/dec.h
@@ -0,0 +1,3 @@
+int dec(int x) {
+ return x + 1;
+}
diff --git a/llvm/test/tools/llvm-cov/Inputs/sources_specified/extra/inc.h b/llvm/test/tools/llvm-cov/Inputs/sources_specified/extra/inc.h
new file mode 100644
index 00000000000..5086aaa1e38
--- /dev/null
+++ b/llvm/test/tools/llvm-cov/Inputs/sources_specified/extra/inc.h
@@ -0,0 +1,3 @@
+int inc(int x) {
+ return x + 1;
+}
diff --git a/llvm/test/tools/llvm-cov/Inputs/sources_specified/main.cc b/llvm/test/tools/llvm-cov/Inputs/sources_specified/main.cc
new file mode 100644
index 00000000000..cda21f1f57a
--- /dev/null
+++ b/llvm/test/tools/llvm-cov/Inputs/sources_specified/main.cc
@@ -0,0 +1,9 @@
+#include "abs.h"
+#include "extra/dec.h"
+#include "extra/inc.h"
+
+int main() {
+ int x = 0;
+ inc(x);
+ return abs(x);
+}
diff --git a/llvm/test/tools/llvm-cov/Inputs/sources_specified/main.covmapping b/llvm/test/tools/llvm-cov/Inputs/sources_specified/main.covmapping
new file mode 100644
index 00000000000..95f22f53b4d
--- /dev/null
+++ b/llvm/test/tools/llvm-cov/Inputs/sources_specified/main.covmapping
Binary files differ
diff --git a/llvm/test/tools/llvm-cov/Inputs/sources_specified/main.profdata b/llvm/test/tools/llvm-cov/Inputs/sources_specified/main.profdata
new file mode 100644
index 00000000000..aeee1ab7f7d
--- /dev/null
+++ b/llvm/test/tools/llvm-cov/Inputs/sources_specified/main.profdata
Binary files differ
diff --git a/llvm/test/tools/llvm-cov/sources-specified.test b/llvm/test/tools/llvm-cov/sources-specified.test
new file mode 100644
index 00000000000..cd19adf52fe
--- /dev/null
+++ b/llvm/test/tools/llvm-cov/sources-specified.test
@@ -0,0 +1,28 @@
+RUN: llvm-cov report -instr-profile %S/Inputs/sources_specified/main.profdata \
+RUN: %S/Inputs/sources_specified/main.covmapping \
+RUN: %S/Inputs/sources_specified/main.cc %S/Inputs/sources_specified/extra \
+RUN: | FileCheck -check-prefix=REPORT %s
+
+RUN: llvm-cov show -instr-profile %S/Inputs/sources_specified/main.profdata \
+RUN: %S/Inputs/sources_specified/main.covmapping \
+RUN: %S/Inputs/sources_specified/main.cc %S/Inputs/sources_specified/extra \
+RUN: | FileCheck -check-prefix=SHOW %s
+
+
+REPORT: {{^}}main.cc{{.*}}
+REPORT: {{^}}extra{{[/\\]}}{{dec|inc}}.h{{.*}}
+REPORT: {{^}}extra{{[/\\]}}{{dec|inc}}.h{{.*}}
+REPORT-NOT: {{^}}abs.h{{.*}}
+
+SHOW: {{.*}}main.cc{{.*}}
+SHOW: {{.*}}extra{{[/\\]}}{{dec|inc}}.h{{.*}}
+SHOW: {{.*}}extra{{[/\\]}}{{dec|inc}}.h{{.*}}
+SHOW-NOT: {{.*}}abs.h{{.*}}
+
+Instructions for regenerating the test:
+
+clang -mllvm -enable-name-compression=false -fprofile-instr-generate -fcoverage-mapping 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
OpenPOWER on IntegriCloud