This commit is contained in:
Tanvi Jagtap 2024-06-12 02:10:23 +00:00 committed by GitHub
commit 8ed05e36ff
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
6 changed files with 20 additions and 16 deletions

View File

@ -51,7 +51,7 @@ static void test_grpc_parse_ipv6_parity_with_getaddrinfo(
grpc_core::ExecCtx exec_ctx;
absl::StatusOr<grpc_core::URI> uri = grpc_core::URI::Parse(target);
if (!uri.ok()) {
gpr_log(GPR_ERROR, "%s", uri.status().ToString().c_str());
LOG(ERROR) << uri.status();
ASSERT_TRUE(uri.ok());
}
grpc_resolved_address addr;
@ -75,7 +75,7 @@ static void test_grpc_parse_ipv6_parity_with_getaddrinfo(
struct sockaddr_in6 resolve_with_gettaddrinfo(const char* uri_text) {
absl::StatusOr<grpc_core::URI> uri = grpc_core::URI::Parse(uri_text);
if (!uri.ok()) {
gpr_log(GPR_ERROR, "%s", uri.status().ToString().c_str());
LOG(ERROR) << uri.status();
EXPECT_TRUE(uri.ok());
}
std::string host;

View File

@ -57,7 +57,10 @@ grpc_yodel_simple_test(
grpc_yodel_simple_test(
name = "load_balanced_call_destination",
srcs = ["load_balanced_call_destination_test.cc"],
external_deps = ["gtest"],
external_deps = [
"absl/log:log",
"gtest",
],
deps = [
"//:grpc_client_channel",
"//test/core/call/yodel:yodel_test",

View File

@ -17,6 +17,7 @@
#include <atomic>
#include <memory>
#include "absl/log/log.h"
#include "absl/strings/string_view.h"
#include "gtest/gtest.h"
@ -106,7 +107,7 @@ class ClientChannelTest : public YodelTest {
RefCountedPtr<Subchannel> CreateSubchannel(
const grpc_resolved_address& address,
const ChannelArgs& args) override {
gpr_log(GPR_INFO, "CreateSubchannel: args=%s", args.ToString().c_str());
LOG(INFO) << "CreateSubchannel: args=" << args.ToString();
return Subchannel::Create(MakeOrphanable<TestConnector>(), address, args);
}
};

View File

@ -208,7 +208,7 @@ static void on_read_request_done_locked(void* arg, grpc_error_handle error);
static void proxy_connection_failed(proxy_connection* conn,
failure_type failure, const char* prefix,
grpc_error_handle error) {
gpr_log(GPR_INFO, "%s: %s", prefix, grpc_core::StatusToString(error).c_str());
LOG(INFO) << prefix << ": " << grpc_core::StatusToString(error);
// Decide whether we should shut down the client and server.
bool shutdown_client = false;
bool shutdown_server = false;

View File

@ -164,8 +164,7 @@ static void session_read_cb(void* arg, // session
// before notify_on_read is called.
grpc_fd_notify_on_read(se->em_fd, &se->session_read_closure);
} else {
grpc_core::Crash(absl::StrFormat("Unhandled read error %s",
grpc_core::StrError(errno).c_str()));
LOG(FATAL) << "Unhandled read error " << grpc_core::StrError(errno);
}
}
}
@ -330,8 +329,7 @@ static void client_session_write(void* arg, // client
}
gpr_mu_unlock(g_mu);
} else {
grpc_core::Crash(absl::StrFormat("unknown errno %s",
grpc_core::StrError(errno).c_str()));
LOG(FATAL) << "unknown errno " << grpc_core::StrError(errno).c_str();
}
}
@ -348,12 +346,10 @@ static void client_start(client* cl, int port) {
pfd.events = POLLOUT;
pfd.revents = 0;
if (poll(&pfd, 1, -1) == -1) {
gpr_log(GPR_ERROR, "poll() failed during connect; errno=%d", errno);
abort();
LOG(FATAL) << "poll() failed during connect; errno=" << errno;
}
} else {
grpc_core::Crash(
absl::StrFormat("Failed to connect to the server (errno=%d)", errno));
LOG(FATAL) << "Failed to connect to the server (errno=" << errno << ")";
}
}

View File

@ -33,7 +33,6 @@
#include "gtest/gtest.h"
#include <grpc/slice.h>
#include <grpc/support/log.h>
#include <grpc/support/port_platform.h>
#include "src/core/lib/gprpp/memory.h"
@ -395,14 +394,19 @@ size_t SumSlice(const Slice& slice) {
TEST(SliceTest, ExternalAsOwned) {
auto external_string = std::make_unique<std::string>(RandomString(1024));
Slice slice = Slice::FromExternalString(*external_string);
const auto initial_sum = SumSlice(slice);
const size_t initial_sum = SumSlice(slice);
Slice owned = slice.AsOwned();
EXPECT_EQ(initial_sum, SumSlice(owned));
external_string.reset();
// In ASAN (where we can be sure that it'll crash), go ahead and read the
// bytes we just deleted.
if (BuiltUnderAsan()) {
ASSERT_DEATH({ gpr_log(GPR_DEBUG, "%" PRIdPTR, SumSlice(slice)); }, "");
ASSERT_DEATH(
{
size_t sum = SumSlice(slice);
VLOG(2) << sum;
},
"");
}
EXPECT_EQ(initial_sum, SumSlice(owned));
}