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

Method CheckResponseCode

test/brpc_sofa_pbrpc_protocol_unittest.cpp:160–181  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

158 }
159
160 void CheckResponseCode(bool expect_empty, int expect_code) {
161 int bytes_in_pipe = 0;
162 ioctl(_pipe_fds[0], FIONREAD, &bytes_in_pipe);
163 if (expect_empty) {
164 EXPECT_EQ(0, bytes_in_pipe);
165 return;
166 }
167
168 EXPECT_GT(bytes_in_pipe, 0);
169 butil::IOPortal buf;
170 EXPECT_EQ((ssize_t)bytes_in_pipe,
171 buf.append_from_file_descriptor(_pipe_fds[0], 1024));
172 brpc::ParseResult pr = brpc::policy::ParseSofaMessage(&buf, NULL, false, NULL);
173 EXPECT_EQ(brpc::PARSE_OK, pr.error());
174 brpc::policy::MostCommonMessage* msg =
175 static_cast<brpc::policy::MostCommonMessage*>(pr.message());
176
177 brpc::policy::SofaRpcMeta meta;
178 butil::IOBufAsZeroCopyInputStream meta_stream(msg->meta);
179 EXPECT_TRUE(meta.ParseFromZeroCopyStream(&meta_stream));
180 EXPECT_EQ(expect_code, meta.error_code());
181 }
182
183 void TestSofaCompress(brpc::CompressType type) {
184 butil::IOBuf request_buf;

Callers

nothing calls this directly

Calls 5

ParseSofaMessageFunction · 0.85
errorMethod · 0.45
messageMethod · 0.45
error_codeMethod · 0.45

Tested by

no test coverage detected