[PATCH] D30684: [libFuzzer] Don't use same seed for all parallel jobs
Vitaly Buka via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Tue Mar 7 01:20:23 PST 2017
vitalybuka created this revision.
If booth -seed and -jobs are set we could set deterministic but unique seed for
each jobs by combining input seed with a job number.
https://reviews.llvm.org/D30684
Files:
lib/Fuzzer/FuzzerDriver.cpp
lib/Fuzzer/test/fuzzer-jobs.test
Index: lib/Fuzzer/test/fuzzer-jobs.test
===================================================================
--- lib/Fuzzer/test/fuzzer-jobs.test
+++ lib/Fuzzer/test/fuzzer-jobs.test
@@ -8,7 +8,7 @@
RUN: rm -f fuzz-{0,1}.log
# Start fuzzer and in parallel check that the output files
# that should be created exist.
-RUN: LLVMFuzzer-EmptyTest -max_total_time=4 -jobs=2 -workers=2 FuzzerJobsTestCORPUS > %t-fuzzer-jobs-test.log 2>&1 & export FUZZER_PID=$!
+RUN: LLVMFuzzer-EmptyTest -seed=127 -max_total_time=4 -jobs=2 -workers=2 FuzzerJobsTestCORPUS > %t-fuzzer-jobs-test.log 2>&1 & export FUZZER_PID=$!
# Wait a short while to give time for the child processes
# to start fuzzing
RUN: sleep 2
@@ -27,5 +27,8 @@
RUN: rm %t-fuzzer-jobs-test.log
RUN: cd ../
+CHECK-DAG: Seed: 127
+CHECK-DAG: Seed: 128
+
CHECK-DAG: Job 0 exited with exit code 0
CHECK-DAG: Job 1 exited with exit code 0
Index: lib/Fuzzer/FuzzerDriver.cpp
===================================================================
--- lib/Fuzzer/FuzzerDriver.cpp
+++ lib/Fuzzer/FuzzerDriver.cpp
@@ -206,8 +206,11 @@
while (true) {
unsigned C = (*Counter)++;
if (C >= NumJobs) break;
+ std::string Seed;
+ if (Flags.seed)
+ Seed = "-seed=" + std::to_string(C + Flags.seed);
std::string Log = "fuzz-" + std::to_string(C) + ".log";
- std::string ToRun = Cmd + " > " + Log + " 2>&1\n";
+ std::string ToRun = Cmd + " " + Seed + " > " + Log + " 2>&1\n";
if (Flags.verbosity)
Printf("%s", ToRun.c_str());
int ExitCode = ExecuteCommand(ToRun);
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D30684.90815.patch
Type: text/x-patch
Size: 1555 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20170307/f4ac084f/attachment.bin>
More information about the llvm-commits
mailing list