proxygen
AsyncSocketGSOIntegrationTest Class Reference
Inheritance diagram for AsyncSocketGSOIntegrationTest:
testing::Test

Public Member Functions

void SetUp () override
 
void startServer ()
 
void TearDown () override
 
std::unique_ptr< UDPClientperformPingPongTest (TestData &testData, folly::Optional< folly::SocketAddress > connectedAddress)
 
- Public Member Functions inherited from testing::Test
virtual ~Test ()
 
virtual ~Test ()
 
virtual ~Test ()
 

Public Attributes

folly::EventBase sevb
 
folly::EventBase cevb
 
TestDatatestData_ {nullptr}
 
std::unique_ptr< std::thread > serverThread
 
std::unique_ptr< UDPServerserver
 
std::unique_ptr< UDPClientclient
 

Additional Inherited Members

- Public Types inherited from testing::Test
typedef internal::SetUpTestCaseFunc SetUpTestCaseFunc
 
typedef internal::TearDownTestCaseFunc TearDownTestCaseFunc
 
typedef internal::SetUpTestCaseFunc SetUpTestCaseFunc
 
typedef internal::TearDownTestCaseFunc TearDownTestCaseFunc
 
typedef internal::SetUpTestCaseFunc SetUpTestCaseFunc
 
typedef internal::TearDownTestCaseFunc TearDownTestCaseFunc
 
- Static Public Member Functions inherited from testing::Test
static void SetUpTestCase ()
 
static void TearDownTestCase ()
 
static bool HasFatalFailure ()
 
static bool HasNonfatalFailure ()
 
static bool HasFailure ()
 
static void RecordProperty (const std::string &key, const std::string &value)
 
static void RecordProperty (const std::string &key, int value)
 
static void SetUpTestCase ()
 
static void TearDownTestCase ()
 
static bool HasFatalFailure ()
 
static bool HasNonfatalFailure ()
 
static bool HasFailure ()
 
static void RecordProperty (const std::string &key, const std::string &value)
 
static void RecordProperty (const std::string &key, int value)
 
static void SetUpTestCase ()
 
static void TearDownTestCase ()
 
static bool HasFatalFailure ()
 
static bool HasNonfatalFailure ()
 
static bool HasFailure ()
 
static void RecordProperty (const std::string &key, const std::string &value)
 
static void RecordProperty (const std::string &key, int value)
 
- Protected Member Functions inherited from testing::Test
 Test ()
 
 Test ()
 
 Test ()
 

Detailed Description

Definition at line 306 of file AsyncUDPSocketGSOTest.cpp.

Member Function Documentation

std::unique_ptr< UDPClient > AsyncSocketGSOIntegrationTest::performPingPongTest ( TestData testData,
folly::Optional< folly::SocketAddress connectedAddress 
)

Definition at line 349 of file AsyncUDPSocketGSOTest.cpp.

References folly::gen::move.

351  {
352  testData_ = &testData;
353 
354  client = std::make_unique<UDPClient>(&cevb, testData);
355  if (connectedAddress) {
356  client->setShouldConnect(*connectedAddress);
357  }
358 
359  // Start event loop in a separate thread
360  auto clientThread = std::thread([this]() { cevb.loopForever(); });
361 
362  // Wait for event loop to start
363  cevb.waitUntilRunning();
364 
365  // Send ping
366  cevb.runInEventBaseThread([&]() { client->start(server->address()); });
367 
368  // Wait for client to finish
369  clientThread.join();
370  return std::move(client);
371 }
constexpr detail::Map< Move > move
Definition: Base-inl.h:2567
std::unique_ptr< UDPClient > client
std::unique_ptr< UDPServer > server
void AsyncSocketGSOIntegrationTest::SetUp ( )
inlineoverridevirtual

Reimplemented from testing::Test.

Definition at line 308 of file AsyncUDPSocketGSOTest.cpp.

308  {
309  server = std::make_unique<UDPServer>(
310  &sevb, folly::SocketAddress("127.0.0.1", 0), 1);
311 
312  // Start event loop in a separate thread
313  serverThread =
314  std::make_unique<std::thread>([this]() { sevb.loopForever(); });
315 
316  // Wait for event loop to start
317  sevb.waitUntilRunning();
318  }
std::unique_ptr< std::thread > serverThread
std::unique_ptr< UDPServer > server
void AsyncSocketGSOIntegrationTest::startServer ( )
inline

Definition at line 320 of file AsyncUDPSocketGSOTest.cpp.

320  {
321  // Start the server
322  sevb.runInEventBaseThreadAndWait([&]() { server->start(); });
323  LOG(INFO) << "Server listening=" << server->address();
324  }
bool runInEventBaseThreadAndWait(void(*fn)(T *), T *arg)
Definition: EventBase.h:799
std::unique_ptr< UDPServer > server
void AsyncSocketGSOIntegrationTest::TearDown ( )
inlineoverridevirtual

Reimplemented from testing::Test.

Definition at line 326 of file AsyncUDPSocketGSOTest.cpp.

326  {
327  // Shutdown server
328  sevb.runInEventBaseThread([&]() {
329  server->shutdown();
331  });
332 
333  // Wait for server thread to join
334  serverThread->join();
335  }
void terminateLoopSoon()
Definition: EventBase.cpp:493
bool runInEventBaseThread(void(*fn)(T *), T *arg)
Definition: EventBase.h:794
std::unique_ptr< std::thread > serverThread
std::unique_ptr< UDPServer > server

Member Data Documentation

folly::EventBase AsyncSocketGSOIntegrationTest::cevb

Definition at line 342 of file AsyncUDPSocketGSOTest.cpp.

std::unique_ptr<UDPClient> AsyncSocketGSOIntegrationTest::client

Definition at line 346 of file AsyncUDPSocketGSOTest.cpp.

std::unique_ptr<UDPServer> AsyncSocketGSOIntegrationTest::server

Definition at line 345 of file AsyncUDPSocketGSOTest.cpp.

std::unique_ptr<std::thread> AsyncSocketGSOIntegrationTest::serverThread

Definition at line 344 of file AsyncUDPSocketGSOTest.cpp.

folly::EventBase AsyncSocketGSOIntegrationTest::sevb

Definition at line 341 of file AsyncUDPSocketGSOTest.cpp.

TestData* AsyncSocketGSOIntegrationTest::testData_ {nullptr}

Definition at line 343 of file AsyncUDPSocketGSOTest.cpp.


The documentation for this class was generated from the following file: