commit | fca4dcce9dc99cc56281c965fbc0febc07ad923b | [log] [tgz] |
---|---|---|
author | Tengpeng <66138273+tengpengli@users.noreply.github.com> | Tue Aug 25 20:29:02 2020 -0400 |
committer | GitHub <noreply@github.com> | Tue Aug 25 20:29:02 2020 -0400 |
tree | b8f976390a0d02c432ddb987955de35b3ef096bc | |
parent | 69a6e668b531598d8375a918a5af38b12b1c7542 [diff] |
Adds dictionary support to launcher (#63) Adds dictionary support to the fuzzing_launcher 1) Adds --dict to launcher.py 2) Adds fuzzing_dictionary as an implicit argument to fuzzing_launcher 3) Adds dict_dir directory with valid and invalid dictionaries 4) Adds empty_fuzz_test_with_dict and empty_fuzz_test_with_invalid_dict Signed-off-by: tengpeng <tengpeng.li2020@gmail.com> modified: examples/BUILD new file: examples/dict_dir/invalid.dict new file: examples/dict_dir/valid.dict modified: fuzzing/cc_deps.bzl modified: fuzzing/common.bzl modified: fuzzing/tools/launcher.py
This repository contains Bazel Starlark extensions for defining fuzz tests in Bazel projects.
This is not an officially supported Google product.
To import the fuzzing rules in your project, you first need to add the snippet below to your WORKSPACE
file:
load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive") http_archive( name = "rules_fuzzing", sha256 = "597622ca07b0abc36e5bea565ca66f8d3d07faed33de5d9e09117816c68da281", strip_prefix = "bazel-rules-fuzzing-ac0acb1e38246ef94badd6db22ad5dad11250150", urls = ["https://github.com/googleinterns/bazel-rules-fuzzing/archive/ac0acb1e38246ef94badd6db22ad5dad11250150.zip"], ) load("@rules_fuzzing//fuzzing:repositories.bzl", "rules_fuzzing_dependencies") rules_fuzzing_dependencies() load("@rules_fuzzing//fuzzing:dependency_imports.bzl", "fuzzing_dependency_imports") fuzzing_dependency_imports() load("@fuzzing_py_deps//:requirements.bzl", fuzzing_py_install = "pip_install") fuzzing_py_install()
Tiny example:
Assume that you have a fuzz_test.cc
file to do the fuzzing test and corpus files corpus_1.txt
and corpus_dir/*
.
You can create a fuzz test target in the BUILD
like below:
load("@rules_fuzzing//fuzzing:cc_deps.bzl", "cc_fuzz_test") cc_fuzz_test( name = "fuzz_test", srcs = ["fuzz_test.cc"], corpus = ["corpus_1.txt"] + glob(["corpus_dir/**"], )
If your .bazelrc
in the project root directory has config libfuzzer
:
build:libfuzzer --action_env=CC=clang build:libfuzzer --action_env=CXX=clang++ build:libfuzzer --linkopt=-fsanitize=fuzzer build:libfuzzer --copt=-fsanitize=fuzzer build:libfuzzer --@rules_fuzzing//fuzzing:engine=libfuzzer
you then can run the fuzz test above using command
bazel run fuzz_test_run --config=libfuzzer
You can also control the fuzzing test running time by passing --timeout_secs
like
bazel run fuzz_test_run --config=libfuzzer -- --timeout_secs=20
If you only want to run the regression test on the corpus, set --regression
:
bazel run fuzz_test_run --config=libfuzzer -- --regression=True
Feel free to copy the config setting in .bazelrc to yours.
See the examples directory for more examples.