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

Fix benchmark integration script #1504

Merged
merged 3 commits into from
Oct 3, 2022
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
3 changes: 0 additions & 3 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -1,3 +0,0 @@
[submodule "third_party/oss-fuzz"]
path = third_party/oss-fuzz
url = https://github.com/google/oss-fuzz.git
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
23 changes: 9 additions & 14 deletions benchmarks/oss_fuzz_benchmark_integration.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,23 +15,24 @@
will create benchmark.yaml as well as copy the files from OSS-Fuzz to build the
benchmark."""
import argparse
import bisect
import datetime
from distutils import spawn
from distutils import dir_util
import json
import os
import sys
import subprocess
import json
import bisect
import tempfile


from common import utils
from common import benchmark_utils
from common import logs
from common import new_process
from common import yaml_utils

OSS_FUZZ_DIR = os.path.join(utils.ROOT_DIR, 'third_party', 'oss-fuzz')
OSS_FUZZ_REPO_PATH = os.path.join(OSS_FUZZ_DIR, 'infra')
OSS_FUZZ_REPO_URL = 'https://github.com/google/oss-fuzz'
OSS_FUZZ_IMAGE_UPGRADE_DATE = datetime.datetime(
year=2021, month=8, day=25, tzinfo=datetime.timezone.utc)

Expand Down Expand Up @@ -77,14 +78,10 @@ def find_digest(self, timestamp):
def copy_oss_fuzz_files(project, commit_date, benchmark_dir):
"""Checks out the right files from OSS-Fuzz to build the benchmark based on
|project| and |commit_date|. Then copies them to |benchmark_dir|."""
if not os.path.exists(os.path.join(OSS_FUZZ_DIR, '.git')):
logs.error(
'%s is not a git repo. Try running: git submodule update --init',
OSS_FUZZ_DIR)
raise RuntimeError('%s is not a git repo.' % OSS_FUZZ_DIR)
oss_fuzz_repo_manager = GitRepoManager(OSS_FUZZ_DIR)
project_dir = os.path.join(OSS_FUZZ_DIR, 'projects', project)
try:
with tempfile.TemporaryDirectory() as oss_fuzz_dir:
oss_fuzz_repo_manager = GitRepoManager(oss_fuzz_dir)
oss_fuzz_repo_manager.git(['clone', OSS_FUZZ_REPO_URL, oss_fuzz_dir])
project_dir = os.path.join(oss_fuzz_dir, 'projects', project)
# Find an OSS-Fuzz commit that can be used to build the benchmark.
_, oss_fuzz_commit, _ = oss_fuzz_repo_manager.git([
'log', '--before=' + commit_date.isoformat(), '-n1', '--format=%H',
Expand All @@ -98,8 +95,6 @@ def copy_oss_fuzz_files(project, commit_date, benchmark_dir):
dir_util.copy_tree(project_dir, benchmark_dir)
os.remove(os.path.join(benchmark_dir, 'project.yaml'))
return True
finally:
oss_fuzz_repo_manager.git(['reset', '--hard'])


def get_benchmark_name(project, fuzz_target, benchmark_name=None):
Expand Down
1 change: 0 additions & 1 deletion docs/getting-started/prerequisites.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ Clone the FuzzBench repository to your machine by running the following command:
```bash
git clone https://github.com/google/fuzzbench
cd fuzzbench
git submodule update --init
```

## Installing prerequisites
Expand Down
3 changes: 0 additions & 3 deletions experiment/run_experiment.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,6 @@

BENCHMARKS_DIR = os.path.join(utils.ROOT_DIR, 'benchmarks')
FUZZERS_DIR = os.path.join(utils.ROOT_DIR, 'fuzzers')
OSS_FUZZ_PROJECTS_DIR = os.path.join(utils.ROOT_DIR, 'third_party', 'oss-fuzz',
'projects')
RESOURCES_DIR = os.path.join(utils.ROOT_DIR, 'experiment', 'resources')
FUZZER_NAME_REGEX = re.compile(r'^[a-z][a-z0-9_]+$')
EXPERIMENT_CONFIG_REGEX = re.compile(r'^[a-z0-9-]{0,30}$')
Expand All @@ -56,7 +54,6 @@
r'\#*\#$|'
r'\.pytest_cache/|'
r'.*/test_data/|'
r'^third_party/oss-fuzz/build/|'
r'^docker/generated.mk$|'
r'^docs/)')
_OSS_FUZZ_CORPUS_BACKUP_URL_FORMAT = (
Expand Down
1 change: 0 additions & 1 deletion third_party/oss-fuzz
Submodule oss-fuzz deleted from d39cbb