Skip to content

Commit

Permalink
Ignore formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
seladb committed Oct 3, 2024
1 parent fdb7f19 commit b083640
Showing 1 changed file with 59 additions and 78 deletions.
137 changes: 59 additions & 78 deletions Tests/Pcap++Test/Tests/TcpReassemblyTests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -371,16 +371,14 @@ PTF_TEST_CASE(TestTcpReassemblySanity)
PTF_ASSERT_EQUAL(stats.begin()->second.connData.dstIP, expectedDstIP);
PTF_ASSERT_EQUAL(stats.begin()->second.connData.startTime.tv_sec, 1491516383);
PTF_ASSERT_EQUAL(stats.begin()->second.connData.startTime.tv_usec, 915793);
PTF_ASSERT_EQUAL(std::chrono::duration_cast<std::chrono::nanoseconds>(
stats.begin()->second.connData.startTimePrecise.time_since_epoch())
.count(),
1491516383915793000);
// clang-format off
PTF_ASSERT_EQUAL(
std::chrono::duration_cast<std::chrono::nanoseconds>(stats.begin()->second.connData.startTimePrecise.time_since_epoch()).count(), 1491516383915793000);
PTF_ASSERT_EQUAL(stats.begin()->second.connData.endTime.tv_sec, 1491516399);
PTF_ASSERT_EQUAL(stats.begin()->second.connData.endTime.tv_usec, 576245);
PTF_ASSERT_EQUAL(std::chrono::duration_cast<std::chrono::nanoseconds>(
stats.begin()->second.connData.endTimePrecise.time_since_epoch())
.count(),
1491516399576245000);
PTF_ASSERT_EQUAL(
std::chrono::duration_cast<std::chrono::nanoseconds>(stats.begin()->second.connData.endTimePrecise.time_since_epoch()).count(), 1491516399576245000);
// clang-format on

std::string expectedReassemblyData = readFileIntoString(std::string("PcapExamples/one_tcp_stream_output.txt"));
PTF_ASSERT_EQUAL(expectedReassemblyData, stats.begin()->second.reassembledData);
Expand Down Expand Up @@ -870,16 +868,14 @@ PTF_TEST_CASE(TestTcpReassemblyMultipleConns)
PTF_ASSERT_EQUAL(iterConn1->second.flowKey, results.flowKeysList[0]);
PTF_ASSERT_EQUAL(iterConn1->second.startTime.tv_sec, 1361916156);
PTF_ASSERT_EQUAL(iterConn1->second.startTime.tv_usec, 677488);
// clang-format off
PTF_ASSERT_EQUAL(
std::chrono::duration_cast<std::chrono::nanoseconds>(iterConn1->second.startTimePrecise.time_since_epoch())
.count(),
1361916156677488000);
std::chrono::duration_cast<std::chrono::nanoseconds>(iterConn1->second.startTimePrecise.time_since_epoch()).count(), 1361916156677488000);
PTF_ASSERT_EQUAL(iterConn1->second.endTime.tv_sec, 1361916156);
PTF_ASSERT_EQUAL(iterConn1->second.endTime.tv_usec, 766111);
PTF_ASSERT_EQUAL(
std::chrono::duration_cast<std::chrono::nanoseconds>(iterConn1->second.endTimePrecise.time_since_epoch())
.count(),
1361916156766111000);
std::chrono::duration_cast<std::chrono::nanoseconds>(iterConn1->second.endTimePrecise.time_since_epoch()).count(), 1361916156766111000);
// clang-format on

// test the return of invalid connection flowKey
pcpp::ConnectionData dummyConn;
Expand Down Expand Up @@ -927,16 +923,14 @@ PTF_TEST_CASE(TestTcpReassemblyIPv6)
PTF_ASSERT_EQUAL(stats.begin()->second.connData.dstIP, expectedDstIP);
PTF_ASSERT_EQUAL(stats.begin()->second.connData.startTime.tv_sec, 1147551796);
PTF_ASSERT_EQUAL(stats.begin()->second.connData.startTime.tv_usec, 702602);
PTF_ASSERT_EQUAL(std::chrono::duration_cast<std::chrono::nanoseconds>(
stats.begin()->second.connData.startTimePrecise.time_since_epoch())
.count(),
1147551796702602000);
// clang-format off
PTF_ASSERT_EQUAL(
std::chrono::duration_cast<std::chrono::nanoseconds>(stats.begin()->second.connData.startTimePrecise.time_since_epoch()).count(), 1147551796702602000);
PTF_ASSERT_EQUAL(stats.begin()->second.connData.endTime.tv_sec, 1147551797);
PTF_ASSERT_EQUAL(stats.begin()->second.connData.endTime.tv_usec, 29966);
PTF_ASSERT_EQUAL(std::chrono::duration_cast<std::chrono::nanoseconds>(
stats.begin()->second.connData.endTimePrecise.time_since_epoch())
.count(),
1147551797029966000);
PTF_ASSERT_EQUAL(
std::chrono::duration_cast<std::chrono::nanoseconds>(stats.begin()->second.connData.endTimePrecise.time_since_epoch()).count(), 1147551797029966000);
// clang-format on

