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

make it possible to run projects not in OSS-Fuzz upstream #551

Merged
merged 2 commits into from
Aug 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 10 additions & 4 deletions experiment/evaluator.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,8 @@ def load_existing_textcov(project: str) -> textcov.Textcov:

if not blobs.prefixes: # type: ignore
# No existing coverage reports.
raise RuntimeError(f'No existing coverage reports for {project}')
logger.info('No existing coverage report. Using empty.')
return textcov.Textcov()

# Find the latest generated textcov date.
latest_dir = sorted(blobs.prefixes)[-1] # type: ignore
Expand Down Expand Up @@ -137,7 +138,8 @@ def load_existing_coverage_summary(project: str) -> dict:

if not blobs.prefixes: # type: ignore
# No existing coverage reports.
raise RuntimeError(f'No existing coverage reports for {project}')
logger.info('No existing coverage reports, using empty one.')
return {}

latest_dir = sorted(blobs.prefixes)[-1] # type: ignore
blob = bucket.blob(f'{latest_dir}linux/summary.json')
Expand Down Expand Up @@ -418,8 +420,12 @@ def check_target(self, ai_binary, target_path: str) -> Result:
# Gets line coverage (diff) details.
coverage_summary = self._load_existing_coverage_summary()

total_lines = _compute_total_lines_without_fuzz_targets(
coverage_summary, generated_target_name)
if coverage_summary:
total_lines = _compute_total_lines_without_fuzz_targets(
coverage_summary, generated_target_name)
else:
total_lines = 0

if self.benchmark.language == 'jvm':
# The Jacoco.xml coverage report used to generate
# summary.json on OSS-Fuzz for JVM projects does
Expand Down
16 changes: 9 additions & 7 deletions experiment/oss_fuzz_checkout.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
# This will change if temp_dir is used.
OSS_FUZZ_DIR: str = os.path.join(
os.path.dirname(os.path.dirname(os.path.realpath(__file__))), 'oss-fuzz')
CLEAN_UP_OSS_FUZZ = bool(int(os.getenv('OFG_CLEAN_UP_OSS_FUZZ', '1')))

VENV_DIR: str = 'venv'

Expand Down Expand Up @@ -90,13 +91,14 @@ def clone_oss_fuzz(oss_fuzz_dir: str = ''):

if not os.path.exists(OSS_FUZZ_DIR):
_clone_oss_fuzz_repo()
# Remove existing targets.
clean_command = ['git', 'clean', '-fxd', '-e', VENV_DIR, '-e', BUILD_DIR]
sp.run(clean_command,
capture_output=True,
stdin=sp.DEVNULL,
check=True,
cwd=OSS_FUZZ_DIR)

if CLEAN_UP_OSS_FUZZ:
clean_command = ['git', 'clean', '-fxd', '-e', VENV_DIR, '-e', BUILD_DIR]
sp.run(clean_command,
capture_output=True,
stdin=sp.DEVNULL,
check=True,
cwd=OSS_FUZZ_DIR)


def postprocess_oss_fuzz() -> None:
Expand Down