N=100; M=4; ./pcre_fuzzer ./CORPUS -jobs=$N -workers=$M
-This is useful when you already have an exhaustive test corpus.
-If you've just started fuzzing with no good corpus running independent
-jobs will create a corpus with too many duplicates.
-One way to avoid this and still use all of your CPUs is to use the flag ``-exit_on_first=1``
-which will cause the fuzzer to exit on the first new synthesised input::
+By default (``-reload=1``) the fuzzer processes will periodically scan the CORPUS directory
+and reload any new tests. This way the test inputs found by one process will be picked up
+by all others.
- N=100; M=4; ./pcre_fuzzer ./CORPUS -jobs=$N -workers=$M -exit_on_first=1
+If ``-workers=$M`` is not supplied, ``min($N,NumberOfCpuCore/2)`` will be used.
Heartbleed
----------
return 0;
}
+ if (Flags.jobs > 0 && Flags.workers == 0) {
+ Flags.workers = std::min(NumberOfCpuCores() / 2, Flags.jobs);
+ if (Flags.workers > 1)
+ std::cerr << "Running " << Flags.workers << " workers\n";
+ }
+
if (Flags.workers > 0 && Flags.jobs > 0)
return RunInMultipleProcesses(argc, argv, Flags.workers, Flags.jobs);
" this number of jobs in separate worker processes"
" with stdout/stderr redirected to fuzz-JOB.log.")
FUZZER_FLAG_INT(workers, 0,
- "Number of simultaneous worker processes to run the jobs.")
+ "Number of simultaneous worker processes to run the jobs."
+ " If zero, \"min(jobs,NumberOfCpuCores()/2)\" is used.")
FUZZER_FLAG_INT(reload, 1,
"Reload the main corpus periodically to get new units"
"discovered by other processes.")
void SetTimer(int Seconds);
void PrintFileAsBase64(const std::string &Path);
+int NumberOfCpuCores();
+
class Fuzzer {
public:
struct FuzzingOptions {
assert(Res == 0);
}
+int NumberOfCpuCores() {
+ FILE *F = popen("nproc", "r");
+ int N = 0;
+ fscanf(F, "%d", &N);
+ fclose(F);
+ return N;
+}
+
} // namespace fuzzer