std::string expectedReassemblyData = readFileIntoString(std::string("PcapExamples/one_ipv6_http_stream.txt"));
PTF_ASSERT_EQUAL(expectedReassemblyData, stats.begin()->second.reassembledData);
Expand Down Expand Up @@ -973,16 +967,14 @@ PTF_TEST_CASE(TestTcpReassemblyIPv6MultConns)
PTF_ASSERT_EQUAL(iter->second.connData.srcPort, 35995);
PTF_ASSERT_EQUAL(stats.begin()->second.connData.startTime.tv_sec, 1147551795);
PTF_ASSERT_EQUAL(stats.begin()->second.connData.startTime.tv_usec, 526632);
PTF_ASSERT_EQUAL(std::chrono::duration_cast<std::chrono::nanoseconds>(
stats.begin()->second.connData.startTimePrecise.time_since_epoch())
.count(),
1147551795526632000);
// clang-format off
PTF_ASSERT_EQUAL(
std::chrono::duration_cast<std::chrono::nanoseconds>(stats.begin()->second.connData.startTimePrecise.time_since_epoch()).count(), 1147551795526632000);
PTF_ASSERT_EQUAL(stats.begin()->second.connData.endTime.tv_sec, 1147551797);
PTF_ASSERT_EQUAL(stats.begin()->second.connData.endTime.tv_usec, 111060);
PTF_ASSERT_EQUAL(std::chrono::duration_cast<std::chrono::nanoseconds>(
stats.begin()->second.connData.endTimePrecise.time_since_epoch())
.count(),
1147551797111060000);
PTF_ASSERT_EQUAL(
std::chrono::duration_cast<std::chrono::nanoseconds>(stats.begin()->second.connData.endTimePrecise.time_since_epoch()).count(), 1147551797111060000);
// clang-format on
expectedReassemblyData = readFileIntoString(std::string("PcapExamples/one_ipv6_http_stream4.txt"));
PTF_ASSERT_EQUAL(expectedReassemblyData, iter->second.reassembledData);

Expand All @@ -999,16 +991,14 @@ PTF_TEST_CASE(TestTcpReassemblyIPv6MultConns)
PTF_ASSERT_EQUAL(iter->second.connData.srcPort, 35999);
PTF_ASSERT_EQUAL(stats.begin()->second.connData.startTime.tv_sec, 1147551795);
PTF_ASSERT_EQUAL(stats.begin()->second.connData.startTime.tv_usec, 526632);
PTF_ASSERT_EQUAL(std::chrono::duration_cast<std::chrono::nanoseconds>(
stats.begin()->second.connData.startTimePrecise.time_since_epoch())
.count(),
1147551795526632000);
// clang-format off
PTF_ASSERT_EQUAL(
std::chrono::duration_cast<std::chrono::nanoseconds>(stats.begin()->second.connData.startTimePrecise.time_since_epoch()).count(), 1147551795526632000);
PTF_ASSERT_EQUAL(stats.begin()->second.connData.endTime.tv_sec, 1147551797);
PTF_ASSERT_EQUAL(stats.begin()->second.connData.endTime.tv_usec, 111060);
PTF_ASSERT_EQUAL(std::chrono::duration_cast<std::chrono::nanoseconds>(
stats.begin()->second.connData.endTimePrecise.time_since_epoch())
.count(),
1147551797111060000);
PTF_ASSERT_EQUAL(
std::chrono::duration_cast<std::chrono::nanoseconds>(stats.begin()->second.connData.endTimePrecise.time_since_epoch()).count(), 1147551797111060000);
// clang-format on

++iter;

