Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
wants to merge 8 commits into from
15 changes: 1 addition & 14 deletions CMakeLists.txt

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

15 changes: 1 addition & 14 deletions build_autogenerated.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 4 additions & 2 deletions test/core/bad_ssl/bad_ssl_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@

#include <string>

#include "absl/log/check.h"

#include <grpc/credentials.h>
#include <grpc/grpc.h>
#include <grpc/grpc_security.h>
Expand Down Expand Up @@ -101,12 +103,12 @@ static void run_test(const char* target, size_t nops) {
op++;
error = grpc_call_start_batch(c, ops, nops, grpc_core::CqVerifier::tag(1),
nullptr);
GPR_ASSERT(GRPC_CALL_OK == error);
CHECK_EQ(error, GRPC_CALL_OK);

cqv.Expect(grpc_core::CqVerifier::tag(1), true);
cqv.Verify();

GPR_ASSERT(status != GRPC_STATUS_OK);
CHECK(status != GRPC_STATUS_OK);

grpc_call_unref(c);
grpc_slice_unref(details);
Expand Down
6 changes: 6 additions & 0 deletions test/core/bad_ssl/generate_tests.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,9 @@ def grpc_bad_ssl_tests():
name = "bad_ssl_test_server",
srcs = ["server_common.cc"],
hdrs = ["server_common.h"],
external_deps = [
"absl/log:check",
],
deps = [
"//test/core/util:grpc_test_util",
"//test/core/util:grpc_test_util_base",
Expand All @@ -48,6 +51,9 @@ def grpc_bad_ssl_tests():
grpc_cc_test(
name = "bad_ssl_%s_test" % t,
srcs = ["bad_ssl_test.cc"],
external_deps = [
"absl/log:check",
],
data = [
":bad_ssl_%s_server" % t,
"//src/core/tsi/test_creds:badserver.key",
Expand Down
22 changes: 12 additions & 10 deletions test/core/bad_ssl/server_common.cc
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@

#include <signal.h>

#include "absl/log/check.h"

#include <grpc/support/log.h>
#include <grpc/support/time.h>

Expand All @@ -42,7 +44,7 @@ const char* bad_ssl_addr(int argc, char** argv) {
gpr_cmdline_add_string(cl, "bind", "Bind host:port", &addr);
gpr_cmdline_parse(cl, argc, argv);
gpr_cmdline_destroy(cl);
GPR_ASSERT(addr);
CHECK(addr);
return addr;
}

Expand All @@ -67,18 +69,18 @@ void bad_ssl_run(grpc_server* server) {
error = grpc_server_request_call(server, &s, &call_details,
&request_metadata_recv, cq, cq,
reinterpret_cast<void*>(1));
GPR_ASSERT(GRPC_CALL_OK == error);
CHECK_EQ(error, GRPC_CALL_OK);

signal(SIGINT, sigint_handler);
while (!shutdown_finished) {
if (got_sigint && !shutdown_started) {
gpr_log(GPR_INFO, "Shutting down due to SIGINT");
shutdown_cq = grpc_completion_queue_create_for_pluck(nullptr);
grpc_server_shutdown_and_notify(server, shutdown_cq, nullptr);
GPR_ASSERT(grpc_completion_queue_pluck(
shutdown_cq, nullptr, grpc_timeout_seconds_to_deadline(5),
nullptr)
.type == GRPC_OP_COMPLETE);
CHECK(grpc_completion_queue_pluck(shutdown_cq, nullptr,
grpc_timeout_seconds_to_deadline(5),
nullptr)
.type == GRPC_OP_COMPLETE);
grpc_completion_queue_destroy(shutdown_cq);
grpc_completion_queue_shutdown(cq);
shutdown_started = 1;
Expand All @@ -90,19 +92,19 @@ void bad_ssl_run(grpc_server* server) {
nullptr);
switch (ev.type) {
case GRPC_OP_COMPLETE:
GPR_ASSERT(ev.tag == (void*)1);
GPR_ASSERT(ev.success == 0);
CHECK(ev.tag == (void*)1);
CHECK_EQ(ev.success, 0);
break;
case GRPC_QUEUE_SHUTDOWN:
GPR_ASSERT(shutdown_started);
CHECK(shutdown_started);
shutdown_finished = 1;
break;
case GRPC_QUEUE_TIMEOUT:
break;
}
}

GPR_ASSERT(s == nullptr);
CHECK_EQ(s, nullptr);
grpc_call_details_destroy(&call_details);
grpc_metadata_array_destroy(&request_metadata_recv);
}
6 changes: 4 additions & 2 deletions test/core/bad_ssl/servers/alpn.cc
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@

#include <string.h>

#include "absl/log/check.h"

#include <grpc/credentials.h>
#include <grpc/grpc.h>
#include <grpc/grpc_security.h>
Expand Down Expand Up @@ -54,7 +56,7 @@ size_t grpc_chttp2_num_alpn_versions(void) {
}

const char* grpc_chttp2_get_alpn_version_index(size_t i) {
GPR_ASSERT(i < GPR_ARRAY_SIZE(fake_versions));
CHECK(i < GPR_ARRAY_SIZE(fake_versions));
return fake_versions[i];
}

Expand All @@ -72,7 +74,7 @@ int main(int argc, char** argv) {
ssl_creds = grpc_ssl_server_credentials_create(nullptr, &pem_key_cert_pair, 1,
0, nullptr);
server = grpc_server_create(nullptr, nullptr);
GPR_ASSERT(grpc_server_add_http2_port(server, addr, ssl_creds));
CHECK(grpc_server_add_http2_port(server, addr, ssl_creds));
grpc_server_credentials_release(ssl_creds);

bad_ssl_run(server);
Expand Down
4 changes: 3 additions & 1 deletion test/core/bad_ssl/servers/cert.cc
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@
//
//

#include "absl/log/check.h"

#include <grpc/credentials.h>
#include <grpc/grpc.h>
#include <grpc/grpc_security.h>
Expand Down Expand Up @@ -47,7 +49,7 @@ int main(int argc, char** argv) {
ssl_creds = grpc_ssl_server_credentials_create(nullptr, &pem_key_cert_pair, 1,
0, nullptr);
server = grpc_server_create(nullptr, nullptr);
GPR_ASSERT(grpc_server_add_http2_port(server, addr, ssl_creds));
CHECK(grpc_server_add_http2_port(server, addr, ssl_creds));
grpc_server_credentials_release(ssl_creds);

bad_ssl_run(server);
Expand Down