fix style

This commit is contained in:
Yakov Olkhovskiy 2024-10-16 21:39:03 +00:00
parent f5a99dde86
commit ae71f1070f

View File

@ -122,7 +122,7 @@ def run_fuzzer(fuzzer: str, timeout: int):
custom_libfuzzer_options = " ".join(
f"-{key}={value}"
for key, value in parser["libfuzzer"].items()
if key != "jobs" and key != "exact_artifact_path"
if key not in ('jobs', 'exact_artifact_path')
)
if parser.has_section("fuzzer_arguments"):
@ -153,9 +153,10 @@ def run_fuzzer(fuzzer: str, timeout: int):
stopwatch = Stopwatch()
try:
with open(out_path, "wb") as out:
result = subprocess.run(
cmd_line,
stderr=open(out_path, "w"),
stderr=out,
stdout=subprocess.DEVNULL,
text=True,
check=True,
@ -166,19 +167,25 @@ def run_fuzzer(fuzzer: str, timeout: int):
except subprocess.CalledProcessError as e:
# print("Command failed with error:", e)
logging.info("Stderr output: %s", e.stderr)
with open(status_path, "w") as status:
status.write(f"FAIL\n{stopwatch.start_time_str}\n{stopwatch.duration_seconds}\n")
with open(status_path, "wb") as status:
status.write(
f"FAIL\n{stopwatch.start_time_str}\n{stopwatch.duration_seconds}\n"
)
except subprocess.TimeoutExpired as e:
logging.info("Timeout for %s", cmd_line)
kill_fuzzer(fuzzer)
sleep(10)
process_fuzzer_output(e.stderr)
with open(status_path,"w") as status:
status.write(f"Timeout\n{stopwatch.start_time_str}\n{stopwatch.duration_seconds}\n")
with open(status_path,"wb") as status:
status.write(
f"Timeout\n{stopwatch.start_time_str}\n{stopwatch.duration_seconds}\n"
)
else:
process_fuzzer_output(result.stderr)
with open(status_path,"w") as status:
status.write(f"OK\n{stopwatch.start_time_str}\n{stopwatch.duration_seconds}\n")
with open(status_path,"wb") as status:
status.write(
f"OK\n{stopwatch.start_time_str}\n{stopwatch.duration_seconds}\n"
)
s3.upload_build_directory_to_s3(
Path(new_corpus_dir), f"fuzzer/corpus/{fuzzer}", False