better diagnostics

This commit is contained in:
Yakov Olkhovskiy 2024-10-22 15:22:59 +00:00
parent d1426886e3
commit 32be533290
2 changed files with 14 additions and 3 deletions

View File

@ -184,6 +184,7 @@ def process_results(result_path: Path):
file_path = file.parent / fuzzer file_path = file.parent / fuzzer
file_path_unit = file_path.with_suffix(".unit") file_path_unit = file_path.with_suffix(".unit")
file_path_out = file_path.with_suffix(".out") file_path_out = file_path.with_suffix(".out")
file_path_stdout = file_path.with_suffix(".stdout")
status = read_status(file) status = read_status(file)
result = TestResult(fuzzer, status[0], float(status[2])) result = TestResult(fuzzer, status[0], float(status[2]))
if status[0] == "OK": if status[0] == "OK":
@ -192,6 +193,8 @@ def process_results(result_path: Path):
errors += 1 errors += 1
if file_path_out.exists(): if file_path_out.exists():
result.set_log_files(f"['{file_path_out}']") result.set_log_files(f"['{file_path_out}']")
elif file_path_stdout.exists():
result.set_log_files(f"['{file_path_stdout}']")
else: else:
fails += 1 fails += 1
if file_path_out.exists(): if file_path_out.exists():
@ -200,6 +203,8 @@ def process_results(result_path: Path):
result.set_log_files(f"['{file_path_unit}']") result.set_log_files(f"['{file_path_unit}']")
elif file_path_out.exists(): elif file_path_out.exists():
result.set_log_files(f"['{file_path_out}']") result.set_log_files(f"['{file_path_out}']")
elif file_path_stdout.exists():
result.set_log_files(f"['{file_path_stdout}']")
test_results.append(result) test_results.append(result)
return [oks, errors, fails, test_results] return [oks, errors, fails, test_results]

View File

@ -81,6 +81,7 @@ def run_fuzzer(fuzzer: str, timeout: int):
exact_artifact_path = f"{OUTPUT}/{fuzzer}.unit" exact_artifact_path = f"{OUTPUT}/{fuzzer}.unit"
status_path = f"{OUTPUT}/{fuzzer}.status" status_path = f"{OUTPUT}/{fuzzer}.status"
out_path = f"{OUTPUT}/{fuzzer}.out" out_path = f"{OUTPUT}/{fuzzer}.out"
stdout_path = f"{OUTPUT}/{fuzzer}.stdout"
cmd_line = f"{DEBUGGER} ./{fuzzer} {active_corpus_dir} {seed_corpus_dir}" cmd_line = f"{DEBUGGER} ./{fuzzer} {active_corpus_dir} {seed_corpus_dir}"
@ -98,11 +99,11 @@ def run_fuzzer(fuzzer: str, timeout: int):
stopwatch = Stopwatch() stopwatch = Stopwatch()
try: try:
with open(out_path, "wb") as out: with open(out_path, "wb") as out, open(stdout_path, "wb") as stdout:
subprocess.run( subprocess.run(
cmd_line.split(), cmd_line.split(),
stdin=subprocess.DEVNULL, stdin=subprocess.DEVNULL,
stdout=subprocess.DEVNULL, stdout=stdout,
stderr=out, stderr=out,
text=True, text=True,
check=True, check=True,
@ -122,13 +123,18 @@ def run_fuzzer(fuzzer: str, timeout: int):
status.write( status.write(
f"OK\n{stopwatch.start_time_str}\n{stopwatch.duration_seconds}\n" f"OK\n{stopwatch.start_time_str}\n{stopwatch.duration_seconds}\n"
) )
except Exception as e:
logging.info("Unexpected exception running %s: %s", fuzzer, e)
with open(status_path, "w", encoding="utf-8") as status:
status.write(
f"ERROR\n{stopwatch.start_time_str}\n{stopwatch.duration_seconds}\n"
)
else: else:
logging.info("Error running %s", fuzzer) logging.info("Error running %s", fuzzer)
with open(status_path, "w", encoding="utf-8") as status: with open(status_path, "w", encoding="utf-8") as status:
status.write( status.write(
f"ERROR\n{stopwatch.start_time_str}\n{stopwatch.duration_seconds}\n" f"ERROR\n{stopwatch.start_time_str}\n{stopwatch.duration_seconds}\n"
) )
os.remove(out_path)
def main(): def main():