[compiler-rt] r354088 - [libFuzzer] fix the unit tests

Kostya Serebryany via llvm-commits llvm-commits at lists.llvm.org
Thu Feb 14 16:15:13 PST 2019


Author: kcc
Date: Thu Feb 14 16:15:13 2019
New Revision: 354088

URL: http://llvm.org/viewvc/llvm-project?rev=354088&view=rev
Log:
[libFuzzer] fix the unit tests

Modified:
    compiler-rt/trunk/lib/fuzzer/FuzzerMerge.cpp
    compiler-rt/trunk/lib/fuzzer/FuzzerMerge.h
    compiler-rt/trunk/lib/fuzzer/tests/FuzzerUnittest.cpp

Modified: compiler-rt/trunk/lib/fuzzer/FuzzerMerge.cpp
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/fuzzer/FuzzerMerge.cpp?rev=354088&r1=354087&r2=354088&view=diff
==============================================================================
--- compiler-rt/trunk/lib/fuzzer/FuzzerMerge.cpp (original)
+++ compiler-rt/trunk/lib/fuzzer/FuzzerMerge.cpp Thu Feb 14 16:15:13 2019
@@ -131,9 +131,10 @@ size_t Merger::ApproximateMemoryConsumpt
 
 // Decides which files need to be merged (add those to NewFiles).
 // Returns the number of new features added.
-void Merger::Merge(const Set<uint32_t> &InitialFeatures,
-                   Set<uint32_t> *NewFeatures, const Set<uint32_t> &InitialCov,
-                   Set<uint32_t> *NewCov, Vector<std::string> *NewFiles) {
+size_t Merger::Merge(const Set<uint32_t> &InitialFeatures,
+                     Set<uint32_t> *NewFeatures,
+                     const Set<uint32_t> &InitialCov, Set<uint32_t> *NewCov,
+                     Vector<std::string> *NewFiles) {
   NewFiles->clear();
   assert(NumFilesInFirstCorpus <= Files.size());
   Set<uint32_t> AllFeatures = InitialFeatures;
@@ -181,6 +182,7 @@ void Merger::Merge(const Set<uint32_t> &
       if (InitialCov.find(Cov) == InitialCov.end())
         NewCov->insert(Cov);
   }
+  return NewFeatures->size();
 }
 
 Set<uint32_t> Merger::AllFeatures() const {

Modified: compiler-rt/trunk/lib/fuzzer/FuzzerMerge.h
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/fuzzer/FuzzerMerge.h?rev=354088&r1=354087&r2=354088&view=diff
==============================================================================
--- compiler-rt/trunk/lib/fuzzer/FuzzerMerge.h (original)
+++ compiler-rt/trunk/lib/fuzzer/FuzzerMerge.h Thu Feb 14 16:15:13 2019
@@ -63,9 +63,9 @@ struct Merger {
   bool Parse(std::istream &IS, bool ParseCoverage);
   bool Parse(const std::string &Str, bool ParseCoverage);
   void ParseOrExit(std::istream &IS, bool ParseCoverage);
-  void Merge(const Set<uint32_t> &InitialFeatures, Set<uint32_t> *NewFeatures,
-             const Set<uint32_t> &InitialCov, Set<uint32_t> *NewCov,
-             Vector<std::string> *NewFiles);
+  size_t Merge(const Set<uint32_t> &InitialFeatures, Set<uint32_t> *NewFeatures,
+               const Set<uint32_t> &InitialCov, Set<uint32_t> *NewCov,
+               Vector<std::string> *NewFiles);
   size_t ApproximateMemoryConsumption() const;
   Set<uint32_t> AllFeatures() const;
 };

Modified: compiler-rt/trunk/lib/fuzzer/tests/FuzzerUnittest.cpp
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/fuzzer/tests/FuzzerUnittest.cpp?rev=354088&r1=354087&r2=354088&view=diff
==============================================================================
--- compiler-rt/trunk/lib/fuzzer/tests/FuzzerUnittest.cpp (original)
+++ compiler-rt/trunk/lib/fuzzer/tests/FuzzerUnittest.cpp Thu Feb 14 16:15:13 2019
@@ -644,9 +644,9 @@ static void Merge(const std::string &Inp
                   size_t NumNewFeatures) {
   Merger M;
   Vector<std::string> NewFiles;
-  Set<uint32_t> NewFeatures;
+  Set<uint32_t> NewFeatures, NewCov;
   EXPECT_TRUE(M.Parse(Input, true));
-  EXPECT_EQ(NumNewFeatures, M.Merge({}, &NewFeatures, &NewFiles));
+  EXPECT_EQ(NumNewFeatures, M.Merge({}, &NewFeatures, {}, &NewCov, &NewFiles));
   EQ(NewFiles, Result);
 }
 
@@ -690,7 +690,7 @@ TEST(Merge, Good) {
 
 
   Vector<std::string> NewFiles;
-  Set<uint32_t> NewFeatures;
+  Set<uint32_t> NewFeatures, NewCov;
 
   EXPECT_TRUE(M.Parse("3\n2\nAA\nBB\nC\n"
                         "STARTED 0 1000\nFT 0 1 2 3\n"
@@ -704,7 +704,7 @@ TEST(Merge, Good) {
   EQ(M.Files[0].Features, {1, 2, 3});
   EQ(M.Files[1].Features, {4, 5, 6});
   EQ(M.Files[2].Features, {1, 3, 6});
-  EXPECT_EQ(0U, M.Merge({}, &NewFeatures, &NewFiles));
+  EXPECT_EQ(0U, M.Merge({}, &NewFeatures, {}, &NewCov, &NewFiles));
   EQ(NewFiles, {});
 
   EXPECT_TRUE(M.Parse("3\n1\nA\nB\nC\n"
@@ -715,7 +715,7 @@ TEST(Merge, Good) {
   EQ(M.Files[0].Features, {1, 2, 3});
   EQ(M.Files[1].Features, {4, 5, 6});
   EQ(M.Files[2].Features, {1, 3, 6});
-  EXPECT_EQ(3U, M.Merge({}, &NewFeatures, &NewFiles));
+  EXPECT_EQ(3U, M.Merge({}, &NewFeatures, {}, &NewCov, &NewFiles));
   EQ(NewFiles, {"B"});
 
   // Same as the above, but with InitialFeatures.
@@ -729,7 +729,7 @@ TEST(Merge, Good) {
   InitialFeatures.insert(1);
   InitialFeatures.insert(2);
   InitialFeatures.insert(3);
-  EXPECT_EQ(3U, M.Merge(InitialFeatures, &NewFeatures, &NewFiles));
+  EXPECT_EQ(3U, M.Merge(InitialFeatures, &NewFeatures, {}, &NewCov, &NewFiles));
   EQ(NewFiles, {"B"});
 }
 




More information about the llvm-commits mailing list