[libFuzzer] make -test_single_input more reliable: make sure the input's size is...
[oota-llvm.git] / lib / Fuzzer / FuzzerDriver.cpp
index 4543d81cb1e9acbccf7e8fbc0c338011477624e1..363abc482cbba6fad1e019961ee5ef29401db05b 100644 (file)
@@ -184,7 +184,9 @@ static int RunInMultipleProcesses(const std::vector<std::string> &Args,
 
 int RunOneTest(Fuzzer *F, const char *InputFilePath) {
   Unit U = FileToVector(InputFilePath);
-  F->ExecuteCallback(U);
+  Unit PreciseSizedU(U);
+  assert(PreciseSizedU.size() == PreciseSizedU.capacity());
+  F->ExecuteCallback(PreciseSizedU);
   return 0;
 }
 
@@ -234,6 +236,7 @@ int FuzzerDriver(const std::vector<std::string> &Args,
   Options.MutateDepth = Flags.mutate_depth;
   Options.ExitOnFirst = Flags.exit_on_first;
   Options.UseCounters = Flags.use_counters;
+  Options.UseIndirCalls = Flags.use_indir_calls;
   Options.UseTraces = Flags.use_traces;
   Options.ShuffleAtStartUp = Flags.shuffle;
   Options.PreferSmallDuringInitialShuffle =
@@ -268,6 +271,11 @@ int FuzzerDriver(const std::vector<std::string> &Args,
   if (Flags.test_single_input)
     return RunOneTest(&F, Flags.test_single_input);
 
+  if (Flags.merge) {
+    F.Merge(*Inputs);
+    exit(0);
+  }
+
   unsigned Seed = Flags.seed;
   // Initialize Seed.
   if (Seed == 0)