forked from OSchip/llvm-project
				
			[libFuzzer] remove two unused experimental flags
llvm-svn: 353573
This commit is contained in:
		
							parent
							
								
									3edf63c55a
								
							
						
					
					
						commit
						b1e8b8149b
					
				| 
						 | 
					@ -478,8 +478,7 @@ void FuzzWithFork(const FuzzingOptions &Options,
 | 
				
			||||||
  auto CFPath = TempPath(".fork");
 | 
					  auto CFPath = TempPath(".fork");
 | 
				
			||||||
  Printf("INFO: -fork=1: doing fuzzing in a separate process in order to "
 | 
					  Printf("INFO: -fork=1: doing fuzzing in a separate process in order to "
 | 
				
			||||||
         "be more resistant to crashes, timeouts, and OOMs\n");
 | 
					         "be more resistant to crashes, timeouts, and OOMs\n");
 | 
				
			||||||
  auto Files =
 | 
					  auto Files = CrashResistantMerge(Args, Corpora, CFPath);
 | 
				
			||||||
      CrashResistantMerge(Args, Corpora, CFPath, nullptr, nullptr);
 | 
					 | 
				
			||||||
  Printf("INFO: -fork=1: seed corpus analyzed, %zd seeds chosen, starting to "
 | 
					  Printf("INFO: -fork=1: seed corpus analyzed, %zd seeds chosen, starting to "
 | 
				
			||||||
         "fuzz in separate processes\n", Files.size());
 | 
					         "fuzz in separate processes\n", Files.size());
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -738,9 +737,7 @@ int FuzzerDriver(int *argc, char ***argv, UserCallback Callback) {
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
    std::string CFPath =
 | 
					    std::string CFPath =
 | 
				
			||||||
        Flags.merge_control_file ? Flags.merge_control_file : TempPath(".txt");
 | 
					        Flags.merge_control_file ? Flags.merge_control_file : TempPath(".txt");
 | 
				
			||||||
    auto Files =
 | 
					    auto Files = CrashResistantMerge(Args, *Inputs, CFPath);
 | 
				
			||||||
        CrashResistantMerge(Args, *Inputs, CFPath, Flags.load_coverage_summary,
 | 
					 | 
				
			||||||
                            Flags.save_coverage_summary);
 | 
					 | 
				
			||||||
    for (auto &Path : Files)
 | 
					    for (auto &Path : Files)
 | 
				
			||||||
      F->WriteToOutputCorpus(FileToVector(Path, Options.MaxLen));
 | 
					      F->WriteToOutputCorpus(FileToVector(Path, Options.MaxLen));
 | 
				
			||||||
    // We are done, delete the control file if it was a temporary one.
 | 
					    // We are done, delete the control file if it was a temporary one.
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -52,13 +52,6 @@ FUZZER_FLAG_STRING(merge_control_file,
 | 
				
			||||||
                   "If a merge process gets killed it tries to leave this file "
 | 
					                   "If a merge process gets killed it tries to leave this file "
 | 
				
			||||||
                   "in a state suitable for resuming the merge. "
 | 
					                   "in a state suitable for resuming the merge. "
 | 
				
			||||||
                   "By default a temporary file will be used.")
 | 
					                   "By default a temporary file will be used.")
 | 
				
			||||||
FUZZER_FLAG_STRING(save_coverage_summary, "Experimental:"
 | 
					 | 
				
			||||||
                   " save coverage summary to a given file."
 | 
					 | 
				
			||||||
                   " Used with -merge=1")
 | 
					 | 
				
			||||||
FUZZER_FLAG_STRING(load_coverage_summary, "Experimental:"
 | 
					 | 
				
			||||||
                   " load coverage summary from a given file."
 | 
					 | 
				
			||||||
                   " Treat this coverage as belonging to the first corpus. "
 | 
					 | 
				
			||||||
                   " Used with -merge=1")
 | 
					 | 
				
			||||||
FUZZER_FLAG_INT(minimize_crash, 0, "If 1, minimizes the provided"
 | 
					FUZZER_FLAG_INT(minimize_crash, 0, "If 1, minimizes the provided"
 | 
				
			||||||
  " crash input. Use with -runs=N or -max_total_time=N to limit "
 | 
					  " crash input. Use with -runs=N or -max_total_time=N to limit "
 | 
				
			||||||
  "the number attempts."
 | 
					  "the number attempts."
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -168,16 +168,6 @@ size_t Merger::Merge(const Set<uint32_t> &InitialFeatures,
 | 
				
			||||||
  return AllFeatures.size() - InitialNumFeatures;
 | 
					  return AllFeatures.size() - InitialNumFeatures;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
void Merger::PrintSummary(std::ostream &OS) {
 | 
					 | 
				
			||||||
  for (auto &File : Files) {
 | 
					 | 
				
			||||||
    OS << std::hex;
 | 
					 | 
				
			||||||
    OS << File.Name << " size: " << File.Size << " features: ";
 | 
					 | 
				
			||||||
    for (auto Feature : File.Features)
 | 
					 | 
				
			||||||
      OS << " " << Feature;
 | 
					 | 
				
			||||||
    OS << "\n";
 | 
					 | 
				
			||||||
  }
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
Set<uint32_t> Merger::AllFeatures() const {
 | 
					Set<uint32_t> Merger::AllFeatures() const {
 | 
				
			||||||
  Set<uint32_t> S;
 | 
					  Set<uint32_t> S;
 | 
				
			||||||
  for (auto &File : Files)
 | 
					  for (auto &File : Files)
 | 
				
			||||||
| 
						 | 
					@ -185,25 +175,6 @@ Set<uint32_t> Merger::AllFeatures() const {
 | 
				
			||||||
  return S;
 | 
					  return S;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
Set<uint32_t> Merger::ParseSummary(std::istream &IS) {
 | 
					 | 
				
			||||||
  std::string Line, Tmp;
 | 
					 | 
				
			||||||
  Set<uint32_t> Res;
 | 
					 | 
				
			||||||
  while (std::getline(IS, Line, '\n')) {
 | 
					 | 
				
			||||||
    size_t N;
 | 
					 | 
				
			||||||
    std::istringstream ISS1(Line);
 | 
					 | 
				
			||||||
    ISS1 >> Tmp;  // Name
 | 
					 | 
				
			||||||
    ISS1 >> Tmp;  // size:
 | 
					 | 
				
			||||||
    assert(Tmp == "size:" && "Corrupt summary file");
 | 
					 | 
				
			||||||
    ISS1 >> std::hex;
 | 
					 | 
				
			||||||
    ISS1 >> N;    // File Size
 | 
					 | 
				
			||||||
    ISS1 >> Tmp;  // features:
 | 
					 | 
				
			||||||
    assert(Tmp == "features:" && "Corrupt summary file");
 | 
					 | 
				
			||||||
    while (ISS1 >> std::hex >> N)
 | 
					 | 
				
			||||||
      Res.insert(N);
 | 
					 | 
				
			||||||
  }
 | 
					 | 
				
			||||||
  return Res;
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
// Inner process. May crash if the target crashes.
 | 
					// Inner process. May crash if the target crashes.
 | 
				
			||||||
void Fuzzer::CrashResistantMergeInternalStep(const std::string &CFPath) {
 | 
					void Fuzzer::CrashResistantMergeInternalStep(const std::string &CFPath) {
 | 
				
			||||||
  Printf("MERGE-INNER: using the control file '%s'\n", CFPath.c_str());
 | 
					  Printf("MERGE-INNER: using the control file '%s'\n", CFPath.c_str());
 | 
				
			||||||
| 
						 | 
					@ -278,9 +249,7 @@ static void WriteNewControlFile(const std::string &CFPath,
 | 
				
			||||||
Vector<std::string>
 | 
					Vector<std::string>
 | 
				
			||||||
CrashResistantMerge(const Vector<std::string> &Args,
 | 
					CrashResistantMerge(const Vector<std::string> &Args,
 | 
				
			||||||
                    const Vector<std::string> &Corpora,
 | 
					                    const Vector<std::string> &Corpora,
 | 
				
			||||||
                    const std::string &CFPath,
 | 
					                    const std::string &CFPath) {
 | 
				
			||||||
                    const char *CoverageSummaryInputPathOrNull,
 | 
					 | 
				
			||||||
                    const char *CoverageSummaryOutputPathOrNull) {
 | 
					 | 
				
			||||||
  size_t NumAttempts = 0;
 | 
					  size_t NumAttempts = 0;
 | 
				
			||||||
  if (FileSize(CFPath)) {
 | 
					  if (FileSize(CFPath)) {
 | 
				
			||||||
    Printf("MERGE-OUTER: non-empty control file provided: '%s'\n",
 | 
					    Printf("MERGE-OUTER: non-empty control file provided: '%s'\n",
 | 
				
			||||||
| 
						 | 
					@ -354,19 +323,7 @@ CrashResistantMerge(const Vector<std::string> &Args,
 | 
				
			||||||
  IF.close();
 | 
					  IF.close();
 | 
				
			||||||
  Printf("MERGE-OUTER: consumed %zdMb (%zdMb rss) to parse the control file\n",
 | 
					  Printf("MERGE-OUTER: consumed %zdMb (%zdMb rss) to parse the control file\n",
 | 
				
			||||||
         M.ApproximateMemoryConsumption() >> 20, GetPeakRSSMb());
 | 
					         M.ApproximateMemoryConsumption() >> 20, GetPeakRSSMb());
 | 
				
			||||||
  if (CoverageSummaryOutputPathOrNull) {
 | 
					 | 
				
			||||||
    Printf("MERGE-OUTER: writing coverage summary for %zd files to %s\n",
 | 
					 | 
				
			||||||
           M.Files.size(), CoverageSummaryOutputPathOrNull);
 | 
					 | 
				
			||||||
    std::ofstream SummaryOut(CoverageSummaryOutputPathOrNull);
 | 
					 | 
				
			||||||
    M.PrintSummary(SummaryOut);
 | 
					 | 
				
			||||||
  }
 | 
					 | 
				
			||||||
  Set<uint32_t> InitialFeatures;
 | 
					  Set<uint32_t> InitialFeatures;
 | 
				
			||||||
  if (CoverageSummaryInputPathOrNull) {
 | 
					 | 
				
			||||||
    std::ifstream SummaryIn(CoverageSummaryInputPathOrNull);
 | 
					 | 
				
			||||||
    InitialFeatures = M.ParseSummary(SummaryIn);
 | 
					 | 
				
			||||||
    Printf("MERGE-OUTER: coverage summary loaded from %s, %zd features found\n",
 | 
					 | 
				
			||||||
           CoverageSummaryInputPathOrNull, InitialFeatures.size());
 | 
					 | 
				
			||||||
  }
 | 
					 | 
				
			||||||
  Vector<std::string> NewFiles;
 | 
					  Vector<std::string> NewFiles;
 | 
				
			||||||
  size_t NumNewFeatures = M.Merge(InitialFeatures, &NewFiles);
 | 
					  size_t NumNewFeatures = M.Merge(InitialFeatures, &NewFiles);
 | 
				
			||||||
  Printf("MERGE-OUTER: %zd new files with %zd new features added\n",
 | 
					  Printf("MERGE-OUTER: %zd new files with %zd new features added\n",
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -63,8 +63,6 @@ struct Merger {
 | 
				
			||||||
  bool Parse(std::istream &IS, bool ParseCoverage);
 | 
					  bool Parse(std::istream &IS, bool ParseCoverage);
 | 
				
			||||||
  bool Parse(const std::string &Str, bool ParseCoverage);
 | 
					  bool Parse(const std::string &Str, bool ParseCoverage);
 | 
				
			||||||
  void ParseOrExit(std::istream &IS, bool ParseCoverage);
 | 
					  void ParseOrExit(std::istream &IS, bool ParseCoverage);
 | 
				
			||||||
  void PrintSummary(std::ostream &OS);
 | 
					 | 
				
			||||||
  Set<uint32_t> ParseSummary(std::istream &IS);
 | 
					 | 
				
			||||||
  size_t Merge(const Set<uint32_t> &InitialFeatures,
 | 
					  size_t Merge(const Set<uint32_t> &InitialFeatures,
 | 
				
			||||||
               Vector<std::string> *NewFiles);
 | 
					               Vector<std::string> *NewFiles);
 | 
				
			||||||
  size_t ApproximateMemoryConsumption() const;
 | 
					  size_t ApproximateMemoryConsumption() const;
 | 
				
			||||||
| 
						 | 
					@ -74,9 +72,7 @@ struct Merger {
 | 
				
			||||||
Vector<std::string>
 | 
					Vector<std::string>
 | 
				
			||||||
CrashResistantMerge(const Vector<std::string> &Args,
 | 
					CrashResistantMerge(const Vector<std::string> &Args,
 | 
				
			||||||
                    const Vector<std::string> &Corpora,
 | 
					                    const Vector<std::string> &Corpora,
 | 
				
			||||||
                    const std::string &CFPath,
 | 
					                    const std::string &CFPath);
 | 
				
			||||||
                    const char *CoverageSummaryInputPathOrNull,
 | 
					 | 
				
			||||||
                    const char *CoverageSummaryOutputPathOrNull);
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
}  // namespace fuzzer
 | 
					}  // namespace fuzzer
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -645,10 +645,7 @@ static void Merge(const std::string &Input,
 | 
				
			||||||
  Merger M;
 | 
					  Merger M;
 | 
				
			||||||
  Vector<std::string> NewFiles;
 | 
					  Vector<std::string> NewFiles;
 | 
				
			||||||
  EXPECT_TRUE(M.Parse(Input, true));
 | 
					  EXPECT_TRUE(M.Parse(Input, true));
 | 
				
			||||||
  std::stringstream SS;
 | 
					 | 
				
			||||||
  M.PrintSummary(SS);
 | 
					 | 
				
			||||||
  EXPECT_EQ(NumNewFeatures, M.Merge({}, &NewFiles));
 | 
					  EXPECT_EQ(NumNewFeatures, M.Merge({}, &NewFiles));
 | 
				
			||||||
  EXPECT_EQ(M.AllFeatures(), M.ParseSummary(SS));
 | 
					 | 
				
			||||||
  EQ(NewFiles, Result);
 | 
					  EQ(NewFiles, Result);
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -28,16 +28,6 @@ RUN: %run %t/T.exe -merge=1 %t/T1 %t/T2 -merge_control_file=%t/MCF 2>&1 | FileCh
 | 
				
			||||||
OK_0: MERGE-OUTER: control file ok, 3 files total, first not processed file 0
 | 
					OK_0: MERGE-OUTER: control file ok, 3 files total, first not processed file 0
 | 
				
			||||||
OK_0: MERGE-OUTER: 3 new files with {{.*}} new features added
 | 
					OK_0: MERGE-OUTER: 3 new files with {{.*}} new features added
 | 
				
			||||||
 | 
					
 | 
				
			||||||
RUN: rm -f %t/T1/*; cp %t/T0/* %t/T1
 | 
					 | 
				
			||||||
RUN: echo 3 > %t/MCF; echo 0 >> %t/MCF; echo %t/T1/1 >> %t/MCF; echo %t/T1/2 >> %t/MCF; echo %t/T1/3 >> %t/MCF
 | 
					 | 
				
			||||||
RUN: %run %t/T.exe -merge=1 %t/T1 %t/T2 -merge_control_file=%t/MCF -save_coverage_summary=%t/SUMMARY 2>&1 | FileCheck %s --check-prefix=SAVE_SUMMARY
 | 
					 | 
				
			||||||
SAVE_SUMMARY: MERGE-OUTER: writing coverage summary for 3 files to {{.*}}/SUMMARY
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
RUN: rm -f %t/T1/*; cp %t/T0/* %t/T1
 | 
					 | 
				
			||||||
RUN: echo 3 > %t/MCF; echo 0 >> %t/MCF; echo %t/T1/1 >> %t/MCF; echo %t/T1/2 >> %t/MCF; echo %t/T1/3 >> %t/MCF
 | 
					 | 
				
			||||||
RUN: %run %t/T.exe -merge=1 %t/T1 %t/T2 -merge_control_file=%t/MCF -load_coverage_summary=%t/SUMMARY 2>&1 | FileCheck %s --check-prefix=LOAD_SUMMARY
 | 
					 | 
				
			||||||
LOAD_SUMMARY: MERGE-OUTER: coverage summary loaded from
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
RUN: rm -f %t/T1/*; cp %t/T0/* %t/T1
 | 
					RUN: rm -f %t/T1/*; cp %t/T0/* %t/T1
 | 
				
			||||||
RUN: echo 3 > %t/MCF; echo 0 >> %t/MCF; echo %t/T1/1 >> %t/MCF; echo %t/T1/2 >> %t/MCF; echo %t/T1/3 >> %t/MCF
 | 
					RUN: echo 3 > %t/MCF; echo 0 >> %t/MCF; echo %t/T1/1 >> %t/MCF; echo %t/T1/2 >> %t/MCF; echo %t/T1/3 >> %t/MCF
 | 
				
			||||||
RUN: echo STARTED 0 1 >> %t/MCF
 | 
					RUN: echo STARTED 0 1 >> %t/MCF
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -1,17 +0,0 @@
 | 
				
			||||||
RUN: %cpp_compiler %S/FullCoverageSetTest.cpp -o %t-FullCoverageSetTest
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
RUN: rm -rf %t/T1 %t/T2
 | 
					 | 
				
			||||||
RUN: mkdir -p %t/T0 %t/T1 %t/T2
 | 
					 | 
				
			||||||
RUN: echo ...Z.. > %t/T2/1
 | 
					 | 
				
			||||||
RUN: echo ....E. > %t/T2/2
 | 
					 | 
				
			||||||
RUN: echo .....R > %t/T2/3
 | 
					 | 
				
			||||||
RUN: echo F..... > %t/T2/a
 | 
					 | 
				
			||||||
RUN: echo .U.... > %t/T2/b
 | 
					 | 
				
			||||||
RUN: echo ..Z... > %t/T2/c
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
RUN: %run %t-FullCoverageSetTest -merge=1 %t/T1 %t/T2 -save_coverage_summary=%t/SUMMARY 2>&1 | FileCheck %s --check-prefix=SAVE_SUMMARY
 | 
					 | 
				
			||||||
SAVE_SUMMARY: MERGE-OUTER: writing coverage summary for 6 files to {{.*}}SUMMARY
 | 
					 | 
				
			||||||
RUN: rm %t/T1/*
 | 
					 | 
				
			||||||
RUN: %run %t-FullCoverageSetTest -merge=1 %t/T1 %t/T2 -load_coverage_summary=%t/SUMMARY 2>&1 | FileCheck %s --check-prefix=LOAD_SUMMARY
 | 
					 | 
				
			||||||
LOAD_SUMMARY: MERGE-OUTER: coverage summary loaded from {{.*}}SUMMAR
 | 
					 | 
				
			||||||
LOAD_SUMMARY: MERGE-OUTER: 0 new files with 0 new features added
 | 
					 | 
				
			||||||
		Loading…
	
		Reference in New Issue