Skip to content

Commit

Permalink
x
Browse files Browse the repository at this point in the history
  • Loading branch information
ctiller committed Jan 24, 2025
1 parent f537413 commit d055999
Show file tree
Hide file tree
Showing 8 changed files with 39 additions and 130 deletions.
45 changes: 30 additions & 15 deletions test/core/util/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,10 @@
# 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_test", "grpc_package","grpc_cc_proto_library", "grpc_internal_proto_library")
load(
"//test/core/test_util:grpc_fuzzer.bzl",
"grpc_fuzz_test",
"grpc_proto_fuzzer",
)
load("//test/cpp/microbenchmarks:grpc_benchmark_config.bzl", "HISTORY", "grpc_cc_benchmark")

Expand Down Expand Up @@ -361,19 +360,25 @@ grpc_cc_test(
],
)

grpc_proto_fuzzer(
grpc_internal_proto_library(
name = "chunked_vector_fuzzer_proto",
srcs = ["chunked_vector_fuzzer.proto"],
)

grpc_cc_proto_library(
name = "chunked_vector_fuzzer_cc_proto",
deps = ["chunked_vector_fuzzer_proto"],
)

grpc_fuzz_test(
name = "chunked_vector_fuzzer",
srcs = ["chunked_vector_fuzzer.cc"],
corpus = "chunked_vector_corpora",
external_deps = ["absl/log:check"],
proto = "chunked_vector_fuzzer.proto",
tags = ["no_windows"],
uses_event_engine = False,
uses_polling = False,
external_deps = ["absl/log:check", "fuzztest", "fuzztest_main"],
deps = [
"//src/core:chunked_vector",
"//src/core:resource_quota",
"//test/core/test_util:grpc_test_util",
"chunked_vector_fuzzer_cc_proto",
],
)

Expand Down Expand Up @@ -720,17 +725,27 @@ grpc_cc_test(
],
)

grpc_proto_fuzzer(
grpc_internal_proto_library(
name = "avl_fuzzer_proto",
srcs = ["avl_fuzzer.proto"],
)

grpc_cc_proto_library(
name = "avl_fuzzer_cc_proto",
deps = ["avl_fuzzer_proto"],
)

grpc_fuzz_test(
name = "avl_fuzzer",
srcs = ["avl_fuzzer.cc"],
corpus = "avl_fuzzer_corpus",
proto = "avl_fuzzer.proto",
tags = ["no_windows"],
uses_event_engine = False,
uses_polling = False,
external_deps = [
"fuzztest",
"fuzztest_main",
],
deps = [
"//src/core:avl",
"//test/core/test_util:grpc_test_util",
"avl_fuzzer_cc_proto",
],
)

Expand Down
9 changes: 5 additions & 4 deletions test/core/util/avl_fuzzer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
#include <utility>

#include "src/core/util/avl.h"
#include "src/libfuzzer/libfuzzer_macro.h"
#include "fuzztest/fuzztest.h"
#include "test/core/util/avl_fuzzer.pb.h"

bool squelch = true;
Expand Down Expand Up @@ -88,9 +88,7 @@ std::map<int, int> MapFromProto(const RepeatedField& p) {
return a;
}

} // namespace grpc_core

DEFINE_PROTO_FUZZER(const avl_fuzzer::Msg& msg) {
void SameAsMap(const avl_fuzzer::Msg& msg) {
grpc_core::Fuzzer fuzzer;
for (const auto& action : msg.actions()) {
grpc_core::Fuzzer().Run(action);
Expand All @@ -105,3 +103,6 @@ DEFINE_PROTO_FUZZER(const avl_fuzzer::Msg& msg) {
if ((left_avl < right_avl) != (left_map < right_map)) abort();
}
}
FUZZ_TEST(AvlFuzzer, SameAsMap);

} // namespace grpc_core
1 change: 0 additions & 1 deletion test/core/util/avl_fuzzer_corpus/0

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

79 changes: 0 additions & 79 deletions test/core/util/chunked_vector_corpora/testcase-5405829431427072

This file was deleted.

7 changes: 4 additions & 3 deletions test/core/util/chunked_vector_fuzzer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@
#include "src/core/lib/resource_quota/resource_quota.h"
#include "src/core/util/chunked_vector.h"
#include "src/core/util/ref_counted_ptr.h"
#include "src/libfuzzer/libfuzzer_macro.h"
#include "test/core/util/chunked_vector_fuzzer.pb.h"
#include "fuzztest/fuzztest.h"

bool squelch = true;
bool leak_check = true;
Expand Down Expand Up @@ -169,11 +169,12 @@ class Fuzzer {
RefCountedPtr<Arena> arena_ = SimpleArenaAllocator(128)->MakeArena();
std::map<int, Comparison> vectors_;
};
} // namespace grpc_core

DEFINE_PROTO_FUZZER(const chunked_vector_fuzzer::Msg& msg) {
void SameAsVector(const chunked_vector_fuzzer::Msg& msg) {
grpc_core::Fuzzer fuzzer;
for (int i = 0; i < msg.actions_size(); i++) {
fuzzer.Act(msg.actions(i));
}
}
FUZZ_TEST(ChunkedVectorTest, SameAsVector);
} // namespace grpc_core

0 comments on commit d055999

Please sign in to comment.