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

Public Member Functions

 HTTP2FramerTest ()
 
template<typename ParseFunc , typename... Args>
void parse (ParseFunc &&parseFn, FrameHeader &outHeader, Args &&...outArgs)
 
template<typename ParseFunc , typename... Args>
void parse (const IOBuf *data, ParseFunc &&parseFn, FrameHeader &outHeader, Args &&...outArgs)
 
void dataFrameTest (uint32_t dataLen, folly::Optional< uint8_t > padLen)
 
void dataFrameTest (IOBuf *body, uint32_t dataLen, folly::Optional< uint8_t > padLen)
 
- Public Member Functions inherited from testing::Test
virtual ~Test ()
 
virtual ~Test ()
 
virtual ~Test ()
 

Public Attributes

IOBufQueue queue_ {IOBufQueue::cacheChainLength()}
 

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 ()
 
virtual void SetUp ()
 
virtual void TearDown ()
 
 Test ()
 
virtual void SetUp ()
 
virtual void TearDown ()
 
 Test ()
 
virtual void SetUp ()
 
virtual void TearDown ()
 

Detailed Description

Definition at line 36 of file HTTP2FramerTest.cpp.

Constructor & Destructor Documentation

HTTP2FramerTest::HTTP2FramerTest ( )
inline

Definition at line 38 of file HTTP2FramerTest.cpp.

References testing::Args().

38 {}

Member Function Documentation

void HTTP2FramerTest::dataFrameTest ( uint32_t  dataLen,
folly::Optional< uint8_t padLen 
)
inline

Definition at line 55 of file HTTP2FramerTest.cpp.

References makeBuf().

55  {
56  auto body = makeBuf(dataLen);
57  dataFrameTest(body.get(), dataLen, padLen);
58  }
std::unique_ptr< folly::IOBuf > makeBuf(uint32_t size)
Definition: ZlibTests.cpp:26
void dataFrameTest(uint32_t dataLen, folly::Optional< uint8_t > padLen)
void HTTP2FramerTest::dataFrameTest ( IOBuf body,
uint32_t  dataLen,
folly::Optional< uint8_t padLen 
)
inline

Definition at line 60 of file HTTP2FramerTest.cpp.

References folly::IOBuf::clone(), EXPECT_DEATH_NO_CORE, EXPECT_EQ, proxygen::http2::kMaxFramePayloadLength, folly::IOBuf::moveToFbString(), parse(), proxygen::http2::parseData(), uint16_t, uint32_t, and proxygen::http2::writeData().

61  {
62  uint32_t frameLen = uint32_t(dataLen);
63  if (padLen) {
64  frameLen += 1 + *padLen;
65  }
66  if (frameLen > kMaxFramePayloadLength) {
67  EXPECT_DEATH_NO_CORE(writeData(queue_, body->clone(), 1, padLen,
68  false, true), ".*");
69  } else {
70  writeData(queue_, body->clone(), 1, padLen, false, true);
71 
72  FrameHeader outHeader;
73  std::unique_ptr<IOBuf> outBuf;
74  uint16_t padding = 0;
75  parse(&parseData, outHeader, outBuf, padding);
76 
77  EXPECT_EQ(outBuf->moveToFbString(), body->moveToFbString());
78  EXPECT_EQ(padding, padLen ? (*padLen + 1) : 0);
79  }
80  queue_.move(); // reset everything
81  }
#define EXPECT_DEATH_NO_CORE(token, regex)
Definition: TestUtils.h:19
#define EXPECT_EQ(val1, val2)
Definition: gtest.h:1922
fbstring moveToFbString()
Definition: IOBuf.cpp:968
const uint32_t kMaxFramePayloadLength
std::unique_ptr< folly::IOBuf > move()
Definition: IOBufQueue.h:459
std::unique_ptr< IOBuf > clone() const
Definition: IOBuf.cpp:527
void parse(ParseFunc &&parseFn, FrameHeader &outHeader, Args &&...outArgs)
ErrorCode parseData(Cursor &cursor, const FrameHeader &header, std::unique_ptr< IOBuf > &outBuf, uint16_t &outPadding) noexcept
size_t writeData(IOBufQueue &queue, std::unique_ptr< IOBuf > data, uint32_t stream, folly::Optional< uint8_t > padding, bool endStream, bool reuseIOBufHeadroom) noexcept
template<typename ParseFunc , typename... Args>
void HTTP2FramerTest::parse ( ParseFunc &&  parseFn,
FrameHeader outHeader,
Args &&...  outArgs 
)
inline

Definition at line 41 of file HTTP2FramerTest.cpp.

References testing::Args(), and parse().

41  {
42  parse(queue_.front(), parseFn, outHeader, std::forward<Args>(outArgs)...);
43  }
const folly::IOBuf * front() const
Definition: IOBufQueue.h:476
void parse(ParseFunc &&parseFn, FrameHeader &outHeader, Args &&...outArgs)
template<typename ParseFunc , typename... Args>
void HTTP2FramerTest::parse ( const IOBuf data,
ParseFunc &&  parseFn,
FrameHeader outHeader,
Args &&...  outArgs 
)
inline

Definition at line 46 of file HTTP2FramerTest.cpp.

References ASSERT_EQ, and proxygen::http2::parseFrameHeader().

47  {
48  Cursor cursor(data);
49  auto ret1 = parseFrameHeader(cursor, outHeader);
50  ASSERT_EQ(ret1, ErrorCode::NO_ERROR);
51  auto ret2 = (*parseFn)(cursor, outHeader, std::forward<Args>(outArgs)...);
52  ASSERT_EQ(ret2, ErrorCode::NO_ERROR);
53  }
ErrorCode parseFrameHeader(Cursor &cursor, FrameHeader &header) noexcept
#define ASSERT_EQ(val1, val2)
Definition: gtest.h:1956

Member Data Documentation

IOBufQueue HTTP2FramerTest::queue_ {IOBufQueue::cacheChainLength()}

Definition at line 83 of file HTTP2FramerTest.cpp.


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