[gcov] Add a test showing differences in line counts when building with or without...
authorMarco Castelluccio <mcastelluccio@mozilla.com>
Mon, 16 Jul 2018 14:40:33 +0000 (14:40 +0000)
committerMarco Castelluccio <mcastelluccio@mozilla.com>
Mon, 16 Jul 2018 14:40:33 +0000 (14:40 +0000)
Test for https://bugs.llvm.org/show_bug.cgi?id=38066.

llvm-svn: 337174

compiler-rt/test/profile/Inputs/instrprof-gcov-exceptions.cpp [new file with mode: 0644]
compiler-rt/test/profile/Inputs/instrprof-gcov-exceptions.cpp.gcov [new file with mode: 0644]
compiler-rt/test/profile/instrprof-gcov-exceptions.test [new file with mode: 0644]

diff --git a/compiler-rt/test/profile/Inputs/instrprof-gcov-exceptions.cpp b/compiler-rt/test/profile/Inputs/instrprof-gcov-exceptions.cpp
new file mode 100644 (file)
index 0000000..3279665
--- /dev/null
@@ -0,0 +1,11 @@
+#include <string>
+
+void asd(std::string i) {
+}
+
+int main(void)
+{
+  asd("22");
+
+  return 0;
+}
diff --git a/compiler-rt/test/profile/Inputs/instrprof-gcov-exceptions.cpp.gcov b/compiler-rt/test/profile/Inputs/instrprof-gcov-exceptions.cpp.gcov
new file mode 100644 (file)
index 0000000..7caf508
--- /dev/null
@@ -0,0 +1,16 @@
+// CHECK:        -:    0:Source:{{.*}}Inputs/instrprof-gcov-exceptions.cpp
+// CHECK-NEXT:        -:    0:Graph:instrprof-gcov-exceptions.gcno
+// CHECK-NEXT:        -:    0:Data:instrprof-gcov-exceptions.gcda
+// CHECK-NEXT:        -:    0:Runs:1
+// CHECK-NEXT:        -:    0:Programs:1
+// CHECK-NEXT:        -:    1:#include <string>
+// CHECK-NEXT:        -:    2:
+// CHECK-NEXT:        -:    3:void asd(std::string i) {
+// CHECK-NEXT:        2:    4:}
+// CHECK-NEXT:        -:    5:
+// CHECK-NEXT:        -:    6:int main(void)
+// CHECK-NEXT:        -:    7:{
+// CHECK-NEXT:        1:    8:  asd("22");
+// CHECK-NEXT:        -:    9:
+// CHECK-NEXT:        1:   10:  return 0;
+// CHECK-NEXT:        -:   11:}
diff --git a/compiler-rt/test/profile/instrprof-gcov-exceptions.test b/compiler-rt/test/profile/instrprof-gcov-exceptions.test
new file mode 100644 (file)
index 0000000..20ca47a
--- /dev/null
@@ -0,0 +1,21 @@
+RUN: mkdir -p %t.d
+RUN: cd %t.d
+
+# Test with exceptions disabled.
+RUN: %clangxx --coverage -o %t %S/Inputs/instrprof-gcov-exceptions.cpp -fno-exceptions
+RUN: test -f instrprof-gcov-exceptions.gcno
+
+RUN: rm -f instrprof-gcov-exceptions.gcda
+RUN: %run %t
+RUN: llvm-cov gcov instrprof-gcov-exceptions.gcda
+RUN: FileCheck --match-full-lines --strict-whitespace --input-file instrprof-gcov-exceptions.cpp.gcov %S/Inputs/instrprof-gcov-exceptions.cpp.gcov
+
+# Test with exceptions enabled, the result in terms of line counts should be the same.
+RUN: %clangxx --coverage -o %t %S/Inputs/instrprof-gcov-exceptions.cpp
+RUN: test -f instrprof-gcov-exceptions.gcno
+
+RUN: rm -f instrprof-gcov-exceptions.gcda
+RUN: %run %t
+RUN: llvm-cov gcov instrprof-gcov-exceptions.gcda
+# The result should be the same, not using XFAIL as only this part of the test is failing.
+RUN: not FileCheck --match-full-lines --strict-whitespace --input-file instrprof-gcov-exceptions.cpp.gcov %S/Inputs/instrprof-gcov-exceptions.cpp.gcov