mirror of
https://github.com/RPCSX/llvm.git
synced 2025-02-02 18:42:36 +00:00
[libFuzzer] make -runs=N flag also affect the simple runner (will execute every input N times)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@260649 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
197cdba264
commit
14c6007ab2
@ -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);
|
||||
|
@ -22,6 +22,7 @@ set(Tests
|
||||
MemcmpTest
|
||||
LeakTest
|
||||
NullDerefTest
|
||||
NthRunCrashTest
|
||||
RepeatedMemcmp
|
||||
SimpleCmpTest
|
||||
SimpleDictionaryTest
|
||||
|
15
lib/Fuzzer/test/NthRunCrashTest.cpp
Normal file
15
lib/Fuzzer/test/NthRunCrashTest.cpp
Normal 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;
|
||||
}
|
||||
|
@ -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
|
||||
|
Loading…
x
Reference in New Issue
Block a user