Options.PrintFinalStats = Flags.print_final_stats;
Options.PrintCorpusStats = Flags.print_corpus_stats;
Options.PrintCoverage = Flags.print_coverage;
- Options.PruneCorpus = Flags.prune_corpus;
if (Flags.exit_on_src_pos)
Options.ExitOnSrcPos = Flags.exit_on_src_pos;
"try to detect memory leaks during fuzzing (i.e. not only at shut down).")
FUZZER_FLAG_INT(rss_limit_mb, 2048, "If non-zero, the fuzzer will exit upon"
"reaching this limit of RSS memory usage.")
-FUZZER_FLAG_INT(prune_corpus, 1, "Prune corpus items without new coverage when "
- "loading corpus.")
FUZZER_FLAG_STRING(exit_on_src_pos, "Exit if a newly found PC originates"
" from the given source location. Example: -exit_on_src_pos=foo.cc:123. "
"Used primarily for testing libFuzzer itself.")
ShuffleCorpus(InitialCorpus);
for (const auto &U : *InitialCorpus) {
- bool NewCoverage = RunOne(U);
- if (!Options.PruneCorpus || NewCoverage) {
+ if (RunOne(U)) {
AddToCorpusAndMaybeRerun(U);
if (Options.Verbosity >= 2)
Printf("NEW0: %zd L %zd\n", MaxCoverage.BlockCoverage, U.size());
bool PrintCorpusStats = false;
bool PrintCoverage = false;
bool DetectLeaks = true;
- bool PruneCorpus = true;
};
} // namespace fuzzer
static const char *Separator = "-_^_-";
static const char *Target = "012-_^_-abc";
+static volatile int sink;
+
extern "C" int LLVMFuzzerTestOneInput(const uint8_t *Data, size_t Size) {
assert(Data);
std::string Str(reinterpret_cast<const char *>(Data), Size);
+ // Ensure that two different elements exist in the corpus.
+ if (Size && Data[0] == '0') sink++;
+ if (Size && Data[0] == 'a') sink--;
+
if (Str.find(Target) != std::string::npos) {
std::cout << "BINGO; Found the target, exiting\n";
exit(1);
RUN: mkdir -p %t/CustomCrossover
RUN: echo "0123456789" > %t/CustomCrossover/digits
RUN: echo "abcdefghij" > %t/CustomCrossover/chars
-RUN: not LLVMFuzzer-CustomCrossOverTest -seed=1 -use_memcmp=0 -runs=100000 -prune_corpus=0 %t/CustomCrossover 2>&1 | FileCheck %s --check-prefix=LLVMFuzzerCustomCrossover
+RUN: not LLVMFuzzer-CustomCrossOverTest -seed=1 -use_memcmp=0 -runs=100000 %t/CustomCrossover 2>&1 | FileCheck %s --check-prefix=LLVMFuzzerCustomCrossover
RUN: rm -rf %t/CustomCrossover
LLVMFuzzerCustomCrossover: In LLVMFuzzerCustomCrossover
+++ /dev/null
-RUN: rm -rf %t/PruneCorpus
-RUN: mkdir -p %t/PruneCorpus
-RUN: echo a > %t/PruneCorpus/a
-RUN: echo b > %t/PruneCorpus/b
-RUN: LLVMFuzzer-EmptyTest %t/PruneCorpus -prune_corpus=1 -runs=0 2>&1 | FileCheck %s --check-prefix=PRUNE
-RUN: LLVMFuzzer-EmptyTest %t/PruneCorpus -prune_corpus=0 -runs=0 2>&1 | FileCheck %s --check-prefix=NOPRUNE
-RUN: rm -rf %t/PruneCorpus
-
-PRUNE: READ units: 2
-PRUNE: INITED{{.*}}units: 1
-NOPRUNE: READ units: 2
-NOPRUNE: INITED{{.*}}units: 2
-