Expand All @@ -1023,16 +1013,14 @@ PTF_TEST_CASE(TestTcpReassemblyIPv6MultConns)
PTF_ASSERT_EQUAL(iter->second.connData.srcPort, 40426);
PTF_ASSERT_EQUAL(stats.begin()->second.connData.startTime.tv_sec, 1147551795);
PTF_ASSERT_EQUAL(stats.begin()->second.connData.startTime.tv_usec, 526632);
PTF_ASSERT_EQUAL(std::chrono::duration_cast<std::chrono::nanoseconds>(
stats.begin()->second.connData.startTimePrecise.time_since_epoch())
.count(),
1147551795526632000);
// clang-format off
PTF_ASSERT_EQUAL(
std::chrono::duration_cast<std::chrono::nanoseconds>(stats.begin()->second.connData.startTimePrecise.time_since_epoch()).count(), 1147551795526632000);
PTF_ASSERT_EQUAL(stats.begin()->second.connData.endTime.tv_sec, 1147551797);
PTF_ASSERT_EQUAL(stats.begin()->second.connData.endTime.tv_usec, 111060);
PTF_ASSERT_EQUAL(std::chrono::duration_cast<std::chrono::nanoseconds>(
stats.begin()->second.connData.endTimePrecise.time_since_epoch())
.count(),
1147551797111060000);
PTF_ASSERT_EQUAL(
std::chrono::duration_cast<std::chrono::nanoseconds>(stats.begin()->second.connData.endTimePrecise.time_since_epoch()).count(), 1147551797111060000);
// clang-format on
expectedReassemblyData = readFileIntoString(std::string("PcapExamples/one_ipv6_http_stream3.txt"));
PTF_ASSERT_EQUAL(expectedReassemblyData, iter->second.reassembledData);

Expand All @@ -1049,16 +1037,15 @@ PTF_TEST_CASE(TestTcpReassemblyIPv6MultConns)
PTF_ASSERT_EQUAL(iter->second.connData.srcPort, 35997);
PTF_ASSERT_EQUAL(stats.begin()->second.connData.startTime.tv_sec, 1147551795);
PTF_ASSERT_EQUAL(stats.begin()->second.connData.startTime.tv_usec, 526632);
PTF_ASSERT_EQUAL(std::chrono::duration_cast<std::chrono::nanoseconds>(
stats.begin()->second.connData.startTimePrecise.time_since_epoch())
.count(),
1147551795526632000);
// clang-format off
PTF_ASSERT_EQUAL(
std::chrono::duration_cast<std::chrono::nanoseconds>(stats.begin()->second.connData.startTimePrecise.time_since_epoch()).count(), 1147551795526632000);
PTF_ASSERT_EQUAL(stats.begin()->second.connData.endTime.tv_sec, 1147551797);
PTF_ASSERT_EQUAL(stats.begin()->second.connData.endTime.tv_usec, 111060);
PTF_ASSERT_EQUAL(std::chrono::duration_cast<std::chrono::nanoseconds>(
stats.begin()->second.connData.endTimePrecise.time_since_epoch())
.count(),
1147551797111060000);
PTF_ASSERT_EQUAL(
std::chrono::duration_cast<std::chrono::nanoseconds>(stats.begin()->second.connData.endTimePrecise.time_since_epoch()).count(), 1147551797111060000);
// clang-format on

expectedReassemblyData = readFileIntoString(std::string("PcapExamples/one_ipv6_http_stream2.txt"));
PTF_ASSERT_EQUAL(expectedReassemblyData, iter->second.reassembledData);
} // TestTcpReassemblyIPv6MultConns
Expand Down Expand Up @@ -1097,16 +1084,14 @@ PTF_TEST_CASE(TestTcpReassemblyIPv6_OOO)
PTF_ASSERT_EQUAL(stats.begin()->second.connData.dstIP, expectedDstIP);
PTF_ASSERT_EQUAL(stats.begin()->second.connData.startTime.tv_sec, 1147551796);
PTF_ASSERT_EQUAL(stats.begin()->second.connData.startTime.tv_usec, 702602);
PTF_ASSERT_EQUAL(std::chrono::duration_cast<std::chrono::nanoseconds>(
stats.begin()->second.connData.startTimePrecise.time_since_epoch())
.count(),
1147551796702602000);
// clang-format off
PTF_ASSERT_EQUAL(
std::chrono::duration_cast<std::chrono::nanoseconds>(stats.begin()->second.connData.startTimePrecise.time_since_epoch()).count(), 1147551796702602000);
PTF_ASSERT_EQUAL(stats.begin()->second.connData.endTime.tv_sec, 1147551797);
PTF_ASSERT_EQUAL(stats.begin()->second.connData.endTime.tv_usec, 29966);
PTF_ASSERT_EQUAL(std::chrono::duration_cast<std::chrono::nanoseconds>(
stats.begin()->second.connData.endTimePrecise.time_since_epoch())
.count(),
1147551797029966000);
PTF_ASSERT_EQUAL(
std::chrono::duration_cast<std::chrono::nanoseconds>(stats.begin()->second.connData.endTimePrecise.time_since_epoch()).count(), 1147551797029966000);
// clang-format on

