[libFuzzer] try to print correct time in seconds when reporting a timeout. Don't report timeouts while still loading the corpus.

llvm-svn: 266693
This commit is contained in:
Kostya Serebryany 2016-04-18 22:50:39 +00:00
parent 43d1e45347
commit ebb932d060
3 changed files with 6 additions and 6 deletions

View File

@ -391,8 +391,8 @@ private:
void DumpCurrentUnit(const char *Prefix);
void DeathCallback();
uint8_t *CurrentUnitData;
size_t CurrentUnitSize;
uint8_t *CurrentUnitData = nullptr;
size_t CurrentUnitSize = 0;
size_t TotalNumberOfRuns = 0;
size_t TotalNumberOfExecutedTraceBasedMutations = 0;

View File

@ -280,7 +280,6 @@ void Fuzzer::ShuffleAndMinimize() {
}
bool Fuzzer::RunOne(const uint8_t *Data, size_t Size) {
UnitStartTime = system_clock::now();
TotalNumberOfRuns++;
PrepareCoverageBeforeRun();
@ -312,6 +311,7 @@ void Fuzzer::RunOneAndUpdateCorpus(uint8_t *Data, size_t Size) {
}
void Fuzzer::ExecuteCallback(const uint8_t *Data, size_t Size) {
UnitStartTime = system_clock::now();
// We copy the contents of Unit into a separate heap buffer
// so that we reliably find buffer overflows in it.
std::unique_ptr<uint8_t[]> DataCopy(new uint8_t[Size]);
@ -320,10 +320,10 @@ void Fuzzer::ExecuteCallback(const uint8_t *Data, size_t Size) {
CurrentUnitData = DataCopy.get();
CurrentUnitSize = Size;
int Res = CB(DataCopy.get(), Size);
CurrentUnitSize = 0;
CurrentUnitData = nullptr;
(void)Res;
assert(Res == 0);
CurrentUnitData = nullptr;
CurrentUnitSize = 0;
}
size_t Fuzzer::RecordBlockCoverage() {

View File

@ -8,7 +8,7 @@ TimeoutTest: #2
TimeoutTest: SUMMARY: libFuzzer: timeout
RUN: not LLVMFuzzer-TimeoutTest -timeout=1 %S/hi.txt 2>&1 | FileCheck %s --check-prefix=SingleInputTimeoutTest
SingleInputTimeoutTest: ALARM: working on the last Unit for
SingleInputTimeoutTest: ALARM: working on the last Unit for {{[1-3]}} seconds
SingleInputTimeoutTest-NOT: Test unit written to ./timeout-
RUN: LLVMFuzzer-TimeoutTest -timeout=1 -timeout_exitcode=0