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

Method CheckResponseCode

test/brpc_public_pbrpc_protocol_unittest.cpp:170–191  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

168 }
169
170 void CheckResponseCode(bool expect_empty, int expect_code) {
171 int bytes_in_pipe = 0;
172 ioctl(_pipe_fds[0], FIONREAD, &bytes_in_pipe);
173 if (expect_empty) {
174 EXPECT_EQ(0, bytes_in_pipe);
175 return;
176 }
177
178 EXPECT_GT(bytes_in_pipe, 0);
179 butil::IOPortal buf;
180 EXPECT_EQ((ssize_t)bytes_in_pipe,
181 buf.append_from_file_descriptor(_pipe_fds[0], 1024));
182 brpc::ParseResult pr = brpc::policy::ParseNsheadMessage(&buf, NULL, false, NULL);
183 EXPECT_EQ(brpc::PARSE_OK, pr.error());
184 brpc::policy::MostCommonMessage* msg =
185 static_cast<brpc::policy::MostCommonMessage*>(pr.message());
186
187 brpc::policy::PublicPbrpcResponse meta;
188 butil::IOBufAsZeroCopyInputStream meta_stream(msg->payload);
189 EXPECT_TRUE(meta.ParseFromZeroCopyStream(&meta_stream));
190 EXPECT_EQ(expect_code, meta.responsehead().code());
191 }
192
193 int _pipe_fds[2];
194 brpc::SocketUniquePtr _socket;

Callers

nothing calls this directly

Calls 4

ParseNsheadMessageFunction · 0.85
errorMethod · 0.45
messageMethod · 0.45

Tested by

no test coverage detected