aboutsummaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorMax Moroz <mmoroz@chromium.org>2018-10-12 13:59:56 +0000
committerMax Moroz <mmoroz@chromium.org>2018-10-12 13:59:56 +0000
commit98d2aa84a634a6e5f708c5f2ce8691d026c2125a (patch)
tree9a9b70ff9a19536781db3015f4bfd2243c22c308 /test
parent6804ce467d7e17216e38527f83ecaa8a571feee2 (diff)
[libFuzzer] Add test for SanitizerCoverage working on Mac even with -Wl,-dead_strip.
Summary: The corresponding asncov change: https://reviews.llvm.org/D53113. Bug: https://bugs.chromium.org/p/chromium/issues/detail?id=892167 Reviewers: morehouse, kcc, george.karpenkov Reviewed By: morehouse, george.karpenkov Subscribers: delcypher, #sanitizers, llvm-commits Differential Revision: https://reviews.llvm.org/D53114 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@344346 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'test')
-rw-r--r--test/fuzzer/dead-stripping.test23
1 files changed, 23 insertions, 0 deletions
diff --git a/test/fuzzer/dead-stripping.test b/test/fuzzer/dead-stripping.test
new file mode 100644
index 000000000..85445ea9f
--- /dev/null
+++ b/test/fuzzer/dead-stripping.test
@@ -0,0 +1,23 @@
+REQUIRES: darwin
+
+No dead_strip. Unused code is not removed.
+RUN: %cpp_compiler %S/GcSectionsTest.cpp -o %t
+RUN: nm %t | grep UnusedFunctionShouldBeRemovedByLinker | count 1
+RUN: %run %t -runs=0 2>&1 | FileCheck %s
+
+With dead_strip. Unused code is not removed.
+RUN: %cpp_compiler %S/GcSectionsTest.cpp -o %t -ffunction-sections -Wl,-dead_strip
+RUN: nm %t | grep UnusedFunctionShouldBeRemovedByLinker | count 1
+RUN: %run %t -runs=0 2>&1 | FileCheck %s
+
+With dead_strip, with trace-pc. Unused code is removed.
+RUN: %cpp_compiler %S/GcSectionsTest.cpp -o %t -ffunction-sections -fsanitize-coverage=0 -fsanitize-coverage=trace-pc -Wl,-dead_strip
+RUN: nm %t | not grep UnusedFunctionShouldBeRemovedByLinker
+RUN: %run %t -runs=0 2>&1 | FileCheck %s
+
+With dead_strip, with pc-table. Unused code is not removed.
+RUN: %cpp_compiler %S/GcSectionsTest.cpp -o %t -ffunction-sections -fsanitize-coverage=0 -fsanitize-coverage=trace-pc-guard,pc-table -Wl,-dead_strip
+RUN: nm %t | grep UnusedFunctionShouldBeRemovedByLinker | count 1
+RUN: %run %t -runs=0 2>&1 | FileCheck %s
+
+CHECK-NOT: ERROR: The size of coverage PC tables does not match