[libFuzzer] add a test that is built w/o coverage instrumentation but has the coverage rt (it should now fail with a descriptive message)

llvm-svn: 272090
This commit is contained in:
Kostya Serebryany 2016-06-08 01:46:13 +00:00
parent 33b8b64aef
commit 76f425211e
5 changed files with 27 additions and 1 deletions

View 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() {

View 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)

View 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

View File

@ -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)

View 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")