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

Method CheckResponseCode

test/brpc_hulu_pbrpc_protocol_unittest.cpp:167–188  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

165 }
166
167 void CheckResponseCode(bool expect_empty, int expect_code) {
168 int bytes_in_pipe = 0;
169 ioctl(_pipe_fds[0], FIONREAD, &bytes_in_pipe);
170 if (expect_empty) {
171 EXPECT_EQ(0, bytes_in_pipe);
172 return;
173 }
174
175 EXPECT_GT(bytes_in_pipe, 0);
176 butil::IOPortal buf;
177 EXPECT_EQ((ssize_t)bytes_in_pipe,
178 buf.append_from_file_descriptor(_pipe_fds[0], 1024));
179 brpc::ParseResult pr = brpc::policy::ParseHuluMessage(&buf, NULL, false, NULL);
180 EXPECT_EQ(brpc::PARSE_OK, pr.error());
181 brpc::policy::MostCommonMessage* msg =
182 static_cast<brpc::policy::MostCommonMessage*>(pr.message());
183
184 brpc::policy::HuluRpcResponseMeta meta;
185 butil::IOBufAsZeroCopyInputStream meta_stream(msg->meta);
186 EXPECT_TRUE(meta.ParseFromZeroCopyStream(&meta_stream));
187 EXPECT_EQ(expect_code, meta.error_code());
188 }
189
190 void TestHuluCompress(brpc::CompressType type) {
191 butil::IOBuf request_buf;

Callers

nothing calls this directly

Calls 5

ParseHuluMessageFunction · 0.85
errorMethod · 0.45
messageMethod · 0.45
error_codeMethod · 0.45

Tested by

no test coverage detected