Ejemplo n.º 1
0
    def test_get_build_steps(self, mock_url, mock_get_datetime_now):
        """Test for get_build_steps."""
        del mock_url, mock_get_datetime_now
        project_yaml_contents = (
            'language: c++\n'
            'sanitizers:\n'
            '  - address\n'
            '  - memory\n'
            '  - undefined\n'
            'architectures:\n'
            '  - x86_64\n'
            '  - i386\n'
            'main_repo: https://github.com/google/oss-fuzz.git\n')
        self.fs.create_dir(test_utils.PROJECT_DIR)
        test_utils.create_project_data(test_utils.PROJECT,
                                       project_yaml_contents)

        expected_build_steps_file_path = test_utils.get_test_data_file_path(
            'expected_build_steps.json')
        self.fs.add_real_file(expected_build_steps_file_path)
        with open(expected_build_steps_file_path) as expected_build_steps_file:
            expected_build_steps = json.load(expected_build_steps_file)

        config = build_project.Config(False, False, None, False, True)
        project_yaml, dockerfile = build_project.get_project_data(
            test_utils.PROJECT)
        build_steps = build_project.get_build_steps(
            test_utils.PROJECT, project_yaml, dockerfile,
            test_utils.IMAGE_PROJECT, test_utils.BASE_IMAGES_PROJECT, config)
        self.assertEqual(build_steps, expected_build_steps)
Ejemplo n.º 2
0
def _do_test_builds(args):
    """Does test coverage and fuzzing builds."""
    # TODO(metzman): Make this handle concurrent builds.
    build_types = []
    sanitizers = list(args.sanitizers)
    if 'coverage' in sanitizers:
        sanitizers.pop(sanitizers.index('coverage'))
        build_types.append(BUILD_TYPES['coverage'])
    if 'introspector' in sanitizers:
        sanitizers.pop(sanitizers.index('introspector'))
        build_types.append(BUILD_TYPES['introspector'])
    if sanitizers:
        build_types.append(BUILD_TYPES['fuzzing'])
    build_ids = collections.defaultdict(list)
    for build_type in build_types:
        projects = get_projects_to_build(list(args.projects), build_type,
                                         args.force_build)
        config = build_project.Config(testing=True,
                                      test_image_suffix=TEST_IMAGE_SUFFIX,
                                      branch=args.branch,
                                      parallel=False,
                                      upload=False)
        credentials = (
            oauth2client.client.GoogleCredentials.get_application_default())
        project_builds = _do_build_type_builds(args, config, credentials,
                                               build_type, projects)
        for project, project_build_id in project_builds.items():
            build_ids[project].append(project_build_id)

    return wait_on_builds(build_ids, credentials, IMAGE_PROJECT)
    def test_get_coverage_build_steps(self, mock_url, mock_corpora_steps,
                                      mock_get_datetime_now):
        """Test for get_build_steps."""
        del mock_url, mock_corpora_steps, mock_get_datetime_now
        project_yaml_contents = ('language: c++\n'
                                 'sanitizers:\n'
                                 '  - address\n'
                                 'architectures:\n'
                                 '  - x86_64\n')
        self.fs.create_dir(test_utils.PROJECT_DIR)
        test_utils.create_project_data(test_utils.PROJECT,
                                       project_yaml_contents)

        expected_build_steps_file_path = test_utils.get_test_data_file_path(
            'expected_coverage_build_steps.json')
        self.fs.add_real_file(expected_build_steps_file_path)
        with open(expected_build_steps_file_path) as expected_build_steps_file:
            expected_coverage_build_steps = json.load(
                expected_build_steps_file)

        config = build_project.Config(False, False, None, False)
        project_yaml, dockerfile = build_project.get_project_data(
            test_utils.PROJECT)
        build_steps = build_and_run_coverage.get_build_steps(
            test_utils.PROJECT, project_yaml, dockerfile,
            test_utils.IMAGE_PROJECT, test_utils.BASE_IMAGES_PROJECT, config)
        self.assertEqual(build_steps, expected_coverage_build_steps)
Ejemplo n.º 4
0
def get_build_steps(project_name, image_project, base_images_project):
    """Retrieve build steps."""
    # TODO(metzman): Figure out if we need this.
    project_yaml_contents, dockerfile_lines = get_project_data(project_name)
    build_config = build_project.Config(False, False, False, False)
    return build_project.get_build_steps(project_name, project_yaml_contents,
                                         dockerfile_lines, image_project,
                                         base_images_project, build_config)
Ejemplo n.º 5
0
def get_build_steps(project_name, image_project, base_images_project):
    """Retrieve build steps."""
    build_config = build_project.Config(False, False, False, False)
    project_yaml_contents, dockerfile_lines = request_build.get_project_data(
        project_name)
    return build_and_run_coverage.get_build_steps(
        project_name, project_yaml_contents, dockerfile_lines, image_project,
        base_images_project, build_config)
Ejemplo n.º 6
0
def do_test_builds(args):
    """Does test coverage and fuzzing builds."""
    # TODO(metzman): Make this handle concurrent builds.
    build_types = []
    if list(args.sanitizers) == ['coverage']:
        build_types.append(BUILD_TYPES['coverage'])
        if len(build_types) > 1:
            build_types.append(BUILD_TYPES['fuzzing'])
    else:
        build_types.append(BUILD_TYPES['fuzzing'])
    for build_type in build_types:
        projects = get_projects_to_build(list(args.projects), build_type)
        config = build_project.Config(testing=True,
                                      test_image_suffix=TEST_IMAGE_SUFFIX,
                                      branch=args.branch,
                                      parallel=False,
                                      upload=False)
        credentials = (
            oauth2client.client.GoogleCredentials.get_application_default())
        build_ids = _do_builds(args, config, credentials, build_type, projects)
    return wait_on_builds(build_ids, credentials, IMAGE_PROJECT)
Ejemplo n.º 7
0
def get_empty_config():
    """Returns an empty build config."""
    return build_project.Config(False, None, None, False)