mirror of https://github.com/grpc/grpc.git
[fuzzing] Roll forward dep on fuzztest (#32667)
<!-- If you know who should review your pull request, please assign it to that person, otherwise the pull request would get assigned randomly. If your pull request is for a specific language, please add the appropriate lang label. --> --------- Co-authored-by: ctiller <ctiller@users.noreply.github.com>pull/32671/head
parent
91d64a3774
commit
2bcca66712
15 changed files with 182 additions and 7 deletions
@ -0,0 +1,25 @@ |
|||||||
|
# Copyright 2023 gRPC authors. |
||||||
|
# |
||||||
|
# Licensed under the Apache License, Version 2.0 (the "License"); |
||||||
|
# you may not use this file except in compliance with the License. |
||||||
|
# You may obtain a copy of the License at |
||||||
|
# |
||||||
|
# http://www.apache.org/licenses/LICENSE-2.0 |
||||||
|
# |
||||||
|
# Unless required by applicable law or agreed to in writing, software |
||||||
|
# distributed under the License is distributed on an "AS IS" BASIS, |
||||||
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
||||||
|
# See the License for the specific language governing permissions and |
||||||
|
# limitations under the License. |
||||||
|
|
||||||
|
load(":grpc_fuzz_test.bzl", "grpc_fuzz_test") |
||||||
|
|
||||||
|
grpc_fuzz_test( |
||||||
|
name = "fuzztest_test", |
||||||
|
srcs = ["fuzztest_test.cc"], |
||||||
|
external_deps = [ |
||||||
|
"fuzztest", |
||||||
|
"fuzztest_main", |
||||||
|
"gtest", |
||||||
|
], |
||||||
|
) |
@ -0,0 +1,7 @@ |
|||||||
|
Tests that leverage fuzztest. |
||||||
|
|
||||||
|
These require C++17 and so cannot be run with the standard build configurations. |
||||||
|
|
||||||
|
To run these tests: |
||||||
|
|
||||||
|
bazel run //fuzztest/path/to:test -c dbg --config fuzztest |
@ -0,0 +1,26 @@ |
|||||||
|
// Copyright 2023 gRPC authors.
|
||||||
|
//
|
||||||
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
// you may not use this file except in compliance with the License.
|
||||||
|
// You may obtain a copy of the License at
|
||||||
|
//
|
||||||
|
// http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
//
|
||||||
|
// Unless required by applicable law or agreed to in writing, software
|
||||||
|
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
// See the License for the specific language governing permissions and
|
||||||
|
// limitations under the License.
|
||||||
|
|
||||||
|
// Test to verify Fuzztest integration
|
||||||
|
|
||||||
|
#include "fuzztest/fuzztest.h" |
||||||
|
|
||||||
|
#include "gtest/gtest.h" |
||||||
|
|
||||||
|
TEST(MyTestSuite, OnePlustTwoIsTwoPlusOne) { EXPECT_EQ(1 + 2, 2 + 1); } |
||||||
|
|
||||||
|
void IntegerAdditionCommutes(unsigned a, unsigned b) { |
||||||
|
EXPECT_EQ(a + b, b + a); |
||||||
|
} |
||||||
|
FUZZ_TEST(MyTestSuite, IntegerAdditionCommutes); |
@ -0,0 +1,28 @@ |
|||||||
|
# Copyright 2023 gRPC authors. |
||||||
|
# |
||||||
|
# Licensed under the Apache License, Version 2.0 (the "License"); |
||||||
|
# you may not use this file except in compliance with the License. |
||||||
|
# You may obtain a copy of the License at |
||||||
|
# |
||||||
|
# http://www.apache.org/licenses/LICENSE-2.0 |
||||||
|
# |
||||||
|
# Unless required by applicable law or agreed to in writing, software |
||||||
|
# distributed under the License is distributed on an "AS IS" BASIS, |
||||||
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
||||||
|
# See the License for the specific language governing permissions and |
||||||
|
# limitations under the License. |
||||||
|
|
||||||
|
""" |
||||||
|
Rules for using fuzztest. |
||||||
|
""" |
||||||
|
|
||||||
|
load("//bazel:grpc_build_system.bzl", "grpc_cc_test") |
||||||
|
|
||||||
|
def grpc_fuzz_test(name, srcs = [], deps = [], tags = [], external_deps = []): |
||||||
|
grpc_cc_test( |
||||||
|
name = name, |
||||||
|
srcs = srcs, |
||||||
|
tags = tags + ["grpc-fuzzer", "no-cache"], |
||||||
|
deps = deps, |
||||||
|
external_deps = external_deps, |
||||||
|
) |
@ -0,0 +1,43 @@ |
|||||||
|
### DO NOT EDIT. Generated file. |
||||||
|
# |
||||||
|
# To regenerate, run the following from your project's workspace: |
||||||
|
# |
||||||
|
# bazel run @com_google_fuzztest//bazel:setup_configs > fuzztest.bazelrc |
||||||
|
# |
||||||
|
# And don't forget to add the following to your project's .bazelrc: |
||||||
|
# |
||||||
|
# try-import %workspace%/fuzztest.bazelrc |
||||||
|
|
||||||
|
|
||||||
|
### Common options. |
||||||
|
# |
||||||
|
# Do not use directly. |
||||||
|
|
||||||
|
# Link with Address Sanitizer (ASAN). |
||||||
|
build:fuzztest-common --linkopt=-fsanitize=address |
||||||
|
|
||||||
|
# Standard define for "ifdef-ing" any fuzz test specific code. |
||||||
|
build:fuzztest-common --copt=-DFUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION |
||||||
|
|
||||||
|
# In fuzz tests, we want to catch assertion violations even in optimized builds. |
||||||
|
build:fuzztest-common --copt=-UNDEBUG |
||||||
|
|
||||||
|
|
||||||
|
### FuzzTest build configuration. |
||||||
|
# |
||||||
|
# Use with: --config=fuzztest |
||||||
|
|
||||||
|
build:fuzztest --config=fuzztest-common |
||||||
|
|
||||||
|
# Link statically. |
||||||
|
build:fuzztest --dynamic_mode=off |
||||||
|
|
||||||
|
# We rely on the following flag instead of the compiler provided |
||||||
|
# __has_feature(address_sanitizer) to know that we have an ASAN build even in |
||||||
|
# the uninstrumented runtime. |
||||||
|
build:fuzztest --copt=-DADDRESS_SANITIZER |
||||||
|
|
||||||
|
# We apply coverage tracking and ASAN instrumentation to everything but the |
||||||
|
# FuzzTest framework itself (including GoogleTest and GoogleMock). |
||||||
|
build:fuzztest --per_file_copt=+//,-fuzztest/.*,-googletest/.*,-googlemock/.*@-fsanitize=address,-fsanitize-coverage=inline-8bit-counters,-fsanitize-coverage=trace-cmp |
||||||
|
|
Loading…
Reference in new issue