aboutsummaryrefslogtreecommitdiffstats
path: root/src/scripts
diff options
context:
space:
mode:
authorJack Lloyd <[email protected]>2020-11-08 09:39:55 -0500
committerJack Lloyd <[email protected]>2020-11-08 09:39:55 -0500
commitf35d437245fa4522734511d5e54172e1d385a94b (patch)
treec49a581323c485c5f05538e301122b9b9f1ae32f /src/scripts
parent45f1a79bcd051ea8eeda66b96edf3f7163e38b4b (diff)
Test fuzzers without a corpus using a randomly generated one
Diffstat (limited to 'src/scripts')
-rwxr-xr-xsrc/scripts/test_fuzzers.py19
1 files changed, 17 insertions, 2 deletions
diff --git a/src/scripts/test_fuzzers.py b/src/scripts/test_fuzzers.py
index 01c202f23..9ea3c378b 100755
--- a/src/scripts/test_fuzzers.py
+++ b/src/scripts/test_fuzzers.py
@@ -9,6 +9,7 @@ import optparse # pylint: disable=deprecated-module
import stat
import multiprocessing
import time
+import tempfile
def run_fuzzer_gdb(args):
(fuzzer_bin, corpus_file) = args
@@ -151,9 +152,23 @@ def main(args=None):
crash_count = 0
sys.stdout.flush()
else:
- for fuzzer in sorted(list(fuzzers_with_corpus)):
+ # Generate a random corpus for fuzzers without a corpus
+ random_corpus_dir = tempfile.mkdtemp(prefix='fuzzer_corpus_')
+
+ for i in range(100):
+ random_input = os.urandom(i)
+ fd = open(os.path.join(random_corpus_dir, 'input_%d' % (i)), 'wb')
+ fd.write(random_input)
+ fd.close()
+
+ for fuzzer in sorted(list(fuzzers)):
fuzzer_bin = os.path.join(fuzzer_dir, fuzzer)
- corpus_subdir = os.path.join(corpus_dir, fuzzer)
+
+ if fuzzer in fuzzers_with_corpus:
+ corpus_subdir = os.path.join(corpus_dir, fuzzer)
+ else:
+ corpus_subdir = random_corpus_dir
+
corpus_files = [os.path.join(corpus_subdir, l) for l in sorted(list(os.listdir(corpus_subdir)))]
start = time.time()