Skip to content

Commit

Permalink
[fuzzers] Move http2 flow control fuzzer to fuzztest (grpc#38558)
Browse files Browse the repository at this point in the history
Closes grpc#38558

COPYBARA_INTEGRATE_REVIEW=grpc#38558 from ctiller:h2 37de9d3
PiperOrigin-RevId: 720243720
  • Loading branch information
ctiller authored and copybara-github committed Jan 27, 2025
1 parent 27f0905 commit 37f5195
Show file tree
Hide file tree
Showing 13 changed files with 30 additions and 1,553 deletions.
27 changes: 19 additions & 8 deletions test/core/transport/chttp2/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
# limitations under the License.

load("//bazel:custom_exec_properties.bzl", "LARGE_MACHINE")
load("//bazel:grpc_build_system.bzl", "grpc_cc_test", "grpc_package")
load("//bazel:grpc_build_system.bzl", "grpc_cc_proto_library", "grpc_cc_test", "grpc_internal_proto_library", "grpc_package")
load("//test/core/test_util:grpc_fuzzer.bzl", "grpc_fuzz_test", "grpc_fuzzer", "grpc_proto_fuzzer")

licenses(["notice"])
Expand Down Expand Up @@ -55,17 +55,28 @@ grpc_proto_fuzzer(
],
)

grpc_proto_fuzzer(
grpc_internal_proto_library(
name = "flow_control_fuzzer_proto",
srcs = ["flow_control_fuzzer.proto"],
deps = ["//test/core/test_util:fuzz_config_vars_proto"],
)

grpc_cc_proto_library(
name = "flow_control_fuzzer_cc_proto",
deps = ["flow_control_fuzzer_proto"],
)

grpc_fuzz_test(
name = "flow_control_fuzzer",
srcs = ["flow_control_fuzzer.cc"],
corpus = "flow_control_fuzzer_corpus",
external_deps = ["absl/log:check"],
proto = "flow_control_fuzzer.proto",
proto_deps = ["//test/core/test_util:fuzz_config_vars_proto"],
external_deps = [
"absl/log:check",
"fuzztest",
"fuzztest_main",
],
tags = ["no_windows"],
uses_event_engine = False,
uses_polling = False,
deps = [
"flow_control_fuzzer_cc_proto",
"//:gpr",
"//src/core:chttp2_flow_control",
"//test/core/test_util:fuzz_config_vars",
Expand Down
21 changes: 11 additions & 10 deletions test/core/transport/chttp2/flow_control_fuzzer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -32,14 +32,14 @@
#include "absl/log/check.h"
#include "absl/status/status.h"
#include "absl/strings/str_join.h"
#include "fuzztest/fuzztest.h"
#include "src/core/ext/transport/chttp2/transport/flow_control.h"
#include "src/core/lib/experiments/config.h"
#include "src/core/lib/iomgr/exec_ctx.h"
#include "src/core/lib/resource_quota/memory_quota.h"
#include "src/core/lib/transport/bdp_estimator.h"
#include "src/core/util/time.h"
#include "src/core/util/useful.h"
#include "src/libfuzzer/libfuzzer_macro.h"
#include "test/core/test_util/fuzz_config_vars.h"
#include "test/core/transport/chttp2/flow_control_fuzzer.pb.h"

Expand Down Expand Up @@ -470,15 +470,11 @@ void FlowControlFuzzer::AssertAnnouncedOverInitialWindowSizeCorrect() const {
tfc_->announced_stream_total_over_incoming_window());
}

} // namespace
} // namespace chttp2
} // namespace grpc_core

DEFINE_PROTO_FUZZER(const flow_control_fuzzer::Msg& msg) {
grpc_core::ApplyFuzzConfigVars(msg.config_vars());
grpc_core::TestOnlyReloadExperimentsFromConfigVariables();
grpc_core::chttp2::InitGlobals();
grpc_core::chttp2::FlowControlFuzzer fuzzer(msg.enable_bdp());
void Test(flow_control_fuzzer::Msg msg) {
ApplyFuzzConfigVars(msg.config_vars());
TestOnlyReloadExperimentsFromConfigVariables();
chttp2::InitGlobals();
chttp2::FlowControlFuzzer fuzzer(msg.enable_bdp());
for (const auto& action : msg.actions()) {
if (!squelch) {
fprintf(stderr, "%s\n", action.DebugString().c_str());
Expand All @@ -488,3 +484,8 @@ DEFINE_PROTO_FUZZER(const flow_control_fuzzer::Msg& msg) {
fuzzer.AssertAnnouncedOverInitialWindowSizeCorrect();
}
}
FUZZ_TEST(FlowControl, Test);

} // namespace
} // namespace chttp2
} // namespace grpc_core
Loading

0 comments on commit 37f5195

Please sign in to comment.