From cfe13cb116dd8f855ebfae3796aba12472ed31ab Mon Sep 17 00:00:00 2001 From: Max Moroz Date: Thu, 9 Jan 2020 09:41:58 -0800 Subject: [PATCH] [infra] Print additional information for build/coverage failures on GCB (#3104). (#3208) * [infra] Explicily print failing build config in the GCB log (#3104). * add trailing "false" command + add a message for misisng coprus backups in code coverage build * improve the coverage message and behavior * fix exit command * use .format() for a single argument format string too * fix typo --- infra/gcb/build_and_run_coverage.py | 9 ++++++++- infra/gcb/build_project.py | 14 +++++++++++--- 2 files changed, 19 insertions(+), 4 deletions(-) diff --git a/infra/gcb/build_and_run_coverage.py b/infra/gcb/build_and_run_coverage.py index 30ea5d952..48d04b6ed 100644 --- a/infra/gcb/build_and_run_coverage.py +++ b/infra/gcb/build_and_run_coverage.py @@ -176,7 +176,14 @@ def get_build_steps(project_dir): 'args': [ 'bash', '-c', - 'for f in /corpus/*.zip; do unzip -q $f -d ${f%%.*}; done && coverage', + ('for f in /corpus/*.zip; do unzip -q $f -d ${f%%.*} || ' + 'echo "Failed to unpack the corpus for $(basename ${f%%.*}). ' + 'This usually means that corpus backup for a particular fuzz ' + 'target does not exist. If a fuzz target was added in the last ' + '24 hours, please wait one more day. Otherwise, something is ' + 'wrong with the fuzz target or the infrastructure, and corpus ' + 'pruning task does not finish successfully." && exit 1; ' + 'done && coverage') ], 'volumes': [{'name': 'corpus', 'path': '/corpus'}], } diff --git a/infra/gcb/build_project.py b/infra/gcb/build_project.py index fcdb1a011..e0a353634 100644 --- a/infra/gcb/build_project.py +++ b/infra/gcb/build_project.py @@ -236,6 +236,8 @@ def get_build_steps(project_dir): if not workdir: workdir = '/src' + failure_msg = ('FAILED IN THE FOLLOWING CONFIG: --sanitizer {0} ' + '--engine {1}').format(sanitizer, fuzzing_engine) build_steps.append( # compile { @@ -251,8 +253,9 @@ def get_build_steps(project_dir): # `cd /src && cd {workdir}` (where {workdir} is parsed from # the Dockerfile). Container Builder overrides our workdir # so we need to add this step to set it back. - 'rm -r /out && cd /src && cd {1} && mkdir -p {0} && compile' - .format(out, workdir), + ('rm -r /out && cd /src && cd {1} && mkdir -p {0} && ' + 'compile || echo "build_fuzzers {2}" && false') + .format(out, workdir, failure_msg), ], }) @@ -276,7 +279,12 @@ def get_build_steps(project_dir): { 'name': 'gcr.io/oss-fuzz-base/base-runner', 'env': env, - 'args': ['bash', '-c', 'test_all'], + 'args': [ + 'bash', + '-c', + 'test_all || echo "check_build {0}" && false'.format( + failure_msg) + ], }) if project_yaml['labels']: