Updated Bazel fuzzing to use the newest fuzz rules.

pull/13171/head
Joshua Haberman 3 years ago
parent c5d6ec737e
commit f5796aa607
  1. 14
      .bazelrc
  2. 16
      WORKSPACE
  3. 8
      bazel/workspace_deps.bzl
  4. 17
      tests/BUILD
  5. 4
      tests/file_descriptor_parsenew_fuzzer.cc

@ -24,4 +24,16 @@ build:analyzer --per_file_copt=json/parser@-fno-analyzer
build:analyzer --per_file_copt=com_google_protobuf@-fno-analyzer
build:analyzer --per_file_copt=com_github_google_benchmark@-fno-analyzer
build:asan-fuzzer --copt=-fsanitize=address,fuzzer --linkopt=-fsanitize=address,fuzzer --define fuzz=true
# --config=asan-libfuzzer
build:asan-libfuzzer --action_env=CC=clang
build:asan-libfuzzer --action_env=CXX=clang++
build:asan-libfuzzer --@rules_fuzzing//fuzzing:cc_engine=@rules_fuzzing//fuzzing/engines:libfuzzer
build:asan-libfuzzer --@rules_fuzzing//fuzzing:cc_engine_instrumentation=libfuzzer
build:asan-libfuzzer --@rules_fuzzing//fuzzing:cc_engine_sanitizer=asan
# --config=msan-libfuzzer
build:msan-libfuzzer --action_env=CC=clang
build:msan-libfuzzer --action_env=CXX=clang++
build:msan-libfuzzer --@rules_fuzzing//fuzzing:cc_engine=@rules_fuzzing//fuzzing/engines:libfuzzer
build:msan-libfuzzer --@rules_fuzzing//fuzzing:cc_engine_instrumentation=libfuzzer
build:msan-libfuzzer --@rules_fuzzing//fuzzing:cc_engine_sanitizer=msan

@ -3,6 +3,7 @@ workspace(name = "upb")
load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
load("@bazel_tools//tools/build_defs/repo:git.bzl", "new_git_repository")
load("//bazel:workspace_deps.bzl", "upb_deps")
load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
upb_deps()
@ -38,3 +39,18 @@ new_git_repository(
build_file = "//benchmarks:BUILD.googleapis",
patch_cmds = ["find google -type f -name BUILD.bazel -delete"],
)
http_archive(
name = "rules_fuzzing",
sha256 = "127d7c45e9b7520b3c42145b3cb1b8c26477cdaed0521b02a0298907339fefa1",
strip_prefix = "rules_fuzzing-0.2.0",
urls = ["https://github.com/bazelbuild/rules_fuzzing/archive/v0.2.0.zip"],
)
load("@rules_fuzzing//fuzzing:repositories.bzl", "rules_fuzzing_dependencies")
rules_fuzzing_dependencies()
load("@rules_fuzzing//fuzzing:init.bzl", "rules_fuzzing_init")
rules_fuzzing_init()

@ -25,12 +25,8 @@ def upb_deps():
maybe(
http_archive,
name = "rules_python",
sha256 = "e5470e92a18aa51830db99a4d9c492cc613761d5bdb7131c04bd92b9834380f6",
strip_prefix = "rules_python-4b84ad270387a7c439ebdccfd530e2339601ef27",
urls = [
"https://mirror.bazel.build/github.com/bazelbuild/rules_python/archive/4b84ad270387a7c439ebdccfd530e2339601ef27.tar.gz",
"https://github.com/bazelbuild/rules_python/archive/4b84ad270387a7c439ebdccfd530e2339601ef27.tar.gz",
],
url = "https://github.com/bazelbuild/rules_python/releases/download/0.3.0/rules_python-0.3.0.tar.gz",
sha256 = "934c9ceb552e84577b0faf1e5a2f0450314985b4d8712b2b70717dc679fdc01b",
)
maybe(

@ -34,14 +34,10 @@ load(
"upb_proto_library",
"upb_proto_reflection_library",
)
load("@rules_fuzzing//fuzzing:cc_defs.bzl", "cc_fuzz_test")
licenses(["notice"])
config_setting(
name = "fuzz",
values = {"define": "fuzz=true"},
)
cc_library(
name = "upb_test",
testonly = 1,
@ -144,18 +140,9 @@ cc_test(
)
# OSS-Fuzz test
cc_binary(
cc_fuzz_test(
name = "file_descriptor_parsenew_fuzzer",
testonly = 1,
srcs = ["file_descriptor_parsenew_fuzzer.cc"],
copts = UPB_DEFAULT_CPPOPTS + select({
"//conditions:default": [],
":fuzz": ["-fsanitize=fuzzer,address"],
}),
defines = select({
"//conditions:default": [],
":fuzz": ["HAVE_FUZZER"],
}),
deps = [
"//:descriptor_upb_proto",
"//:upb",

@ -34,7 +34,3 @@ extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) {
size, arena.ptr());
return 0;
}
#ifndef HAVE_FUZZER
int main() {}
#endif

Loading…
Cancel
Save