Fix trial build for coverage (#8268)

* Fix trial build for coverage

* Fix
This commit is contained in:
jonathanmetzman 2022-08-16 08:59:28 -04:00 committed by GitHub
parent 4ca6508278
commit 9f150d831f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 22 additions and 20 deletions

View File

@ -111,7 +111,8 @@ def get_build_steps( # pylint: disable=too-many-locals, too-many-arguments
env = build_project.get_env(project.fuzzing_language, build)
build_steps.append(
build_project.get_compile_step(project, build, env, config.parallel))
download_corpora_steps = build_lib.download_corpora_steps(project.name)
download_corpora_steps = build_lib.download_corpora_steps(
project.name, test_image_suffix=config.test_image_suffix)
if not download_corpora_steps:
logging.info('Skipping code coverage build for %s.', project.name)
return []
@ -133,8 +134,8 @@ def get_build_steps( # pylint: disable=too-many-locals, too-many-arguments
build_steps.append({
'name':
build_project.get_runner_image_name(base_images_project,
config.test_image_suffix),
build_lib.get_runner_image_name(base_images_project,
config.test_image_suffix),
'env':
coverage_env,
'args': [

View File

@ -30,6 +30,8 @@ from oauth2client.service_account import ServiceAccountCredentials
import requests
import yaml
BASE_IMAGES_PROJECT = 'oss-fuzz-base'
BUILD_TIMEOUT = 16 * 60 * 60
# Needed for reading public target.list.* files.
@ -184,7 +186,7 @@ def get_signed_url(path, method='PUT', content_type=''):
return f'https://storage.googleapis.com{path}?{urlparse.urlencode(values)}'
def download_corpora_steps(project_name):
def download_corpora_steps(project_name, test_image_suffix):
"""Returns GCB steps for downloading corpora backups for the given project.
"""
fuzz_targets = _get_targets_list(project_name)
@ -210,7 +212,7 @@ def download_corpora_steps(project_name):
download_corpus_args.append('%s %s' % (corpus_archive_path, url))
steps.append({
'name': 'gcr.io/oss-fuzz-base/base-runner',
'name': get_runner_image_name(BASE_IMAGES_PROJECT, test_image_suffix),
'entrypoint': 'download_corpus',
'args': download_corpus_args,
'volumes': [{
@ -476,6 +478,15 @@ def get_gcb_url(build_id, cloud_project='oss-fuzz'):
f'{build_id}?project={cloud_project}')
def get_runner_image_name(base_images_project, test_image_suffix):
"""Returns the runner image that should be used, based on
|base_images_project|. Returns the testing image if |test_image_suffix|."""
image = f'gcr.io/{base_images_project}/base-runner'
if test_image_suffix:
image += '-' + test_image_suffix
return image
def get_build_body(steps,
timeout,
body_overrides,

View File

@ -313,8 +313,8 @@ def get_build_steps( # pylint: disable=too-many-locals, too-many-statements, to
# Test fuzz targets.
test_step = {
'name':
get_runner_image_name(base_images_project,
config.test_image_suffix),
build_lib.get_runner_image_name(base_images_project,
config.test_image_suffix),
'env':
env,
'args': [
@ -347,8 +347,8 @@ def get_build_steps( # pylint: disable=too-many-locals, too-many-statements, to
# Generate targets list.
{
'name':
get_runner_image_name(base_images_project,
config.test_image_suffix),
build_lib.get_runner_image_name(base_images_project,
config.test_image_suffix),
'env':
env,
'args': [
@ -451,15 +451,6 @@ def get_cleanup_step(project, build):
}
def get_runner_image_name(base_images_project, test_image_suffix):
"""Returns the runner image that should be used, based on
|base_images_project|. Returns the testing image if |test_image_suffix|."""
image = f'gcr.io/{base_images_project}/base-runner'
if test_image_suffix:
image += '-' + test_image_suffix
return image
# pylint: disable=no-member,too-many-arguments
def run_build(oss_fuzz_project,
build_steps,
@ -523,7 +514,6 @@ def build_script_main(script_description, get_build_steps_func, build_type):
logging.basicConfig(level=logging.INFO)
image_project = 'oss-fuzz'
base_images_project = 'oss-fuzz-base'
credentials = oauth2client.client.GoogleCredentials.get_application_default()
error = False
@ -543,7 +533,7 @@ def build_script_main(script_description, get_build_steps_func, build_type):
steps = get_build_steps_func(project_name, project_yaml,
dockerfile_contents, image_project,
base_images_project, config)
build_lib.BASE_IMAGES_PROJECT, config)
if not steps:
logging.error('No steps. Skipping %s.', project_name)
error = True