]> granicus.if.org Git - llvm/commitdiff
[libFuzzer] print stats after running individual inputs
authorKostya Serebryany <kcc@google.com>
Wed, 4 May 2016 20:44:50 +0000 (20:44 +0000)
committerKostya Serebryany <kcc@google.com>
Wed, 4 May 2016 20:44:50 +0000 (20:44 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@268547 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Fuzzer/FuzzerDriver.cpp
lib/Fuzzer/FuzzerInternal.h
lib/Fuzzer/test/fuzzer.test

index b0dc8f889d30a2c8da8c53b5347159397c3229d9..db5207908231ce13c268a1fbd01fdd4c92f7eddd 100644 (file)
@@ -238,7 +238,7 @@ int RunOneTest(Fuzzer *F, const char *InputFilePath) {
   Unit U = FileToVector(InputFilePath);
   Unit PreciseSizedU(U);
   assert(PreciseSizedU.size() == PreciseSizedU.capacity());
-  F->ExecuteCallback(PreciseSizedU.data(), PreciseSizedU.size());
+  F->RunOne(PreciseSizedU.data(), PreciseSizedU.size());
   return 0;
 }
 
@@ -355,6 +355,7 @@ static int FuzzerDriver(const std::vector<std::string> &Args,
       auto MS = duration_cast<milliseconds>(StopTime - StartTime).count();
       Printf("%s: %zd ms\n", Path.c_str(), (long)MS);
     }
+    F.PrintFinalStats();
     exit(0);
   }
 
index 169536b4f38e4d3e6328963062644d80a513a9d4..a34bfec57c1435a800348a52fbd9920edd4782ed 100644 (file)
@@ -344,6 +344,7 @@ public:
   static void StaticInterruptCallback();
 
   void ExecuteCallback(const uint8_t *Data, size_t Size);
+  bool RunOne(const uint8_t *Data, size_t Size);
 
   // Merge Corpora[1:] into Corpora[0].
   void Merge(const std::vector<std::string> &Corpora);
@@ -359,7 +360,6 @@ private:
   void InterruptCallback();
   void MutateAndTestOne();
   void ReportNewCoverage(const Unit &U);
-  bool RunOne(const uint8_t *Data, size_t Size);
   bool RunOne(const Unit &U) { return RunOne(U.data(), U.size()); }
   void RunOneAndUpdateCorpus(uint8_t *Data, size_t Size);
   void WriteToOutputCorpus(const Unit &U);
index 8794e88dd224cd0dfe33384ce6dae75721d7be63..e56597d2d955392d66799c67ba593940326493bb 100644 (file)
@@ -87,6 +87,10 @@ FINAL_STATS: stat::new_units_added:
 FINAL_STATS: stat::slowest_unit_time_sec:    0
 FINAL_STATS: stat::peak_rss_mb:
 
+RUN: LLVMFuzzer-SimpleTest %S/dict1.txt -runs=33 -print_final_stats=1 2>&1 | FileCheck %s --check-prefix=FINAL_STATS1
+FINAL_STATS1: stat::number_of_executed_units: 33
+FINAL_STATS1: stat::peak_rss_mb:
+
 RUN: LLVMFuzzer-SpamyTest -runs=1                  2>&1 | FileCheck %s --check-prefix=FD_MASK_0
 RUN: LLVMFuzzer-SpamyTest -runs=1 -close_fd_mask=0 2>&1 | FileCheck %s --check-prefix=FD_MASK_0
 RUN: LLVMFuzzer-SpamyTest -runs=1 -close_fd_mask=1 2>&1 | FileCheck %s --check-prefix=FD_MASK_1