proxygen
AsyncUDPSocketGSOTest.cpp File Reference

Go to the source code of this file.

Classes

class  TestData
 
class  UDPAcceptor
 
class  UDPServer
 
class  UDPClient
 
class  AsyncSocketGSOIntegrationTest
 
class  GSOBuf
 
class  GSOSendTest
 

Functions

 TEST_F (AsyncSocketGSOIntegrationTest, PingPongGlobalGSO)
 
 TEST_F (AsyncSocketGSOIntegrationTest, PingPongRequestGSO)
 
 TEST (AsyncSocketGSOTest, send)
 

Variables

constexpr auto kGSO1 = 100
 
constexpr auto kGSO2 = 200
 
constexpr auto kGSO = kGSO1 + kGSO2
 

Function Documentation

TEST ( AsyncSocketGSOTest  ,
send   
)

Definition at line 454 of file AsyncUDPSocketGSOTest.cpp.

References folly::AsyncUDPSocket::address(), folly::AsyncUDPSocket::bind(), folly::AsyncUDPSocket::getGSO(), kGSO, kGSO1, kGSO2, and test().

454  {
455  EventBase evb;
456  folly::AsyncUDPSocket client(&evb);
457  client.bind(folly::SocketAddress("127.0.0.1", 0));
458  if (client.getGSO() < 0) {
459  LOG(INFO) << "GSO not supported";
460  // GSO not supported
461  return;
462  }
463 
464  folly::AsyncUDPSocket server(&evb);
465  server.bind(folly::SocketAddress("127.0.0.1", 0));
466 
467  // send less than GSO in a single IOBuf
468  {
469  GSOSendTest test(client, server.address(), kGSO, kGSO - 1);
470  CHECK_LT(test.get(), 0);
471  }
472 
473  // send less than GSO in multiple IOBufs
474  {
475  GSOSendTest test(client, server.address(), kGSO, kGSO1 - 1, kGSO2);
476  CHECK_LT(test.get(), 0);
477  }
478 
479  // send GSO in a single IOBuf
480  {
481  GSOSendTest test(client, server.address(), kGSO, kGSO);
482  CHECK_LT(test.get(), 0);
483  }
484 
485  // send GSO in multiple IOBuf
486  {
487  GSOSendTest test(client, server.address(), kGSO, kGSO1, kGSO2);
488  CHECK_LT(test.get(), 0);
489  }
490 
491  // send more than GSO in a single IOBuf
492  {
493  GSOSendTest test(client, server.address(), kGSO, kGSO + 1);
494  CHECK_EQ(test.get(), kGSO + 1);
495  }
496 
497  // send more than GSO in a multiple IOBufs
498  {
499  GSOSendTest test(client, server.address(), kGSO, kGSO1 + 1, kGSO2 + 1);
500  CHECK_EQ(test.get(), kGSO + 2);
501  }
502 }
constexpr auto kGSO
constexpr auto kGSO2
static uint64_t test(std::string name, bool fc_, bool dedicated_, bool tc_, bool syncops_, uint64_t base)
constexpr auto kGSO1
TEST_F ( AsyncSocketGSOIntegrationTest  ,
PingPongGlobalGSO   
)

Definition at line 373 of file AsyncUDPSocketGSOTest.cpp.

References ASSERT_TRUE, and folly::none.

373  {
374  int gso = 1000;
375  int in[] = {100, 1200, 3000, 200, 100, 300};
376  int expected[] = {1000, 1000, 1000, 1000, 900};
377  TestData testData(
378  gso,
379  true /*useSocketGSO*/,
380  in,
381  sizeof(in) / sizeof(in[0]),
382  expected,
383  sizeof(expected) / sizeof(expected[0]));
384  ASSERT_TRUE(testData.checkIn());
385  startServer();
386  auto pingClient = performPingPongTest(testData, folly::none);
387  ASSERT_TRUE(testData.checkOut());
388 }
#define ASSERT_TRUE(condition)
Definition: gtest.h:1865
constexpr None none
Definition: Optional.h:87
TEST_F ( AsyncSocketGSOIntegrationTest  ,
PingPongRequestGSO   
)

Definition at line 390 of file AsyncUDPSocketGSOTest.cpp.

References ASSERT_TRUE, and folly::none.

390  {
391  int gso = 421;
392  int in[] = {100, 1200, 3000, 200, 100, 300};
393  int expected[] = {421, 421, 421, 421, 421, 421, 421, 421, 421, 421, 421, 269};
394  TestData testData(
395  gso,
396  false /*useSocketGSO*/,
397  in,
398  sizeof(in) / sizeof(in[0]),
399  expected,
400  sizeof(expected) / sizeof(expected[0]));
401  ASSERT_TRUE(testData.checkIn());
402  startServer();
403  auto pingClient = performPingPongTest(testData, folly::none);
404  ASSERT_TRUE(testData.checkOut());
405 }
#define ASSERT_TRUE(condition)
Definition: gtest.h:1865
constexpr None none
Definition: Optional.h:87

Variable Documentation

constexpr auto kGSO = kGSO1 + kGSO2

Definition at line 410 of file AsyncUDPSocketGSOTest.cpp.

Referenced by TEST().

constexpr auto kGSO1 = 100

Definition at line 408 of file AsyncUDPSocketGSOTest.cpp.

Referenced by TEST().

constexpr auto kGSO2 = 200

Definition at line 409 of file AsyncUDPSocketGSOTest.cpp.

Referenced by TEST().