Skip to content
This repository was archived by the owner on Mar 28, 2020. It is now read-only.

Commit 18c0216

Browse files
committed
[libFuzzer] print stats after running individual inputs
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@268547 91177308-0d34-0410-b5e6-96231b3b80d8
1 parent c95df94 commit 18c0216

File tree

3 files changed

+7
-2
lines changed

3 files changed

+7
-2
lines changed

lib/Fuzzer/FuzzerDriver.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -238,7 +238,7 @@ int RunOneTest(Fuzzer *F, const char *InputFilePath) {
238238
Unit U = FileToVector(InputFilePath);
239239
Unit PreciseSizedU(U);
240240
assert(PreciseSizedU.size() == PreciseSizedU.capacity());
241-
F->ExecuteCallback(PreciseSizedU.data(), PreciseSizedU.size());
241+
F->RunOne(PreciseSizedU.data(), PreciseSizedU.size());
242242
return 0;
243243
}
244244

@@ -355,6 +355,7 @@ static int FuzzerDriver(const std::vector<std::string> &Args,
355355
auto MS = duration_cast<milliseconds>(StopTime - StartTime).count();
356356
Printf("%s: %zd ms\n", Path.c_str(), (long)MS);
357357
}
358+
F.PrintFinalStats();
358359
exit(0);
359360
}
360361

lib/Fuzzer/FuzzerInternal.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -344,6 +344,7 @@ class Fuzzer {
344344
static void StaticInterruptCallback();
345345

346346
void ExecuteCallback(const uint8_t *Data, size_t Size);
347+
bool RunOne(const uint8_t *Data, size_t Size);
347348

348349
// Merge Corpora[1:] into Corpora[0].
349350
void Merge(const std::vector<std::string> &Corpora);
@@ -359,7 +360,6 @@ class Fuzzer {
359360
void InterruptCallback();
360361
void MutateAndTestOne();
361362
void ReportNewCoverage(const Unit &U);
362-
bool RunOne(const uint8_t *Data, size_t Size);
363363
bool RunOne(const Unit &U) { return RunOne(U.data(), U.size()); }
364364
void RunOneAndUpdateCorpus(uint8_t *Data, size_t Size);
365365
void WriteToOutputCorpus(const Unit &U);

lib/Fuzzer/test/fuzzer.test

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,10 @@ FINAL_STATS: stat::new_units_added:
8787
FINAL_STATS: stat::slowest_unit_time_sec: 0
8888
FINAL_STATS: stat::peak_rss_mb:
8989

90+
RUN: LLVMFuzzer-SimpleTest %S/dict1.txt -runs=33 -print_final_stats=1 2>&1 | FileCheck %s --check-prefix=FINAL_STATS1
91+
FINAL_STATS1: stat::number_of_executed_units: 33
92+
FINAL_STATS1: stat::peak_rss_mb:
93+
9094
RUN: LLVMFuzzer-SpamyTest -runs=1 2>&1 | FileCheck %s --check-prefix=FD_MASK_0
9195
RUN: LLVMFuzzer-SpamyTest -runs=1 -close_fd_mask=0 2>&1 | FileCheck %s --check-prefix=FD_MASK_0
9296
RUN: LLVMFuzzer-SpamyTest -runs=1 -close_fd_mask=1 2>&1 | FileCheck %s --check-prefix=FD_MASK_1

0 commit comments

Comments
 (0)