std::string expectedReassemblyData = readFileIntoString(std::string("PcapExamples/one_ipv6_http_stream.txt"));
PTF_ASSERT_EQUAL(expectedReassemblyData, stats.begin()->second.reassembledData);
Expand Down Expand Up @@ -1254,16 +1239,14 @@ PTF_TEST_CASE(TestTcpReassemblyMaxSeq)
PTF_ASSERT_EQUAL(stats.begin()->second.connData.dstIP, expectedDstIP);
PTF_ASSERT_EQUAL(stats.begin()->second.connData.startTime.tv_sec, 1491516383);
PTF_ASSERT_EQUAL(stats.begin()->second.connData.startTime.tv_usec, 915793);
PTF_ASSERT_EQUAL(std::chrono::duration_cast<std::chrono::nanoseconds>(
stats.begin()->second.connData.startTimePrecise.time_since_epoch())
.count(),
1491516383915793000);
// clang-format off
PTF_ASSERT_EQUAL(
std::chrono::duration_cast<std::chrono::nanoseconds>(stats.begin()->second.connData.startTimePrecise.time_since_epoch()).count(), 1491516383915793000);
PTF_ASSERT_EQUAL(stats.begin()->second.connData.endTime.tv_sec, 1491516399);
PTF_ASSERT_EQUAL(stats.begin()->second.connData.endTime.tv_usec, 576245);
PTF_ASSERT_EQUAL(std::chrono::duration_cast<std::chrono::nanoseconds>(
stats.begin()->second.connData.endTimePrecise.time_since_epoch())
.count(),
1491516399576245000);
PTF_ASSERT_EQUAL(
std::chrono::duration_cast<std::chrono::nanoseconds>(stats.begin()->second.connData.endTimePrecise.time_since_epoch()).count(), 1491516399576245000);
// clang-format on

std::string expectedReassemblyData = readFileIntoString(std::string("PcapExamples/one_tcp_stream_output.txt"));
PTF_ASSERT_EQUAL(expectedReassemblyData, stats.begin()->second.reassembledData);
Expand Down Expand Up @@ -1379,16 +1362,14 @@ PTF_TEST_CASE(TestTcpReassemblyHighPrecision)
PTF_ASSERT_EQUAL(stats[flowKeys[2]].numOfDataPackets, 2);
PTF_ASSERT_EQUAL(stats[flowKeys[2]].connData.startTime.tv_sec, 1361916156);
PTF_ASSERT_EQUAL(stats[flowKeys[2]].connData.startTime.tv_usec, 716947);
PTF_ASSERT_EQUAL(std::chrono::duration_cast<std::chrono::nanoseconds>(
stats[flowKeys[2]].connData.startTimePrecise.time_since_epoch())
.count(),
1361916156716947055);
// clang-format off
PTF_ASSERT_EQUAL(
std::chrono::duration_cast<std::chrono::nanoseconds>(stats[flowKeys[2]].connData.startTimePrecise.time_since_epoch()).count(), 1361916156716947055);
PTF_ASSERT_EQUAL(stats[flowKeys[2]].connData.endTime.tv_sec, 1361916156);
PTF_ASSERT_EQUAL(stats[flowKeys[2]].connData.endTime.tv_usec, 800214);
PTF_ASSERT_EQUAL(std::chrono::duration_cast<std::chrono::nanoseconds>(
stats[flowKeys[2]].connData.endTimePrecise.time_since_epoch())
.count(),
1361916156800214055);
PTF_ASSERT_EQUAL(
std::chrono::duration_cast<std::chrono::nanoseconds>(stats[flowKeys[2]].connData.endTimePrecise.time_since_epoch()).count(), 1361916156800214055);
// clang-format on

std::string expectedReassemblyData =
readFileIntoString(std::string("PcapExamples/three_http_streams_conn_1_output.txt"));
Expand Down

0 comments on commit b083640

Please sign in to comment.