diff options
author | Android Build Coastguard Worker <android-build-coastguard-worker@google.com> | 2022-05-11 05:09:55 +0000 |
---|---|---|
committer | Android Build Coastguard Worker <android-build-coastguard-worker@google.com> | 2022-05-11 05:09:55 +0000 |
commit | 25ab32037e9f68384964b20f678dc75c4184bf24 (patch) | |
tree | aab00ff7a7202a49d2afaa9084f260c2e519653b /infra/cifuzz/build_fuzzers_entrypoint.py | |
parent | 8dd31c7112ba7b07fcafe02c83dc9ef3808cdab7 (diff) | |
parent | 964a594e4219fae93e07d1546c905a01e3bf8e3e (diff) | |
download | oss-fuzz-aml_net_331412000.tar.gz |
Snap for 8570526 from 964a594e4219fae93e07d1546c905a01e3bf8e3e to mainline-networking-releaseaml_net_331910030aml_net_331812010aml_net_331710000aml_net_331610000aml_net_331412000aml_net_331313030aml_net_331313010aml_net_331110020aml_net_331011030aml_net_330910010aml_net_330811010android13-mainline-networking-release
Change-Id: I80a4ac7c1910948d2da016ba661e9b715e51402f
Diffstat (limited to 'infra/cifuzz/build_fuzzers_entrypoint.py')
-rw-r--r-- | infra/cifuzz/build_fuzzers_entrypoint.py | 67 |
1 files changed, 23 insertions, 44 deletions
diff --git a/infra/cifuzz/build_fuzzers_entrypoint.py b/infra/cifuzz/build_fuzzers_entrypoint.py index 04f562068..e8e368f1b 100644 --- a/infra/cifuzz/build_fuzzers_entrypoint.py +++ b/infra/cifuzz/build_fuzzers_entrypoint.py @@ -13,7 +13,6 @@ # limitations under the License. """Builds a specific OSS-Fuzz project's fuzzers for CI tools.""" import logging -import os import sys import build_fuzzers @@ -22,19 +21,34 @@ import config_utils # pylint: disable=c-extension-no-member # pylint gets confused because of the relative import of cifuzz. -# TODO: Turn default logging to INFO when CIFuzz is stable logging.basicConfig( format='%(asctime)s - %(name)s - %(levelname)s - %(message)s', level=logging.DEBUG) +def build_fuzzers_entrypoint(): + """Builds OSS-Fuzz project's fuzzers for CI tools.""" + config = config_utils.BuildFuzzersConfig() + + if config.dry_run: + # Sets the default return code on error to success. + returncode = 0 + else: + # The default return code when an error occurs. + returncode = 1 + + if not build_fuzzers.build_fuzzers(config): + logging.error('Error building fuzzers for (commit: %s, pr_ref: %s).', + config.commit_sha, config.pr_ref) + return returncode + + return 0 + + def main(): - """Build OSS-Fuzz project's fuzzers for CI tools. - This script is used to kick off the Github Actions CI tool. It is the - entrypoint of the Dockerfile in this directory. This action can be added to - any OSS-Fuzz project's workflow that uses Github. + """Builds OSS-Fuzz project's fuzzers for CI tools. - Note: The resulting clusterfuzz binaries of this build are placed in + Note: The resulting fuzz target binaries of this build are placed in the directory: ${GITHUB_WORKSPACE}/out Required environment variables: @@ -50,44 +64,9 @@ def main(): SANITIZER: The sanitizer to use when running fuzzers. Returns: - 0 on success or 1 on failure. + 0 on success or nonzero on failure. """ - config = config_utils.BuildFuzzersConfig() - - if config.dry_run: - # Sets the default return code on error to success. - returncode = 0 - else: - # The default return code when an error occurs. - returncode = 1 - - if not config.workspace: - logging.error('This script needs to be run within Github actions.') - return returncode - - if not build_fuzzers.build_fuzzers(config): - logging.error( - 'Error building fuzzers for project %s (commit: %s, pr_ref: %s).', - config.project_name, config.commit_sha, config.pr_ref) - return returncode - - out_dir = os.path.join(config.workspace, 'out') - - if not config.bad_build_check: - # If we've gotten to this point and we don't need to do bad_build_check, - # then the build has succeeded. - returncode = 0 - # yapf: disable - elif build_fuzzers.check_fuzzer_build( - out_dir, - config.sanitizer, - config.language, - allowed_broken_targets_percentage=config.allowed_broken_targets_percentage - ): - # yapf: enable - returncode = 0 - - return returncode + return build_fuzzers_entrypoint() if __name__ == '__main__': |