Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Simplify generate_input #24

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter...
Filter file types
Jump to…
Jump to file
Failed to load files.

Always

Just for now

@@ -27,10 +27,13 @@ def __init__(self, dirs=None, max_input_size=4096):
fname = os.path.join(path, i)
if os.path.isfile(fname):
self._add_file(fname)
if not self._inputs:
self.put(bytearray(0))
self._seed_run_finished = not self._inputs
self._seed_idx = 0
self._save_corpus = dirs and os.path.isdir(dirs[0])


def _add_file(self, path):
with open(path, 'rb') as f:
self._inputs.append(bytearray(f.read()))
@@ -92,13 +95,8 @@ def generate_input(self):
self._seed_run_finished = True
return next_input

if len(self._inputs) == 0:
zero_test_case = bytearray(0)
self.put(zero_test_case)
return zero_test_case
else:
buf = self._inputs[self._rand(len(self._inputs))]
return self.mutate(buf)
buf = self._inputs[self._rand(len(self._inputs))]
return self.mutate(buf)

def mutate(self, buf):
res = buf[:]
ProTip! Use n and p to navigate between commits in a pull request.
You can’t perform that action at this time.