MCPcopy Create free account
hub / github.com/apache/brpc / TEST_F

Function TEST_F

test/brpc_socket_unittest.cpp:117–145  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

115};
116
117TEST_F(SocketTest, not_recycle_until_zero_nref) {
118 std::cout << "sizeof(Socket)=" << sizeof(brpc::Socket) << std::endl;
119 int fds[2];
120 ASSERT_EQ(0, socketpair(AF_UNIX, SOCK_STREAM, 0, fds));
121 brpc::SocketId id = 8888;
122 butil::EndPoint dummy;
123 ASSERT_EQ(0, str2endpoint("192.168.1.26:8080", &dummy));
124 brpc::SocketOptions options;
125 options.fd = fds[1];
126 options.remote_side = dummy;
127 options.user = new CheckRecycle;
128 ASSERT_EQ(0, brpc::Socket::Create(options, &id));
129 {
130 brpc::SocketUniquePtr s;
131 ASSERT_EQ(0, brpc::Socket::Address(id, &s));
132 global_sock = s.get();
133 ASSERT_TRUE(s.get());
134 ASSERT_EQ(fds[1], s->fd());
135 ASSERT_EQ(dummy, s->remote_side());
136 ASSERT_EQ(id, s->id());
137 ASSERT_EQ(0, s->SetFailed());
138 ASSERT_EQ(s.get(), global_sock);
139 }
140 ASSERT_EQ((brpc::Socket*)NULL, global_sock);
141 close(fds[0]);
142
143 brpc::SocketUniquePtr ptr;
144 ASSERT_EQ(-1, brpc::Socket::Address(id, &ptr));
145}
146
147butil::atomic<int> winner_count(0);
148const int AUTH_ERR = -9;

Callers

nothing calls this directly

Calls 15

str2endpointFunction · 0.85
bthread_start_urgentFunction · 0.85
bthread_joinFunction · 0.85
snprintfFunction · 0.85
bthread_id_create2Function · 0.85
bthread_id_joinFunction · 0.85
tcp_listenFunction · 0.85
berrorFunction · 0.85
make_non_blockingFunction · 0.85
EndPointClass · 0.85
bthread_usleepFunction · 0.85
cpuwide_time_usFunction · 0.85

Tested by

no test coverage detected