llvm.org GIT mirror llvm / d3f038d
[libFuzzer] try to print correct time in seconds when reporting a timeout. Don't report timeouts while still loading the corpus. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@266693 91177308-0d34-0410-b5e6-96231b3b80d8 Kostya Serebryany 4 years ago
3 changed file(s) with 6 addition(s) and 6 deletion(s). Raw diff Collapse all Expand all
390390 void DumpCurrentUnit(const char *Prefix);
391391 void DeathCallback();
392392
393 uint8_t *CurrentUnitData;
394 size_t CurrentUnitSize;
393 uint8_t *CurrentUnitData = nullptr;
394 size_t CurrentUnitSize = 0;
395395
396396 size_t TotalNumberOfRuns = 0;
397397 size_t TotalNumberOfExecutedTraceBasedMutations = 0;
279279 }
280280
281281 bool Fuzzer::RunOne(const uint8_t *Data, size_t Size) {
282 UnitStartTime = system_clock::now();
283282 TotalNumberOfRuns++;
284283
285284 PrepareCoverageBeforeRun();
311310 }
312311
313312 void Fuzzer::ExecuteCallback(const uint8_t *Data, size_t Size) {
313 UnitStartTime = system_clock::now();
314314 // We copy the contents of Unit into a separate heap buffer
315315 // so that we reliably find buffer overflows in it.
316316 std::unique_ptr DataCopy(new uint8_t[Size]);
319319 CurrentUnitData = DataCopy.get();
320320 CurrentUnitSize = Size;
321321 int Res = CB(DataCopy.get(), Size);
322 CurrentUnitSize = 0;
323 CurrentUnitData = nullptr;
322324 (void)Res;
323325 assert(Res == 0);
324 CurrentUnitData = nullptr;
325 CurrentUnitSize = 0;
326326 }
327327
328328 size_t Fuzzer::RecordBlockCoverage() {
77 TimeoutTest: SUMMARY: libFuzzer: timeout
88
99 RUN: not LLVMFuzzer-TimeoutTest -timeout=1 %S/hi.txt 2>&1 | FileCheck %s --check-prefix=SingleInputTimeoutTest
10 SingleInputTimeoutTest: ALARM: working on the last Unit for
10 SingleInputTimeoutTest: ALARM: working on the last Unit for {{[1-3]}} seconds
1111 SingleInputTimeoutTest-NOT: Test unit written to ./timeout-
1212
1313 RUN: LLVMFuzzer-TimeoutTest -timeout=1 -timeout_exitcode=0