From 733c896ce5bbae3b27ac5c893da4caf3af138f78 Mon Sep 17 00:00:00 2001 From: Max Moroz Date: Thu, 30 Aug 2018 09:46:14 -0700 Subject: [PATCH] [infra] Support extra coverage args in project.yaml (fix #1726, follow-up #1547). (#1774) * [infra] Support extra coverage args in project.yaml (fix #1726, follow-up #1547). * Update the documentation page. * Fix review comments by Jonathan. --- docs/code_coverage.md | 19 +++++++++++++------ infra/gcb/build_and_run_coverage.py | 5 ++++- infra/gcb/build_project.py | 1 + 3 files changed, 18 insertions(+), 7 deletions(-) diff --git a/docs/code_coverage.md b/docs/code_coverage.md index f196b393d..e14f4b238 100644 --- a/docs/code_coverage.md +++ b/docs/code_coverage.md @@ -87,20 +87,27 @@ python infra/helper.py profile --fuzz-target= --corpus-dir= ``` -To specify particular source files to be shown in the report, list the filepaths -at the end of the extra arguments sequence, for example: +To specify particular source files or directories to show in the report, list +their paths at the end of the extra arguments sequence, for example: ```bash -python infra/helper.py profile zlib -- -tab-size=8 /src/zlib/inftrees.c /src/zlib_uncompress_fuzzer.cc /src/zlib/zutil.c +python infra/helper.py profile zlib -- /src/zlib/inftrees.c /src/zlib_uncompress_fuzzer.cc /src/zlib/zutil.c ``` +If you want OSS-Fuzz to use some extra arguments when generating code coverage +reports for your project, add the arguments into `project.yaml` file as follows: + +```yaml +coverage_extra_args: -ignore-filename-regex=.*crc.* -ignore-filename-regex=.*adler.* +``` + + [Clang Source-based Code Coverage]: https://clang.llvm.org/docs/SourceBasedCodeCoverage.html [gsutil tool]: https://cloud.google.com/storage/docs/gsutil_install [llvm-cov tool]: https://llvm.org/docs/CommandGuide/llvm-cov.html diff --git a/infra/gcb/build_and_run_coverage.py b/infra/gcb/build_and_run_coverage.py index 99d94f6dc..7e992fab8 100644 --- a/infra/gcb/build_and_run_coverage.py +++ b/infra/gcb/build_and_run_coverage.py @@ -135,7 +135,10 @@ def get_build_steps(project_dir): # Unpack the corpus and run coverage script. { 'name': 'gcr.io/oss-fuzz-base/base-runner', - 'env': env + ['HTTP_PORT=', 'COVERAGE_EXTRA_ARGS='], + 'env': env + [ + 'HTTP_PORT=', + 'COVERAGE_EXTRA_ARGS=%s' % project_yaml['coverage_extra_args'] + ], 'args': [ 'bash', '-c', diff --git a/infra/gcb/build_project.py b/infra/gcb/build_project.py index a65c76b18..159fb181e 100755 --- a/infra/gcb/build_project.py +++ b/infra/gcb/build_project.py @@ -83,6 +83,7 @@ def load_project_yaml(project_dir): project_yaml.setdefault('sanitizers', DEFAULT_SANITIZERS) project_yaml.setdefault('fuzzing_engines', DEFAULT_ENGINES) project_yaml.setdefault('run_tests', True) + project_yaml.setdefault('coverage_extra_args', '') return project_yaml