[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.
This commit is contained in:
Max Moroz 2018-08-30 09:46:14 -07:00 committed by GitHub
parent ed900e11a7
commit 733c896ce5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 18 additions and 7 deletions

View File

@ -87,20 +87,27 @@ python infra/helper.py profile --fuzz-target=<fuzz_target_name> --corpus-dir=<my
### Additional arguments for `llvm-cov`
You may want to use some of the options of [llvm-cov tool], for example,
`-ignore-filename-regex=` or `-tab-size=`. You can pass those to the helper
script after `--`:
`-ignore-filename-regex=`. You can pass those to the helper script after `--`:
```bash
python infra/helper.py profile $project_name -- -ignore-filename-regex='.*code/to/be/ignored/.*' -tab-size=2
python infra/helper.py profile $project_name -- -ignore-filename-regex=.*code/to/be/ignored/.* <other_extra_args>
```
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 -- <other_extra_args> /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.* <other_extra_args>
```
[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

View File

@ -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',

View File

@ -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