OSDN Git Service

[libFuzzer] add a test that is built w/o coverage instrumentation but has the coverag...
authorKostya Serebryany <kcc@google.com>
Wed, 8 Jun 2016 01:46:13 +0000 (01:46 +0000)
committerKostya Serebryany <kcc@google.com>
Wed, 8 Jun 2016 01:46:13 +0000 (01:46 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@272090 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Fuzzer/FuzzerLoop.cpp
lib/Fuzzer/test/CMakeLists.txt
lib/Fuzzer/test/fuzzer.test
lib/Fuzzer/test/no-coverage/CMakeLists.txt [new file with mode: 0644]
lib/Fuzzer/test/uninstrumented/CMakeLists.txt

index 5cfbad4..e397645 100644 (file)
@@ -391,6 +391,11 @@ void Fuzzer::ShuffleAndMinimize() {
   for (auto &X : Corpus)
     UnitHashesAddedToCorpus.insert(Hash(X));
   PrintStats("INITED");
+  if (Corpus.empty()) {
+    Printf("ERROR: no interesting inputs were found. "
+           "Is the code instrumented for coverage? Exiting.\n");
+    exit(1);
+  }
 }
 
 bool Fuzzer::UpdateMaxCoverage() {
index 85fb62e..9421606 100644 (file)
@@ -149,6 +149,7 @@ else()
 endif()
 
 add_subdirectory(uninstrumented)
+add_subdirectory(no-coverage)
 add_subdirectory(ubsan)
 add_subdirectory(trace-bb)
 add_subdirectory(trace-pc)
index 25ca5ff..11343ae 100644 (file)
@@ -32,6 +32,9 @@ RUN: not LLVMFuzzer-CallerCalleeTest                     -cross_over=0 -max_len=
 RUN: not LLVMFuzzer-UninstrumentedTest-Uninstrumented 2>&1 | FileCheck %s --check-prefix=UNINSTRUMENTED
 UNINSTRUMENTED: ERROR: __sanitizer_set_death_callback is not defined. Exiting.
 
+RUN: not LLVMFuzzer-UninstrumentedTest-NoCoverage 2>&1 | FileCheck %s --check-prefix=NO_COVERAGE
+NO_COVERAGE: ERROR: no interesting inputs were found. Is the code instrumented for coverage? Exiting
+
 RUN: not LLVMFuzzer-BufferOverflowOnInput 2>&1 | FileCheck %s --check-prefix=OOB
 OOB: AddressSanitizer: heap-buffer-overflow
 OOB: is located 0 bytes to the right of 3-byte region
diff --git a/lib/Fuzzer/test/no-coverage/CMakeLists.txt b/lib/Fuzzer/test/no-coverage/CMakeLists.txt
new file mode 100644 (file)
index 0000000..1dc7d15
--- /dev/null
@@ -0,0 +1,16 @@
+# These tests are not instrumented with coverage,
+# but have coverage rt in the binary.
+
+set(CMAKE_CXX_FLAGS
+  "${LIBFUZZER_FLAGS_BASE} -fno-sanitize-coverage=edge,trace-cmp,indirect-calls,8bit-counters")
+
+set(NoCoverageTests
+  UninstrumentedTest
+  )
+
+foreach(Test ${NoCoverageTests})
+  add_libfuzzer_test(${Test}-NoCoverage SOURCES ../${Test}.cpp)
+endforeach()
+
+# Propagate value into parent directory
+set(TestBinaries ${TestBinaries} PARENT_SCOPE)
index 35c9648..06e4898 100644 (file)
@@ -1,4 +1,5 @@
-# These tests are not instrumented with coverage.
+# These tests are not instrumented with coverage and don't
+# have coverage rt in the binary.
 
 set(CMAKE_CXX_FLAGS
   "${LIBFUZZER_FLAGS_BASE} -fno-sanitize=all -fno-sanitize-coverage=edge,trace-cmp,indirect-calls,8bit-counters")