[grpc][Gpr_To_Absl_Logging] Migrating from gpr to absl logging GPR_ASSERT (#36436)

[grpc][Gpr_To_Absl_Logging] Migrating from gpr to absl logging GPR_ASSERT
Replacing GPR_ASSERT with absl CHECK

These changes have been made using string replacement and regex.

Will not be replacing all instances of CHECK with CHECK_EQ , CHECK_NE etc because there are too many callsites. Only ones which are doable using very simple regex with least chance of failure will be replaced.

Given that we have 5000+ instances of GPR_ASSERT to edit, Doing it manually is too much work for both the author and reviewer.

<!--

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.

-->

Closes #36436

COPYBARA_INTEGRATE_REVIEW=https://github.com/grpc/grpc/pull/36436 from tanvi-jagtap:tjagtap_core_transport 8e25f5ae7b
PiperOrigin-RevId: 627925972
pull/36136/merge
Tanvi Jagtap 9 months ago committed by Copybara-Service
parent 4da74a52a0
commit 4fdd2a8786
  1. 1
      CMakeLists.txt
  2. 1
      build_autogenerated.yaml
  3. 1
      test/core/transport/BUILD
  4. 2
      test/core/transport/binder/end2end/BUILD
  5. 3
      test/core/transport/binder/end2end/fuzzers/BUILD
  6. 7
      test/core/transport/binder/end2end/fuzzers/client_fuzzer.cc
  7. 4
      test/core/transport/binder/end2end/fuzzers/fuzzer_utils.cc
  8. 8
      test/core/transport/binder/end2end/fuzzers/server_fuzzer.cc
  9. 6
      test/core/transport/binder/end2end/testing_channel_create.cc
  10. 3
      test/core/transport/chaotic_good/BUILD
  11. 9
      test/core/transport/chaotic_good/chaotic_good_server_test.cc
  12. 9
      test/core/transport/chaotic_good/frame_fuzzer.cc
  13. 9
      test/core/transport/chaotic_good/frame_test.cc
  14. 2
      test/core/transport/chttp2/flow_control_fuzzer.cc
  15. 2
      test/core/transport/chttp2/remove_stream_from_stalled_lists_test.cc
  16. 4
      test/core/transport/chttp2/stream_leak_with_queued_flow_control_update_test.cc
  17. 2
      test/core/transport/chttp2/streams_not_seen_test.cc
  18. 6
      test/core/transport/chttp2/too_many_pings_test.cc
  19. 7
      test/core/transport/parsed_metadata_test.cc
  20. 5
      test/core/transport/test_suite/BUILD
  21. 7
      test/core/transport/test_suite/chaotic_good_fixture.cc
  22. 8
      test/core/transport/test_suite/fuzzer_main.cc
  23. 1
      test/core/transport/test_suite/grpc_transport_test.bzl

1
CMakeLists.txt generated

@ -21368,6 +21368,7 @@ target_include_directories(parsed_metadata_test
target_link_libraries(parsed_metadata_test target_link_libraries(parsed_metadata_test
${_gRPC_ALLTARGETS_LIBRARIES} ${_gRPC_ALLTARGETS_LIBRARIES}
gtest gtest
absl::check
grpc_test_util grpc_test_util
) )

@ -14062,6 +14062,7 @@ targets:
- test/core/transport/parsed_metadata_test.cc - test/core/transport/parsed_metadata_test.cc
deps: deps:
- gtest - gtest
- absl/log:check
- grpc_test_util - grpc_test_util
- name: parser_test - name: parser_test
gtest: true gtest: true

@ -116,6 +116,7 @@ grpc_cc_test(
name = "parsed_metadata_test", name = "parsed_metadata_test",
srcs = ["parsed_metadata_test.cc"], srcs = ["parsed_metadata_test.cc"],
external_deps = [ external_deps = [
"absl/log:check",
"gtest", "gtest",
], ],
language = "C++", language = "C++",

@ -63,7 +63,7 @@ grpc_cc_library(
testonly = 1, testonly = 1,
srcs = ["testing_channel_create.cc"], srcs = ["testing_channel_create.cc"],
hdrs = ["testing_channel_create.h"], hdrs = ["testing_channel_create.h"],
external_deps = [], external_deps = ["absl/log:check"],
deps = [ deps = [
":fake_binder", ":fake_binder",
"//:grpc++_base", "//:grpc++_base",

@ -35,6 +35,7 @@ grpc_proto_library(
grpc_cc_library( grpc_cc_library(
name = "fuzzer_utils", name = "fuzzer_utils",
srcs = ["fuzzer_utils.cc"], srcs = ["fuzzer_utils.cc"],
external_deps = ["absl/log:check"],
language = "c++", language = "c++",
public_hdrs = ["fuzzer_utils.h"], public_hdrs = ["fuzzer_utils.h"],
deps = [ deps = [
@ -53,6 +54,7 @@ grpc_proto_fuzzer(
"client_fuzzer.cc", "client_fuzzer.cc",
], ],
corpus = "binder_transport_client_fuzzer_corpus", corpus = "binder_transport_client_fuzzer_corpus",
external_deps = ["absl/log:check"],
owner = "binder", owner = "binder",
proto = "client.proto", proto = "client.proto",
tags = [ tags = [
@ -76,6 +78,7 @@ grpc_proto_fuzzer(
"server_fuzzer.cc", "server_fuzzer.cc",
], ],
corpus = "binder_transport_server_fuzzer_corpus", corpus = "binder_transport_server_fuzzer_corpus",
external_deps = ["absl/log:check"],
owner = "binder", owner = "binder",
proto = "server.proto", proto = "server.proto",
tags = [ tags = [

@ -15,6 +15,7 @@
#include <thread> #include <thread>
#include <utility> #include <utility>
#include "absl/log/check.h"
#include "absl/memory/memory.h" #include "absl/memory/memory.h"
#include <grpc/grpc.h> #include <grpc/grpc.h>
@ -110,7 +111,7 @@ DEFINE_PROTO_FUZZER(const binder_transport_fuzzer::Input& input) {
grpc_call_error error = grpc_call_start_batch( grpc_call_error error = grpc_call_start_batch(
call, ops, static_cast<size_t>(op - ops), tag(1), nullptr); call, ops, static_cast<size_t>(op - ops), tag(1), nullptr);
int requested_calls = 1; int requested_calls = 1;
GPR_ASSERT(GRPC_CALL_OK == error); CHECK_EQ(error, GRPC_CALL_OK);
grpc_event ev; grpc_event ev;
while (true) { while (true) {
grpc_core::ExecCtx::Get()->Flush(); grpc_core::ExecCtx::Get()->Flush();
@ -135,13 +136,13 @@ DEFINE_PROTO_FUZZER(const binder_transport_fuzzer::Input& input) {
for (int i = 0; i < requested_calls; i++) { for (int i = 0; i < requested_calls; i++) {
ev = grpc_completion_queue_next(cq, gpr_inf_past(GPR_CLOCK_REALTIME), ev = grpc_completion_queue_next(cq, gpr_inf_past(GPR_CLOCK_REALTIME),
nullptr); nullptr);
GPR_ASSERT(ev.type == GRPC_OP_COMPLETE); CHECK(ev.type == GRPC_OP_COMPLETE);
} }
grpc_completion_queue_shutdown(cq); grpc_completion_queue_shutdown(cq);
for (int i = 0; i < requested_calls; i++) { for (int i = 0; i < requested_calls; i++) {
ev = grpc_completion_queue_next(cq, gpr_inf_past(GPR_CLOCK_REALTIME), ev = grpc_completion_queue_next(cq, gpr_inf_past(GPR_CLOCK_REALTIME),
nullptr); nullptr);
GPR_ASSERT(ev.type == GRPC_QUEUE_SHUTDOWN); CHECK(ev.type == GRPC_QUEUE_SHUTDOWN);
} }
grpc_call_unref(call); grpc_call_unref(call);
grpc_completion_queue_destroy(cq); grpc_completion_queue_destroy(cq);

@ -14,6 +14,8 @@
#include "test/core/transport/binder/end2end/fuzzers/fuzzer_utils.h" #include "test/core/transport/binder/end2end/fuzzers/fuzzer_utils.h"
#include "absl/log/check.h"
namespace grpc_binder { namespace grpc_binder {
namespace fuzzing { namespace fuzzing {
@ -23,7 +25,7 @@ std::thread* g_fuzzing_thread = nullptr;
template <typename... Args> template <typename... Args>
void CreateFuzzingThread(Args&&... args) { void CreateFuzzingThread(Args&&... args) {
GPR_ASSERT(g_fuzzing_thread == nullptr); CHECK_EQ(g_fuzzing_thread, nullptr);
g_fuzzing_thread = new std::thread(std::forward<Args>(args)...); g_fuzzing_thread = new std::thread(std::forward<Args>(args)...);
} }

@ -12,6 +12,8 @@
// See the License for the specific language governing permissions and // See the License for the specific language governing permissions and
// limitations under the License. // limitations under the License.
#include "absl/log/check.h"
#include <grpc/grpc.h> #include <grpc/grpc.h>
#include "src/core/ext/transport/binder/transport/binder_transport.h" #include "src/core/ext/transport/binder/transport/binder_transport.h"
@ -62,7 +64,7 @@ DEFINE_PROTO_FUZZER(const binder_transport_fuzzer::Input& input) {
grpc_metadata_array_init(&request_metadata1); grpc_metadata_array_init(&request_metadata1);
int requested_calls = 0; int requested_calls = 0;
GPR_ASSERT(GRPC_CALL_OK == CHECK(GRPC_CALL_OK ==
grpc_server_request_call(server, &call1, &call_details1, grpc_server_request_call(server, &call1, &call_details1,
&request_metadata1, cq, cq, tag(1))); &request_metadata1, cq, cq, tag(1)));
requested_calls++; requested_calls++;
@ -111,7 +113,7 @@ DEFINE_PROTO_FUZZER(const binder_transport_fuzzer::Input& input) {
grpc_core::ExecCtx::Get()->InvalidateNow(); grpc_core::ExecCtx::Get()->InvalidateNow();
} while (ev.type != GRPC_OP_COMPLETE && } while (ev.type != GRPC_OP_COMPLETE &&
grpc_core::Timestamp::Now() < deadline); grpc_core::Timestamp::Now() < deadline);
GPR_ASSERT(ev.type == GRPC_OP_COMPLETE); CHECK(ev.type == GRPC_OP_COMPLETE);
} }
grpc_completion_queue_shutdown(cq); grpc_completion_queue_shutdown(cq);
for (int i = 0; i <= requested_calls; i++) { for (int i = 0; i <= requested_calls; i++) {
@ -121,7 +123,7 @@ DEFINE_PROTO_FUZZER(const binder_transport_fuzzer::Input& input) {
grpc_core::ExecCtx::Get()->InvalidateNow(); grpc_core::ExecCtx::Get()->InvalidateNow();
} while (ev.type != GRPC_QUEUE_SHUTDOWN && } while (ev.type != GRPC_QUEUE_SHUTDOWN &&
grpc_core::Timestamp::Now() < deadline); grpc_core::Timestamp::Now() < deadline);
GPR_ASSERT(ev.type == GRPC_QUEUE_SHUTDOWN); CHECK(ev.type == GRPC_QUEUE_SHUTDOWN);
} }
grpc_server_destroy(server); grpc_server_destroy(server);
grpc_completion_queue_destroy(cq); grpc_completion_queue_destroy(cq);

@ -16,6 +16,8 @@
#include <utility> #include <utility>
#include "absl/log/check.h"
#include <grpcpp/security/binder_security_policy.h> #include <grpcpp/security/binder_security_policy.h>
#include "src/core/ext/transport/binder/transport/binder_transport.h" #include "src/core/ext/transport/binder/transport/binder_transport.h"
@ -124,9 +126,9 @@ grpc_channel* grpc_binder_channel_create_for_testing(
grpc_binder::end2end_testing::CreateClientServerBindersPairForTesting(); grpc_binder::end2end_testing::CreateClientServerBindersPairForTesting();
grpc_error_handle error = grpc_core::Server::FromC(server)->SetupTransport( grpc_error_handle error = grpc_core::Server::FromC(server)->SetupTransport(
server_transport, nullptr, server_args, nullptr); server_transport, nullptr, server_args, nullptr);
GPR_ASSERT(error.ok()); CHECK_OK(error);
auto channel = grpc_core::ChannelCreate( auto channel = grpc_core::ChannelCreate(
"binder", client_args, GRPC_CLIENT_DIRECT_CHANNEL, client_transport); "binder", client_args, GRPC_CLIENT_DIRECT_CHANNEL, client_transport);
GPR_ASSERT(channel.ok()); CHECK_OK(channel);
return channel->release()->c_ptr(); return channel->release()->c_ptr();
} }

@ -77,6 +77,7 @@ grpc_cc_test(
name = "frame_test", name = "frame_test",
srcs = ["frame_test.cc"], srcs = ["frame_test.cc"],
external_deps = [ external_deps = [
"absl/log:check",
"absl/random", "absl/random",
"absl/status", "absl/status",
"absl/status:statusor", "absl/status:statusor",
@ -93,6 +94,7 @@ grpc_proto_fuzzer(
srcs = ["frame_fuzzer.cc"], srcs = ["frame_fuzzer.cc"],
corpus = "frame_fuzzer_corpus", corpus = "frame_fuzzer_corpus",
external_deps = [ external_deps = [
"absl/log:check",
"absl/random:bit_gen_ref", "absl/random:bit_gen_ref",
"absl/status:statusor", "absl/status:statusor",
], ],
@ -221,6 +223,7 @@ grpc_cc_test(
name = "chaotic_good_server_test", name = "chaotic_good_server_test",
srcs = ["chaotic_good_server_test.cc"], srcs = ["chaotic_good_server_test.cc"],
external_deps = [ external_deps = [
"absl/log:check",
"absl/strings", "absl/strings",
"absl/time", "absl/time",
"gtest", "gtest",

@ -18,6 +18,7 @@
#include <string> #include <string>
#include <utility> #include <utility>
#include "absl/log/check.h"
#include "absl/strings/str_cat.h" #include "absl/strings/str_cat.h"
#include "absl/time/time.h" #include "absl/time/time.h"
#include "gmock/gmock.h" #include "gmock/gmock.h"
@ -66,8 +67,8 @@ class ChaoticGoodServerTest : public ::testing::Test {
auto ev = grpc_completion_queue_pluck( auto ev = grpc_completion_queue_pluck(
shutdown_cq, nullptr, grpc_timeout_milliseconds_to_deadline(15000), shutdown_cq, nullptr, grpc_timeout_milliseconds_to_deadline(15000),
nullptr); nullptr);
GPR_ASSERT(ev.type == GRPC_OP_COMPLETE); CHECK(ev.type == GRPC_OP_COMPLETE);
GPR_ASSERT(ev.tag == nullptr); CHECK_EQ(ev.tag, nullptr);
grpc_completion_queue_destroy(shutdown_cq); grpc_completion_queue_destroy(shutdown_cq);
grpc_server_destroy(server_); grpc_server_destroy(server_);
} }
@ -82,8 +83,8 @@ class ChaoticGoodServerTest : public ::testing::Test {
void ConstructConnector() { void ConstructConnector() {
auto uri = URI::Parse("ipv6:" + addr_); auto uri = URI::Parse("ipv6:" + addr_);
GPR_ASSERT(uri.ok()); CHECK_OK(uri);
GPR_ASSERT(grpc_parse_uri(*uri, &resolved_addr_)); CHECK(grpc_parse_uri(*uri, &resolved_addr_));
args_.address = &resolved_addr_; args_.address = &resolved_addr_;
args_.deadline = Timestamp::Now() + Duration::Seconds(5); args_.deadline = Timestamp::Now() + Duration::Seconds(5);
args_.channel_args = channel_args(); args_.channel_args = channel_args();

@ -18,6 +18,7 @@
#include <limits> #include <limits>
#include <memory> #include <memory>
#include "absl/log/check.h"
#include "absl/random/bit_gen_ref.h" #include "absl/random/bit_gen_ref.h"
#include "absl/status/statusor.h" #include "absl/status/statusor.h"
@ -55,7 +56,7 @@ template <typename T>
void AssertRoundTrips(const T& input, FrameType expected_frame_type) { void AssertRoundTrips(const T& input, FrameType expected_frame_type) {
HPackCompressor hpack_compressor; HPackCompressor hpack_compressor;
auto serialized = input.Serialize(&hpack_compressor); auto serialized = input.Serialize(&hpack_compressor);
GPR_ASSERT(serialized.control.Length() >= CHECK(serialized.control.Length() >=
24); // Initial output buffer size is 64 byte. 24); // Initial output buffer size is 64 byte.
uint8_t header_bytes[24]; uint8_t header_bytes[24];
serialized.control.MoveFirstNBytesIntoBuffer(24, header_bytes); serialized.control.MoveFirstNBytesIntoBuffer(24, header_bytes);
@ -67,15 +68,15 @@ void AssertRoundTrips(const T& input, FrameType expected_frame_type) {
} }
Crash("Failed to parse header"); Crash("Failed to parse header");
} }
GPR_ASSERT(header->type == expected_frame_type); CHECK(header->type == expected_frame_type);
T output; T output;
HPackParser hpack_parser; HPackParser hpack_parser;
DeterministicBitGen bitgen; DeterministicBitGen bitgen;
auto deser = output.Deserialize(&hpack_parser, header.value(), auto deser = output.Deserialize(&hpack_parser, header.value(),
absl::BitGenRef(bitgen), GetContext<Arena>(), absl::BitGenRef(bitgen), GetContext<Arena>(),
std::move(serialized), FuzzerFrameLimits()); std::move(serialized), FuzzerFrameLimits());
GPR_ASSERT(deser.ok()); CHECK_OK(deser);
GPR_ASSERT(output == input); CHECK(output == input);
} }
template <typename T> template <typename T>

@ -16,6 +16,7 @@
#include <cstdint> #include <cstdint>
#include "absl/log/check.h"
#include "absl/random/random.h" #include "absl/random/random.h"
#include "absl/status/status.h" #include "absl/status/status.h"
#include "absl/status/statusor.h" #include "absl/status/statusor.h"
@ -34,7 +35,7 @@ template <typename T>
void AssertRoundTrips(const T& input, FrameType expected_frame_type) { void AssertRoundTrips(const T& input, FrameType expected_frame_type) {
HPackCompressor hpack_compressor; HPackCompressor hpack_compressor;
auto serialized = input.Serialize(&hpack_compressor); auto serialized = input.Serialize(&hpack_compressor);
GPR_ASSERT(serialized.control.Length() >= CHECK_GE(serialized.control.Length(),
24); // Initial output buffer size is 64 byte. 24); // Initial output buffer size is 64 byte.
uint8_t header_bytes[24]; uint8_t header_bytes[24];
serialized.control.MoveFirstNBytesIntoBuffer(24, header_bytes); serialized.control.MoveFirstNBytesIntoBuffer(24, header_bytes);
@ -42,7 +43,7 @@ void AssertRoundTrips(const T& input, FrameType expected_frame_type) {
if (!header.ok()) { if (!header.ok()) {
Crash("Failed to parse header"); Crash("Failed to parse header");
} }
GPR_ASSERT(header->type == expected_frame_type); CHECK(header->type == expected_frame_type);
T output; T output;
HPackParser hpack_parser; HPackParser hpack_parser;
absl::BitGen bitgen; absl::BitGen bitgen;
@ -53,8 +54,8 @@ void AssertRoundTrips(const T& input, FrameType expected_frame_type) {
auto deser = auto deser =
output.Deserialize(&hpack_parser, header.value(), absl::BitGenRef(bitgen), output.Deserialize(&hpack_parser, header.value(), absl::BitGenRef(bitgen),
arena.get(), std::move(serialized), TestFrameLimits()); arena.get(), std::move(serialized), TestFrameLimits());
GPR_ASSERT(deser.ok()); CHECK_OK(deser);
GPR_ASSERT(output == input); CHECK(output == input);
} }
TEST(FrameTest, SettingsFrameRoundTrips) { TEST(FrameTest, SettingsFrameRoundTrips) {

@ -246,7 +246,7 @@ void FlowControlFuzzer::Perform(const flow_control_fuzzer::Action& action) {
bdp->AddIncomingBytes(stream_write.size); bdp->AddIncomingBytes(stream_write.size);
} }
StreamFlowControl::IncomingUpdateContext upd(&stream->fc); StreamFlowControl::IncomingUpdateContext upd(&stream->fc);
CHECK(upd.RecvData(stream_write.size).ok()); CHECK_OK(upd.RecvData(stream_write.size));
PerformAction(upd.MakeAction(), stream); PerformAction(upd.MakeAction(), stream);
} }
send_from_remote_.pop_front(); send_from_remote_.pop_front();

@ -200,7 +200,7 @@ class TestServer {
grpc_call_error error = grpc_server_request_call( grpc_call_error error = grpc_server_request_call(
server_, &call, &call_details, &request_metadata_recv, call_cq, server_, &call, &call_details, &request_metadata_recv, call_cq,
cq_, request_call_tag); cq_, request_call_tag);
CHECK(error == GRPC_CALL_OK); CHECK_EQ(error, GRPC_CALL_OK);
} }
} }
grpc_event event = grpc_completion_queue_next( grpc_event event = grpc_completion_queue_next(

@ -80,7 +80,7 @@ class TestServer {
grpc_call* call; grpc_call* call;
grpc_call_error error = grpc_server_request_call( grpc_call_error error = grpc_server_request_call(
server_, &call, &call_details, &request_metadata_recv, cq_, cq_, tag); server_, &call, &call_details, &request_metadata_recv, cq_, cq_, tag);
CHECK(error == GRPC_CALL_OK); CHECK_EQ(error, GRPC_CALL_OK);
grpc_event event = grpc_completion_queue_next( grpc_event event = grpc_completion_queue_next(
cq_, gpr_inf_future(GPR_CLOCK_REALTIME), nullptr); cq_, gpr_inf_future(GPR_CLOCK_REALTIME), nullptr);
CHECK(event.type == GRPC_OP_COMPLETE); CHECK(event.type == GRPC_OP_COMPLETE);
@ -112,7 +112,7 @@ class TestServer {
op++; op++;
error = grpc_call_start_batch(call, ops, static_cast<size_t>(op - ops), tag, error = grpc_call_start_batch(call, ops, static_cast<size_t>(op - ops), tag,
nullptr); nullptr);
CHECK(error == GRPC_CALL_OK); CHECK_EQ(error, GRPC_CALL_OK);
event = grpc_completion_queue_next(cq_, gpr_inf_future(GPR_CLOCK_REALTIME), event = grpc_completion_queue_next(cq_, gpr_inf_future(GPR_CLOCK_REALTIME),
nullptr); nullptr);
CHECK(event.type == GRPC_OP_COMPLETE); CHECK(event.type == GRPC_OP_COMPLETE);

@ -365,7 +365,7 @@ class StreamsNotSeenTest : public ::testing::Test {
} }
static void OnWriteDone(void* arg, grpc_error_handle error) { static void OnWriteDone(void* arg, grpc_error_handle error) {
CHECK(error.ok()); CHECK_OK(error);
Notification* on_write_done_notification_ = static_cast<Notification*>(arg); Notification* on_write_done_notification_ = static_cast<Notification*>(arg);
on_write_done_notification_->Notify(); on_write_done_notification_->Notify();
} }

@ -442,7 +442,7 @@ grpc_core::Resolver::Result BuildResolverResult(
if (!uri.ok()) { if (!uri.ok()) {
gpr_log(GPR_ERROR, "Failed to parse uri. Error: %s", gpr_log(GPR_ERROR, "Failed to parse uri. Error: %s",
uri.status().ToString().c_str()); uri.status().ToString().c_str());
CHECK(uri.ok()); CHECK_OK(uri);
} }
grpc_resolved_address address; grpc_resolved_address address;
CHECK(grpc_parse_uri(*uri, &address)); CHECK(grpc_parse_uri(*uri, &address));
@ -702,8 +702,8 @@ void PerformCallWithResponsePayload(grpc_channel* channel, grpc_server* server,
cqv.Verify(); cqv.Verify();
CHECK(status == GRPC_STATUS_OK); CHECK(status == GRPC_STATUS_OK);
CHECK(0 == grpc_slice_str_cmp(details, "xyz")); CHECK_EQ(grpc_slice_str_cmp(details, "xyz"), 0);
CHECK(0 == grpc_slice_str_cmp(call_details.method, "/foo")); CHECK_EQ(grpc_slice_str_cmp(call_details.method, "/foo"), 0);
CHECK_EQ(was_cancelled, 0); CHECK_EQ(was_cancelled, 0);
CHECK(byte_buffer_eq_slice(response_payload_recv, response_payload_slice)); CHECK(byte_buffer_eq_slice(response_payload_recv, response_payload_slice));

@ -18,6 +18,7 @@
#include <memory> #include <memory>
#include "absl/log/check.h"
#include "absl/strings/numbers.h" #include "absl/strings/numbers.h"
#include "gmock/gmock.h" #include "gmock/gmock.h"
#include "gtest/gtest.h" #include "gtest/gtest.h"
@ -55,7 +56,7 @@ struct Int32Trait {
static int32_t MementoToValue(int32_t memento) { return memento; } static int32_t MementoToValue(int32_t memento) { return memento; }
static int32_t ParseMemento(Slice slice, bool, MetadataParseErrorFn) { static int32_t ParseMemento(Slice slice, bool, MetadataParseErrorFn) {
int32_t out; int32_t out;
GPR_ASSERT(absl::SimpleAtoi(slice.as_string_view(), &out)); CHECK(absl::SimpleAtoi(slice.as_string_view(), &out));
return out; return out;
} }
static std::string DisplayValue(int32_t value) { static std::string DisplayValue(int32_t value) {
@ -75,7 +76,7 @@ struct Int64Trait {
static int64_t MementoToValue(int64_t memento) { return -memento; } static int64_t MementoToValue(int64_t memento) { return -memento; }
static int64_t ParseMemento(Slice slice, bool, MetadataParseErrorFn) { static int64_t ParseMemento(Slice slice, bool, MetadataParseErrorFn) {
int64_t out; int64_t out;
GPR_ASSERT(absl::SimpleAtoi(slice.as_string_view(), &out)); CHECK(absl::SimpleAtoi(slice.as_string_view(), &out));
return out; return out;
} }
static std::string DisplayValue(int64_t value) { static std::string DisplayValue(int64_t value) {
@ -95,7 +96,7 @@ struct IntptrTrait {
static intptr_t MementoToValue(intptr_t memento) { return memento / 2; } static intptr_t MementoToValue(intptr_t memento) { return memento / 2; }
static intptr_t ParseMemento(Slice slice, bool, MetadataParseErrorFn) { static intptr_t ParseMemento(Slice slice, bool, MetadataParseErrorFn) {
intptr_t out; intptr_t out;
GPR_ASSERT(absl::SimpleAtoi(slice.as_string_view(), &out)); CHECK(absl::SimpleAtoi(slice.as_string_view(), &out));
return out; return out;
} }
static std::string DisplayValue(intptr_t value) { static std::string DisplayValue(intptr_t value) {

@ -48,7 +48,10 @@ grpc_cc_library(
name = "chaotic_good_fixture", name = "chaotic_good_fixture",
testonly = 1, testonly = 1,
srcs = ["chaotic_good_fixture.cc"], srcs = ["chaotic_good_fixture.cc"],
external_deps = ["gtest"], external_deps = [
"absl/log:check",
"gtest",
],
deps = [ deps = [
"fixture", "fixture",
"//src/core:chaotic_good_client_transport", "//src/core:chaotic_good_client_transport",

@ -14,6 +14,7 @@
#include <memory> #include <memory>
#include "absl/log/check.h"
#include "gmock/gmock.h" #include "gmock/gmock.h"
#include "src/core/ext/transport/chaotic_good/client_transport.h" #include "src/core/ext/transport/chaotic_good/client_transport.h"
@ -67,13 +68,13 @@ EndpointPair CreateEndpointPair(
[](absl::Status) {}, endpoint_config, [](absl::Status) {}, endpoint_config,
std::make_unique<MemoryQuotaBasedMemoryAllocatorFactory>( std::make_unique<MemoryQuotaBasedMemoryAllocatorFactory>(
resource_quota->memory_quota())); resource_quota->memory_quota()));
GPR_ASSERT(listener->Bind(resolved_address).ok()); CHECK_OK(listener->Bind(resolved_address));
GPR_ASSERT(listener->Start().ok()); CHECK_OK(listener->Start());
event_engine->Connect( event_engine->Connect(
[&client_endpoint]( [&client_endpoint](
absl::StatusOr<std::unique_ptr<EventEngine::Endpoint>> endpoint) { absl::StatusOr<std::unique_ptr<EventEngine::Endpoint>> endpoint) {
GPR_ASSERT(endpoint.ok()); CHECK_OK(endpoint);
client_endpoint = std::move(endpoint).value(); client_endpoint = std::move(endpoint).value();
}, },
resolved_address, endpoint_config, resolved_address, endpoint_config,

@ -16,6 +16,8 @@
#include <gtest/gtest.h> #include <gtest/gtest.h>
#include "absl/log/check.h"
#include <grpc/event_engine/event_engine.h> #include <grpc/event_engine/event_engine.h>
#include <grpc/support/log.h> #include <grpc/support/log.h>
@ -37,8 +39,8 @@ static void dont_log(gpr_log_func_args* /*args*/) {}
DEFINE_PROTO_FUZZER(const transport_test_suite::Msg& msg) { DEFINE_PROTO_FUZZER(const transport_test_suite::Msg& msg) {
const auto& tests = grpc_core::TransportTestRegistry::Get().tests(); const auto& tests = grpc_core::TransportTestRegistry::Get().tests();
const auto& fixtures = grpc_core::TransportFixtureRegistry::Get().fixtures(); const auto& fixtures = grpc_core::TransportFixtureRegistry::Get().fixtures();
GPR_ASSERT(!tests.empty()); CHECK(!tests.empty());
GPR_ASSERT(!fixtures.empty()); CHECK(!fixtures.empty());
const int test_id = msg.test_id() % tests.size(); const int test_id = msg.test_id() % tests.size();
const int fixture_id = msg.fixture_id() % fixtures.size(); const int fixture_id = msg.fixture_id() % fixtures.size();
@ -62,5 +64,5 @@ DEFINE_PROTO_FUZZER(const transport_test_suite::Msg& msg) {
msg.event_engine_actions(), bitgen); msg.event_engine_actions(), bitgen);
test->RunTest(); test->RunTest();
delete test; delete test;
GPR_ASSERT(!::testing::Test::HasFailure()); CHECK(!::testing::Test::HasFailure());
} }

@ -35,6 +35,7 @@ def grpc_transport_test(name, deps):
srcs = ["fuzzer_main.cc"], srcs = ["fuzzer_main.cc"],
tags = ["no_windows", "no_mac"], tags = ["no_windows", "no_mac"],
external_deps = [ external_deps = [
"absl/log:check",
"gtest", "gtest",
], ],
deps = [ deps = [

Loading…
Cancel
Save