[libFuzzer] exit(1) on failed merge

llvm-svn: 292319
This commit is contained in:
Kostya Serebryany 2017-01-18 00:55:29 +00:00
parent 924978bb43
commit 9d0f02af3d
2 changed files with 10 additions and 0 deletions

View 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);

View 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