[grpc][Gpr_To_Absl_Logging] Migrating from gpr to absl logging GPR_ASSERT

pull/36657/head
tanvi-jagtap 7 months ago
parent 1e83bc6978
commit 662a6e0aa0
  1. 30
      src/objective-c/tests/CFStreamTests/CFStreamClientTests.mm
  2. 26
      src/objective-c/tests/CronetTests/CronetUnitTests.mm
  3. 30
      test/core/iomgr/ios/CFStreamTests/CFStreamClientTests.mm

@ -48,8 +48,8 @@ static void finish_connection() {
}
static void must_succeed(void* arg, grpc_error_handle error) {
GPR_ASSERT(g_connecting != nullptr);
GPR_ASSERT(error.ok());
CHECK(g_connecting != nullptr);
CHECK(error.ok());
grpc_endpoint_shutdown(g_connecting, GRPC_ERROR_CREATE("must_succeed called"));
grpc_endpoint_destroy(g_connecting);
g_connecting = nullptr;
@ -57,8 +57,8 @@ static void must_succeed(void* arg, grpc_error_handle error) {
}
static void must_fail(void* arg, grpc_error_handle error) {
GPR_ASSERT(g_connecting == nullptr);
GPR_ASSERT(!error.ok());
CHECK(g_connecting == nullptr);
CHECK(!error.ok());
NSLog(@"%s", grpc_core::StatusToString(error).c_str());
finish_connection();
}
@ -88,21 +88,21 @@ static void must_fail(void* arg, grpc_error_handle error) {
gpr_log(GPR_DEBUG, "test_succeeds");
auto resolved_addr = grpc_core::StringToSockaddr("127.0.0.1:0");
GPR_ASSERT(resolved_addr.ok());
CHECK(resolved_addr.ok());
struct sockaddr_in* addr = reinterpret_cast<struct sockaddr_in*>(resolved_addr->addr);
/* create a phony server */
svr_fd = socket(AF_INET, SOCK_STREAM, 0);
GPR_ASSERT(svr_fd >= 0);
GPR_ASSERT(0 == bind(svr_fd, (struct sockaddr*)addr, (socklen_t)resolved_addr->len));
GPR_ASSERT(0 == listen(svr_fd, 1));
CHECK(svr_fd >= 0);
CHECK(0 == bind(svr_fd, (struct sockaddr*)addr, (socklen_t)resolved_addr->len));
CHECK(0 == listen(svr_fd, 1));
gpr_mu_lock(&g_mu);
connections_complete_before = g_connections_complete;
gpr_mu_unlock(&g_mu);
/* connect to it */
GPR_ASSERT(getsockname(svr_fd, (struct sockaddr*)addr, (socklen_t*)&resolved_addr->len) == 0);
CHECK(getsockname(svr_fd, (struct sockaddr*)addr, (socklen_t*)&resolved_addr->len) == 0);
GRPC_CLOSURE_INIT(&done, must_succeed, nullptr, grpc_schedule_on_exec_ctx);
auto args =
grpc_core::CoreConfiguration::Get().channel_args_preconditioning().PreconditionChannelArgs(
@ -117,7 +117,7 @@ static void must_fail(void* arg, grpc_error_handle error) {
r = accept(svr_fd, reinterpret_cast<struct sockaddr*>(addr),
reinterpret_cast<socklen_t*>(&resolved_addr->len));
} while (r == -1 && errno == EINTR);
GPR_ASSERT(r >= 0);
CHECK(r >= 0);
close(r);
grpc_core::ExecCtx::Get()->Flush();
@ -145,14 +145,14 @@ static void must_fail(void* arg, grpc_error_handle error) {
gpr_log(GPR_DEBUG, "test_fails");
auto resolved_addr = grpc_core::StringToSockaddr("127.0.0.1:0");
GPR_ASSERT(resolved_addr.ok());
CHECK(resolved_addr.ok());
struct sockaddr_in* addr = reinterpret_cast<struct sockaddr_in*>(resolved_addr->addr);
svr_fd = socket(AF_INET, SOCK_STREAM, 0);
GPR_ASSERT(svr_fd >= 0);
GPR_ASSERT(0 == bind(svr_fd, (struct sockaddr*)addr, (socklen_t)resolved_addr->len));
GPR_ASSERT(0 == listen(svr_fd, 1));
GPR_ASSERT(getsockname(svr_fd, (struct sockaddr*)addr, (socklen_t*)&resolved_addr->len) == 0);
CHECK(svr_fd >= 0);
CHECK(0 == bind(svr_fd, (struct sockaddr*)addr, (socklen_t)resolved_addr->len));
CHECK(0 == listen(svr_fd, 1));
CHECK(getsockname(svr_fd, (struct sockaddr*)addr, (socklen_t*)&resolved_addr->len) == 0);
close(svr_fd);
gpr_mu_lock(&g_mu);

@ -154,7 +154,7 @@ unsigned int parse_h2_length(const char *field) {
c = grpc_channel_create_call(client, NULL, GRPC_PROPAGATE_DEFAULTS, cq,
grpc_slice_from_static_string("/foo"), NULL, deadline, NULL);
GPR_ASSERT(c);
CHECK(c);
grpc_metadata_array_init(&initial_metadata_recv);
grpc_metadata_array_init(&trailing_metadata_recv);
@ -162,7 +162,7 @@ unsigned int parse_h2_length(const char *field) {
grpc_call_details_init(&call_details);
int sl = socket(AF_INET, SOCK_STREAM, 0);
GPR_ASSERT(sl >= 0);
CHECK(sl >= 0);
// Make an TCP endpoint to accept the connection
struct sockaddr_in s_addr;
@ -170,8 +170,8 @@ unsigned int parse_h2_length(const char *field) {
s_addr.sin_family = AF_INET;
s_addr.sin_addr.s_addr = htonl(INADDR_ANY);
s_addr.sin_port = htons(port);
GPR_ASSERT(0 == bind(sl, (struct sockaddr *)&s_addr, sizeof(s_addr)));
GPR_ASSERT(0 == listen(sl, 5));
CHECK(0 == bind(sl, (struct sockaddr *)&s_addr, sizeof(s_addr)));
CHECK(0 == listen(sl, 5));
memset(ops, 0, sizeof(ops));
op = ops;
@ -208,11 +208,11 @@ unsigned int parse_h2_length(const char *field) {
op->reserved = NULL;
op++;
error = grpc_call_start_batch(c, ops, (size_t)(op - ops), (void *)1, NULL);
GPR_ASSERT(GRPC_CALL_OK == error);
CHECK(GRPC_CALL_OK == error);
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
int s = accept(sl, NULL, NULL);
GPR_ASSERT(s >= 0);
CHECK(s >= 0);
// Close the connection after 1 second to trigger Cronet's on_failed()
sleep(1);
@ -223,7 +223,7 @@ unsigned int parse_h2_length(const char *field) {
cqv.Expect((void *)1, true);
cqv.Verify();
GPR_ASSERT(status == GRPC_STATUS_UNAVAILABLE);
CHECK(status == GRPC_STATUS_UNAVAILABLE);
grpc_slice_unref(details);
grpc_metadata_array_destroy(&initial_metadata_recv);
@ -282,7 +282,7 @@ unsigned int parse_h2_length(const char *field) {
c = grpc_channel_create_call(client, NULL, GRPC_PROPAGATE_DEFAULTS, cq,
grpc_slice_from_static_string("/foo"), NULL, deadline, NULL);
GPR_ASSERT(c);
CHECK(c);
grpc_metadata_array_init(&initial_metadata_recv);
grpc_metadata_array_init(&trailing_metadata_recv);
@ -292,18 +292,18 @@ unsigned int parse_h2_length(const char *field) {
__weak XCTestExpectation *expectation = [self expectationWithDescription:@"Coalescing"];
int sl = socket(AF_INET, SOCK_STREAM, 0);
GPR_ASSERT(sl >= 0);
CHECK(sl >= 0);
struct sockaddr_in s_addr;
memset(&s_addr, 0, sizeof(s_addr));
s_addr.sin_family = AF_INET;
s_addr.sin_addr.s_addr = htonl(INADDR_ANY);
s_addr.sin_port = htons(port);
GPR_ASSERT(0 == bind(sl, (struct sockaddr *)&s_addr, sizeof(s_addr)));
GPR_ASSERT(0 == listen(sl, 5));
CHECK(0 == bind(sl, (struct sockaddr *)&s_addr, sizeof(s_addr)));
CHECK(0 == listen(sl, 5));
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
int s = accept(sl, NULL, NULL);
GPR_ASSERT(s >= 0);
CHECK(s >= 0);
struct timeval tv;
tv.tv_sec = 2;
tv.tv_usec = 0;
@ -391,7 +391,7 @@ unsigned int parse_h2_length(const char *field) {
op->reserved = NULL;
op++;
error = grpc_call_start_batch(c, ops, (size_t)(op - ops), (void *)1, NULL);
GPR_ASSERT(GRPC_CALL_OK == error);
CHECK(GRPC_CALL_OK == error);
cqv.Expect((void *)1, true);
cqv.Verify();

@ -47,8 +47,8 @@ static void finish_connection() {
}
static void must_succeed(void* arg, grpc_error_handle error) {
GPR_ASSERT(g_connecting != nullptr);
GPR_ASSERT(error.ok());
CHECK(g_connecting != nullptr);
CHECK(error.ok());
grpc_endpoint_shutdown(g_connecting, GRPC_ERROR_CREATE("must_succeed called"));
grpc_endpoint_destroy(g_connecting);
g_connecting = nullptr;
@ -56,8 +56,8 @@ static void must_succeed(void* arg, grpc_error_handle error) {
}
static void must_fail(void* arg, grpc_error_handle error) {
GPR_ASSERT(g_connecting == nullptr);
GPR_ASSERT(!error.ok());
CHECK(g_connecting == nullptr);
CHECK(!error.ok());
NSLog(@"%s", grpc_core::StatusToString(error).c_str());
finish_connection();
}
@ -87,21 +87,21 @@ static void must_fail(void* arg, grpc_error_handle error) {
gpr_log(GPR_DEBUG, "test_succeeds");
auto resolved_addr = grpc_core::StringToSockaddr("127.0.0.1:0");
GPR_ASSERT(resolved_addr.ok());
CHECK(resolved_addr.ok());
struct sockaddr_in* addr = reinterpret_cast<struct sockaddr_in*>(resolved_addr->addr);
/* create a phony server */
svr_fd = socket(AF_INET, SOCK_STREAM, 0);
GPR_ASSERT(svr_fd >= 0);
GPR_ASSERT(0 == bind(svr_fd, (struct sockaddr*)addr, (socklen_t)resolved_addr->len));
GPR_ASSERT(0 == listen(svr_fd, 1));
CHECK(svr_fd >= 0);
CHECK(0 == bind(svr_fd, (struct sockaddr*)addr, (socklen_t)resolved_addr->len));
CHECK(0 == listen(svr_fd, 1));
gpr_mu_lock(&g_mu);
connections_complete_before = g_connections_complete;
gpr_mu_unlock(&g_mu);
/* connect to it */
GPR_ASSERT(getsockname(svr_fd, (struct sockaddr*)addr, (socklen_t*)&resolved_addr->len) == 0);
CHECK(getsockname(svr_fd, (struct sockaddr*)addr, (socklen_t*)&resolved_addr->len) == 0);
GRPC_CLOSURE_INIT(&done, must_succeed, nullptr, grpc_schedule_on_exec_ctx);
auto args =
grpc_core::CoreConfiguration::Get().channel_args_preconditioning().PreconditionChannelArgs(
@ -116,7 +116,7 @@ static void must_fail(void* arg, grpc_error_handle error) {
r = accept(svr_fd, reinterpret_cast<struct sockaddr*>(addr),
reinterpret_cast<socklen_t*>(&resolved_addr->len));
} while (r == -1 && errno == EINTR);
GPR_ASSERT(r >= 0);
CHECK(r >= 0);
close(r);
grpc_core::ExecCtx::Get()->Flush();
@ -144,14 +144,14 @@ static void must_fail(void* arg, grpc_error_handle error) {
gpr_log(GPR_DEBUG, "test_fails");
auto resolved_addr = grpc_core::StringToSockaddr("127.0.0.1:0");
GPR_ASSERT(resolved_addr.ok());
CHECK(resolved_addr.ok());
struct sockaddr_in* addr = reinterpret_cast<struct sockaddr_in*>(resolved_addr->addr);
svr_fd = socket(AF_INET, SOCK_STREAM, 0);
GPR_ASSERT(svr_fd >= 0);
GPR_ASSERT(0 == bind(svr_fd, (struct sockaddr*)addr, (socklen_t)resolved_addr->len));
GPR_ASSERT(0 == listen(svr_fd, 1));
GPR_ASSERT(getsockname(svr_fd, (struct sockaddr*)addr, (socklen_t*)&resolved_addr->len) == 0);
CHECK(svr_fd >= 0);
CHECK(0 == bind(svr_fd, (struct sockaddr*)addr, (socklen_t)resolved_addr->len));
CHECK(0 == listen(svr_fd, 1));
CHECK(getsockname(svr_fd, (struct sockaddr*)addr, (socklen_t*)&resolved_addr->len) == 0);
close(svr_fd);
gpr_mu_lock(&g_mu);

Loading…
Cancel
Save