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

Function TEST_F

test/brpc_coroutine_unittest.cpp:178–219  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

176}
177
178TEST_F(CoroutineTest, coroutine) {
179 butil::EndPoint ep;
180 ASSERT_EQ(0, str2endpoint("127.0.0.1:8613", &ep));
181
182 brpc::Server server;
183 EchoServiceImpl service;
184 server.AddService(&service, brpc::SERVER_DOESNT_OWN_SERVICE);
185 ASSERT_EQ(0, server.Start(ep, NULL));
186
187 brpc::Channel channel;
188 brpc::ChannelOptions options;
189 ASSERT_EQ(0, channel.Init(ep, &options));
190
191 int out = 0;
192 Coroutine coro(func(channel, &out));
193 coro.join();
194 ASSERT_EQ(456, out);
195
196 out = 0;
197 delay_us = 10000;
198 Coroutine coro2(func(channel, &out));
199 coro2.join();
200 ASSERT_EQ(456, out);
201 delay_us = 0;
202
203 Coroutine coro3(inplace_func2());
204 double d = coro3.join<double>();
205 ASSERT_EQ(0.5, d);
206
207 Coroutine coro4(inplace_func("abc"));
208 coro4.join();
209
210 Coroutine coro5(sleep_func());
211 coro5.join();
212
213 Coroutine coro6(inplace_func2(), true);
214 Coroutine coro7(inplace_func("abc"), true);
215 Coroutine coro8(sleep_func(), true);
216 usleep(10000); // wait sleep_func() to complete
217
218 LOG(INFO) << "test case finished";
219}
220
221#endif // BRPC_ENABLE_COROUTINE

Callers

nothing calls this directly

Calls 9

str2endpointFunction · 0.85
funcFunction · 0.85
inplace_func2Function · 0.85
inplace_funcFunction · 0.85
sleep_funcFunction · 0.85
AddServiceMethod · 0.80
StartMethod · 0.45
InitMethod · 0.45
joinMethod · 0.45

Tested by

no test coverage detected