1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-10-19 11:02:59 +02:00

[libFuzzer] make -runs=N flag also affect the simple runner (will execute every input N times)

llvm-svn: 260649
This commit is contained in:
Kostya Serebryany 2016-02-12 02:32:03 +00:00
parent 3886ad30a4
commit cf66bc968c
4 changed files with 28 additions and 3 deletions

View File

@ -335,10 +335,13 @@ int FuzzerDriver(const std::vector<std::string> &Args,
}
if (AllInputsAreFiles()) {
Printf("%s: Running %zd inputs.\n", ProgName->c_str(), Inputs->size());
int Runs = std::max(1, Flags.runs);
Printf("%s: Running %zd inputs %d time(s) each.\n", ProgName->c_str(),
Inputs->size(), Runs);
for (auto &Path : *Inputs) {
auto StartTime = system_clock::now();
RunOneTest(&F, Path.c_str());
while (Runs-- > 0)
RunOneTest(&F, Path.c_str());
auto StopTime = system_clock::now();
auto MS = duration_cast<milliseconds>(StopTime - StartTime).count();
Printf("%s: %zd ms\n", Path.c_str(), (long)MS);

View File

@ -22,6 +22,7 @@ set(Tests
MemcmpTest
LeakTest
NullDerefTest
NthRunCrashTest
RepeatedMemcmp
SimpleCmpTest
SimpleDictionaryTest

View File

@ -0,0 +1,15 @@
// Crash on the N-th execution.
#include <cstdint>
#include <cstddef>
#include <iostream>
static int Counter;
extern "C" int LLVMFuzzerTestOneInput(const uint8_t *Data, size_t Size) {
if (Counter++ == 1000) {
std::cout << "BINGO; Found the target, exiting\n";
exit(1);
}
return 0;
}

View File

@ -53,10 +53,16 @@ RUN: echo aaa > %tmp/SINGLE_INPUTS/aaa
RUN: echo bbb > %tmp/SINGLE_INPUTS/bbb
RUN: LLVMFuzzer-SimpleTest %tmp/SINGLE_INPUTS/aaa %tmp/SINGLE_INPUTS/bbb 2>&1 | FileCheck %s --check-prefix=SINGLE_INPUTS
RUN: rm -rf %tmp/SINGLE_INPUTS
SINGLE_INPUTS: LLVMFuzzer-SimpleTest: Running 2 inputs.
SINGLE_INPUTS: LLVMFuzzer-SimpleTest: Running 2 inputs 1 time(s) each.
SINGLE_INPUTS: aaa:
SINGLE_INPUTS: bbb:
RUN: not LLVMFuzzer-LeakTest -runs=10 2>&1 | FileCheck %s --check-prefix=LEAK
LEAK: ERROR: LeakSanitizer: detected memory leaks
LEAK-NOT: DEATH:
RUN: echo abcd > %t/NthRunCrashTest.in
RUN: LLVMFuzzer-NthRunCrashTest %t/NthRunCrashTest.in
RUN: LLVMFuzzer-NthRunCrashTest %t/NthRunCrashTest.in -runs=10
RUN: not LLVMFuzzer-NthRunCrashTest %t/NthRunCrashTest.in -runs=10000 2>&1 | FileCheck %s
RUN: rm %t/NthRunCrashTest.in