]> granicus.if.org Git - llvm/commitdiff
[libFuzzer] exit(1) on failed merge
authorKostya Serebryany <kcc@google.com>
Wed, 18 Jan 2017 00:55:29 +0000 (00:55 +0000)
committerKostya Serebryany <kcc@google.com>
Wed, 18 Jan 2017 00:55:29 +0000 (00:55 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@292319 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Fuzzer/FuzzerMerge.cpp
lib/Fuzzer/test/merge.test

index 9e559115680ccef8de856beaf046788f464a8fa3..344d7a83959377b764da366e6cca2622c93a3cca 100644 (file)
@@ -239,15 +239,21 @@ void Fuzzer::CrashResistantMerge(const std::vector<std::string> &Args,
   // Execute the inner process untill it passes.
   // Every inner process should execute at least one input.
   std::string BaseCmd = CloneArgsWithoutX(Args, "keep-all-flags");
+  bool Success = false;
   for (size_t i = 1; i <= AllFiles.size(); i++) {
     Printf("MERGE-OUTER: attempt %zd\n", i);
     auto ExitCode =
         ExecuteCommand(BaseCmd + " -merge_control_file=" + CFPath);
     if (!ExitCode) {
       Printf("MERGE-OUTER: succesfull in %zd attempt(s)\n", i);
+      Success = true;
       break;
     }
   }
+  if (!Success) {
+    Printf("MERGE-OUTER: zero succesfull attempts, exiting\n");
+    exit(1);
+  }
   // Read the control file and do the merge.
   Merger M;
   std::ifstream IF(CFPath);
index 5c7d30e41caa8db309b9d04c302c4f99576c4a60..e1445c2b4c1700b78591939439736c72de16965f 100644 (file)
@@ -52,3 +52,7 @@ TMPDIR: MERGE-OUTER: failed to write to the control file: DIR_DOES_NOT_EXIST/lib
 # Check that we can report an error if file size exceeded
 RUN: (ulimit -f 1; not LLVMFuzzer-FullCoverageSetTest -merge=1 %tmp/T1 %tmp/T2 2>&1 | FileCheck %s --check-prefix=SIGXFSZ)
 SIGXFSZ: ERROR: libFuzzer: file size exceeded
+
+RUN: rm -rf  %tmp/T1/* %tmp/T2/*
+RUN: not LLVMFuzzer-FullCoverageSetTest -merge=1 %tmp/T1 %tmp/T2 2>&1 | FileCheck %s --check-prefix=EMPTY
+EMPTY: MERGE-OUTER: zero succesfull attempts, exiting