SERVER-126317 Mark fuzztests that crash as failing (#53549)

GitOrigin-RevId: 71d09345416f3caddbecb07508963cef5002ea70
This commit is contained in:
Spencer Jackson 2026-05-11 15:12:42 -07:00 committed by MongoDB Bot
parent d472187ff8
commit e72d6be7ad

View File

@ -1,6 +1,7 @@
"""The libfuzzertest.TestCase for C++ libfuzzer tests."""
import datetime
import glob
import os
from typing import Optional
@ -53,6 +54,40 @@ class CPPLibfuzzerTestCase(interface.ProcessTestCase):
interface.append_process_tracking_options(self.program_options, self._id)
def run_test(self):
"""Run the test, then fail if any crash files were recorded in the corpus."""
try:
self.proc = self._make_process()
self._execute(self.proc)
except self.failureException:
raise
except:
self.logger.exception(
"Encountered an error running %s %s", self.test_kind, self.basename()
)
raise
# Centipede's corpus database stores known-reproducible crashes (deduped
# by signature) under <corpus>/<binary>/<test>/crashing/. It self-prunes
# entries that no longer reproduce on the next run, so a non-empty
# directory after the fuzzer exits means there are still-reproducible
# crashes that this build is responsible for.
crash_files = glob.glob(
os.path.join(
self.corpus_directory,
self.short_name(),
"LLVMFuzzer.TestOneInput",
"crashing",
"*",
)
)
crash_files = [f for f in crash_files if os.path.isfile(f)]
if crash_files:
self.return_code = 1
msg = f"{self.short_description()} has {len(crash_files)} reproducible crash(es) in the corpus database: {crash_files}"
self.logger.error(msg)
raise self.failureException(msg)
def _make_process(self):
default_args = [
self.program_executable,