Skip to content

Commit

Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fuzzer: add a cargo-bolero fuzz target type
Browse files Browse the repository at this point in the history
Ekleog committed Jul 19, 2022
1 parent 379f983 commit cbf37bd
Showing 1 changed file with 35 additions and 17 deletions.
52 changes: 35 additions & 17 deletions fuzzers/main.py
Original file line number Diff line number Diff line change
@@ -503,23 +503,41 @@ def start(self, corpus: Corpus) -> None:
# Spin up the fuzzer process itself
# libfuzzer will kill the process if it takes more than -timeout number of seconds.
# nayduck can sigstop the fuzzing process for ~2 hours at most, so 8000s should be ok.
self.proc = subprocess.Popen( # pylint: disable=consider-using-with
[
'cargo',
'fuzz',
'run',
self.target['runner'],
'--',
str(corpus.corpus_for(self.target)),
str(corpus.artifacts_for(self.target)),
f'-artifact_prefix={corpus.artifacts_for(self.target)}/',
'-timeout=8000',
] + self.target['flags'],
cwd=self.repo_dir / self.target['crate'],
start_new_session=True,
stdout=self.log_file,
stderr=subprocess.STDOUT,
)
flags = [
str(corpus.corpus_for(self.target)),
str(corpus.artifacts_for(self.target)),
f'-artifact_prefix={corpus.artifacts_for(self.target)}/',
'-timeout=8000',
] + self.target['flags']
if self.target['type'] == 'bolero':
self.proc = subprocess.Popen(
[
'cargo',
'bolero',
'test',
'-p',
self.target['crate'],
self.target['runner'],
] + map(lambda flag: f'--engine-args="{flag}"', flags),
cwd = self.repo_dir,
start_new_session = True,
stdout = self.log_file,
stderr = subprocess.STDOUT,
)
else:
self.proc = subprocess.Popen( # pylint: disable=consider-using-with
[
'cargo',
'fuzz',
'run',
self.target['runner'],
'--',
] + flags,
cwd=self.repo_dir / self.target['crate'],
start_new_session=True,
stdout=self.log_file,
stderr=subprocess.STDOUT,
)

def check_if_crashed(self) -> bool:
"""Checks if the current process has crashed. Returns True if it stopped.

0 comments on commit cbf37bd

Please sign in to comment.