summaryrefslogtreecommitdiff
path: root/test/profile/Posix/instrprof-shared-gcov-flush.test
diff options
context:
space:
mode:
Diffstat (limited to 'test/profile/Posix/instrprof-shared-gcov-flush.test')
-rw-r--r--test/profile/Posix/instrprof-shared-gcov-flush.test52
1 files changed, 52 insertions, 0 deletions
diff --git a/test/profile/Posix/instrprof-shared-gcov-flush.test b/test/profile/Posix/instrprof-shared-gcov-flush.test
new file mode 100644
index 000000000..8d530fd45
--- /dev/null
+++ b/test/profile/Posix/instrprof-shared-gcov-flush.test
@@ -0,0 +1,52 @@
+# This test fails on Mac (https://bugs.llvm.org/show_bug.cgi?id=38134)
+XFAIL: darwin
+
+RUN: mkdir -p %t.d
+RUN: cd %t.d
+
+RUN: %clang --coverage -o libfunc.so -fPIC -shared %S/../Inputs/instrprof-shared-lib.c
+RUN: test -f instrprof-shared-lib.gcno
+
+# Test the case where we exit abruptly after calling __gcov_flush, which means we don't write out the counters at exit.
+RUN: %clang -DEXIT_ABRUPTLY -DSHARED_CALL_BEFORE_GCOV_FLUSH -DSHARED_CALL_AFTER_GCOV_FLUSH --coverage -o %t -L%t.d -rpath %t.d -lfunc %S/../Inputs/instrprof-shared-main-gcov-flush.c
+RUN: test -f instrprof-shared-main-gcov-flush.gcno
+
+RUN: rm -f instrprof-shared-main-gcov-flush.gcda instrprof-shared-lib.gcda
+RUN: %run %t
+RUN: llvm-cov gcov instrprof-shared-main-gcov-flush.gcda
+RUN: FileCheck --match-full-lines --strict-whitespace --input-file instrprof-shared-main-gcov-flush.c.gcov %S/../Inputs/instrprof-shared-main-gcov-flush_no-writeout.c.gcov
+RUN: llvm-cov gcov instrprof-shared-lib.gcda
+RUN: FileCheck --match-full-lines --strict-whitespace --input-file instrprof-shared-lib.c.gcov %S/../Inputs/instrprof-shared-lib.c.gcov
+
+# Test the case where we exit normally and we have a call to the shared library function before __gcov_flush.
+RUN: %clang -DSHARED_CALL_BEFORE_GCOV_FLUSH --coverage -o %t -L%t.d -rpath %t.d -lfunc %S/../Inputs/instrprof-shared-main-gcov-flush.c
+RUN: test -f instrprof-shared-main-gcov-flush.gcno
+
+RUN: rm -f instrprof-shared-main-gcov-flush.gcda instrprof-shared-lib.gcda
+RUN: %run %t
+RUN: llvm-cov gcov instrprof-shared-main-gcov-flush.gcda
+RUN: FileCheck --match-full-lines --strict-whitespace --input-file instrprof-shared-main-gcov-flush.c.gcov %S/../Inputs/instrprof-shared-main-gcov-flush_shared-call-before.c.gcov
+RUN: llvm-cov gcov instrprof-shared-lib.gcda
+RUN: FileCheck --match-full-lines --strict-whitespace --input-file instrprof-shared-lib.c.gcov %S/../Inputs/instrprof-shared-lib.c.gcov
+
+# Test the case where we exit normally and we have a call to the shared library function after __gcov_flush.
+RUN: %clang -DSHARED_CALL_AFTER_GCOV_FLUSH --coverage -o %t -L%t.d -rpath %t.d -lfunc %S/../Inputs/instrprof-shared-main-gcov-flush.c
+RUN: test -f instrprof-shared-main-gcov-flush.gcno
+
+RUN: rm -f instrprof-shared-main-gcov-flush.gcda instrprof-shared-lib.gcda
+RUN: %run %t
+RUN: llvm-cov gcov instrprof-shared-main-gcov-flush.gcda
+RUN: FileCheck --match-full-lines --strict-whitespace --input-file instrprof-shared-main-gcov-flush.c.gcov %S/../Inputs/instrprof-shared-main-gcov-flush_shared-call-after.c.gcov
+RUN: llvm-cov gcov instrprof-shared-lib.gcda
+RUN: FileCheck --match-full-lines --strict-whitespace --input-file instrprof-shared-lib.c.gcov %S/../Inputs/instrprof-shared-lib.c.gcov
+
+# Test the case where we exit normally and we have calls to the shared library function before and after __gcov_flush.
+RUN: %clang -DSHARED_CALL_BEFORE_GCOV_FLUSH -DSHARED_CALL_AFTER_GCOV_FLUSH --coverage -o %t -L%t.d -rpath %t.d -lfunc %S/../Inputs/instrprof-shared-main-gcov-flush.c
+RUN: test -f instrprof-shared-main-gcov-flush.gcno
+
+RUN: rm -f instrprof-shared-main-gcov-flush.gcda instrprof-shared-lib.gcda
+RUN: %run %t
+RUN: llvm-cov gcov instrprof-shared-main-gcov-flush.gcda
+RUN: FileCheck --match-full-lines --strict-whitespace --input-file instrprof-shared-main-gcov-flush.c.gcov %S/../Inputs/instrprof-shared-main-gcov-flush_shared-call-before-after.c.gcov
+RUN: llvm-cov gcov instrprof-shared-lib.gcda
+RUN: FileCheck --match-full-lines --strict-whitespace --input-file instrprof-shared-lib.c.gcov %S/../Inputs/instrprof-shared-lib_called-twice.c.gcov