Files
carbon-lang/executable_semantics/fuzzing/BUILD
T
pk19604014andJon Meow 22462a0d7f Carbon fuzzing 3/3: added actual fuzzer implementation and a fuzzverter utility for investigating crashing protos (#1156)
* finished fuzzer and added fuzzverter util

* fixed typo

* renamed cmd line params

* fixed libproto_mutator download path

* small fixes

* small fixes

* small fixes

* renamed sample corpus proto

* small fixes

* try building on github with LIBCPP_DEBUG enabled

* temporarily marked proto fuzzer as a manual test

* code review

* use a dedicated proto-fuzzer feature to work around LIBCPP_DEBUG=1 crash in proto code

* code review comments, added README.md

* minor fixes to the text

* Update bazel/cc_toolchains/clang_cc_toolchain_config.bzl

Co-authored-by: Jon Meow <jperkins@google.com>

* use Carbon source representation for "empty Main()" instead of text format proto representation

* fixed typo

* made FuzzerUtil produce the full carbon source (proto converted + Main if needed) to decrease code duplication a bit

* typo

* switched to text proto format per code review

* Update executable_semantics/prelude.h

Co-authored-by: Jon Meow <jperkins@google.com>

* Update executable_semantics/fuzzing/README.md

Co-authored-by: Jon Meow <jperkins@google.com>

* Update executable_semantics/fuzzing/README.md

Co-authored-by: Jon Meow <jperkins@google.com>

* Update executable_semantics/fuzzing/README.md

Co-authored-by: Jon Meow <jperkins@google.com>

* Update executable_semantics/fuzzing/README.md

Co-authored-by: Jon Meow <jperkins@google.com>

* Update executable_semantics/fuzzing/README.md

Co-authored-by: Jon Meow <jperkins@google.com>

* review comments

* removed unnecessary file mode variables

* Update executable_semantics/fuzzing/fuzzverter.cpp

Co-authored-by: Jon Meow <jperkins@google.com>

* Update executable_semantics/fuzzing/README.md

Co-authored-by: Jon Meow <jperkins@google.com>

* Update executable_semantics/fuzzing/README.md

Co-authored-by: Jon Meow <jperkins@google.com>

* code review comments

* Update executable_semantics/syntax/BUILD

Co-authored-by: Jon Meow <jperkins@google.com>

* buildifier

Co-authored-by: Jon Meow <jperkins@google.com>
2022-04-11 16:47:03 -04:00

109 lines
3.2 KiB
Python

# Part of the Carbon Language project, under the Apache License v2.0 with LLVM
# Exceptions. See /LICENSE for license information.
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
load("//bazel/fuzzing:rules.bzl", "cc_fuzz_test")
cc_library(
name = "ast_to_proto_lib",
srcs = ["ast_to_proto.cpp"],
hdrs = ["ast_to_proto.h"],
deps = [
"//common/fuzzing:carbon_cc_proto",
"//executable_semantics/ast",
"//executable_semantics/ast:declaration",
"//executable_semantics/ast:expression",
"@llvm-project//llvm:Support",
],
)
cc_library(
name = "fuzzer_util",
srcs = ["fuzzer_util.cpp"],
hdrs = ["fuzzer_util.h"],
deps = [
"//common:check",
"//common/fuzzing:carbon_cc_proto",
"//common/fuzzing:proto_to_carbon_lib",
"@llvm-project//llvm:Support",
],
)
cc_test(
name = "ast_to_proto_test",
srcs = ["ast_to_proto_test.cpp"],
args = [
"$(locations //executable_semantics:standard_libraries)",
"$(locations //executable_semantics/testdata:carbon_files)",
],
data = [
"//executable_semantics:standard_libraries",
"//executable_semantics/testdata:carbon_files",
],
deps = [
":ast_to_proto_lib",
"//common/fuzzing:carbon_cc_proto",
"//executable_semantics/syntax",
"@com_google_googletest//:gtest",
"@com_google_protobuf//:protobuf_headers",
"@llvm-project//llvm:Support",
],
)
cc_binary(
name = "fuzzverter",
srcs = ["fuzzverter.cpp"],
deps = [
":ast_to_proto_lib",
":fuzzer_util",
"//common:error",
"//common/fuzzing:carbon_cc_proto",
"//executable_semantics/common:error",
"//executable_semantics/common:nonnull",
"//executable_semantics/syntax",
"@com_google_protobuf//:protobuf_headers",
"@llvm-project//llvm:Support",
],
)
cc_test(
name = "proto_to_carbon_test",
srcs = ["proto_to_carbon_test.cpp"],
args = [
"$(locations //executable_semantics:standard_libraries)",
"$(locations //executable_semantics/testdata:carbon_files)",
],
data = [
"//executable_semantics:standard_libraries",
"//executable_semantics/testdata:carbon_files",
],
deps = [
":ast_to_proto_lib",
"//common/fuzzing:carbon_cc_proto",
"//common/fuzzing:proto_to_carbon_lib",
"//executable_semantics/syntax",
"@com_google_googletest//:gtest",
"@com_google_protobuf//:protobuf_headers",
"@llvm-project//llvm:Support",
],
)
# Needs `--config=proto-fuzzer` for `bazel build` / `bazel test`.
cc_fuzz_test(
name = "executable_semantics_fuzzer",
size = "small",
srcs = ["executable_semantics_fuzzer.cpp"],
corpus = glob(["fuzzer_corpus/**"]),
tags = ["manual"],
deps = [
":fuzzer_util",
"//common/fuzzing:carbon_cc_proto",
"//executable_semantics/interpreter:exec_program",
"//executable_semantics/syntax",
"//executable_semantics/syntax:prelude",
"@com_google_libprotobuf_mutator//:libprotobuf_mutator",
"@com_google_protobuf//:protobuf_headers",
"@llvm-project//llvm:Support",
],
)