You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@trafficserver.apache.org by ma...@apache.org on 2018/08/01 07:20:11 UTC

[trafficserver] branch quic-latest updated: Fix unit tests except handshake

This is an automated email from the ASF dual-hosted git repository.

masaori pushed a commit to branch quic-latest
in repository https://gitbox.apache.org/repos/asf/trafficserver.git


The following commit(s) were added to refs/heads/quic-latest by this push:
     new 8dcf5b1  Fix unit tests except handshake
8dcf5b1 is described below

commit 8dcf5b193c3841e75dcf567f685843f1cea1af52
Author: Masaori Koshiba <ma...@apache.org>
AuthorDate: Wed Aug 1 15:59:44 2018 +0900

    Fix unit tests except handshake
---
 iocore/net/quic/QUICTypes.h                      |  1 +
 iocore/net/quic/test/test_QUICFrameDispatcher.cc |  3 ++-
 iocore/net/quic/test/test_QUICLossDetector.cc    |  6 ++++--
 iocore/net/quic/test/test_QUICPacket.cc          | 12 +++++++-----
 iocore/net/quic/test/test_QUICPacketFactory.cc   |  2 +-
 5 files changed, 15 insertions(+), 9 deletions(-)

diff --git a/iocore/net/quic/QUICTypes.h b/iocore/net/quic/QUICTypes.h
index 4775e58..8b4df08 100644
--- a/iocore/net/quic/QUICTypes.h
+++ b/iocore/net/quic/QUICTypes.h
@@ -45,6 +45,7 @@ using QUICOffset       = uint64_t;
 
 // TODO: Update version number
 // Note: Prefix for drafts (0xff000000) + draft number
+// Note: Fix "Supported Version" field in test case of QUICPacketFactory_Create_VersionNegotiationPacket
 // Note: Change ExtensionType (QUICTransportParametersHandler::TRANSPORT_PARAMETER_ID) if it's changed
 constexpr QUICVersion QUIC_SUPPORTED_VERSIONS[] = {
   0xff00000d,
diff --git a/iocore/net/quic/test/test_QUICFrameDispatcher.cc b/iocore/net/quic/test/test_QUICFrameDispatcher.cc
index eca9aa3..30b38ce 100644
--- a/iocore/net/quic/test/test_QUICFrameDispatcher.cc
+++ b/iocore/net/quic/test/test_QUICFrameDispatcher.cc
@@ -40,7 +40,8 @@ TEST_CASE("QUICFrameHandler", "[quic]")
   auto tx            = new MockQUICPacketTransmitter();
   auto info          = new MockQUICConnectionInfoProvider();
   auto cc            = new MockQUICCongestionController(info);
-  auto lossDetector  = new MockQUICLossDetector(tx, info, cc, nullptr, 0);
+  QUICRTTMeasure rtt_measure;
+  auto lossDetector = new MockQUICLossDetector(tx, info, cc, &rtt_measure, 0);
 
   QUICFrameDispatcher quicFrameDispatcher(info);
   quicFrameDispatcher.add_handler(connection);
diff --git a/iocore/net/quic/test/test_QUICLossDetector.cc b/iocore/net/quic/test/test_QUICLossDetector.cc
index cebe4dc..628a96d 100644
--- a/iocore/net/quic/test/test_QUICLossDetector.cc
+++ b/iocore/net/quic/test/test_QUICLossDetector.cc
@@ -33,13 +33,14 @@ TEST_CASE("QUICLossDetector_Loss", "[quic]")
   MockQUICHandshakeProtocol hs_protocol;
   QUICPacketFactory pf;
   pf.set_hs_protocol(&hs_protocol);
+  QUICRTTMeasure rtt_measure;
 
   QUICAckFrameCreator *afc             = new QUICAckFrameCreator();
   QUICConnectionId connection_id       = {reinterpret_cast<const uint8_t *>("\x01"), 1};
   MockQUICPacketTransmitter *tx        = new MockQUICPacketTransmitter();
   MockQUICConnectionInfoProvider *info = new MockQUICConnectionInfoProvider();
   MockQUICCongestionController *cc     = new MockQUICCongestionController(info);
-  QUICLossDetector detector(tx, info, cc, nullptr, 0);
+  QUICLossDetector detector(tx, info, cc, &rtt_measure, 0);
   ats_unique_buf payload              = ats_unique_malloc(16);
   size_t payload_len                  = 16;
   QUICPacketUPtr packet               = QUICPacketFactory::create_null_packet();
@@ -165,7 +166,8 @@ TEST_CASE("QUICLossDetector_HugeGap", "[quic]")
   MockQUICPacketTransmitter *tx        = new MockQUICPacketTransmitter();
   MockQUICConnectionInfoProvider *info = new MockQUICConnectionInfoProvider();
   MockQUICCongestionController *cc     = new MockQUICCongestionController(info);
-  QUICLossDetector detector(tx, info, cc, nullptr, 0);
+  QUICRTTMeasure rtt_measure;
+  QUICLossDetector detector(tx, info, cc, &rtt_measure, 0);
 
   // Check initial state
   CHECK(tx->retransmitted.size() == 0);
diff --git a/iocore/net/quic/test/test_QUICPacket.cc b/iocore/net/quic/test/test_QUICPacket.cc
index c62c18c..67cc295 100644
--- a/iocore/net/quic/test/test_QUICPacket.cc
+++ b/iocore/net/quic/test/test_QUICPacket.cc
@@ -59,14 +59,15 @@ TEST_CASE("QUICPacketHeader - Long", "[quic]")
       0x55,                                           // DCIL/SCIL
       0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, // Destination Connection ID
       0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, // Source Connection ID
+      0x00,                                           // Token Length (i), Token (*)
       0x02,                                           // Payload length
       0xC1, 0x23, 0x45, 0x67,                         // Packet number
       0xff, 0xff,                                     // Payload (dummy)
     };
 
     QUICPacketHeaderUPtr header = QUICPacketHeader::load({}, {const_cast<uint8_t *>(input), [](void *p) {}}, sizeof(input), 0);
-    CHECK(header->size() == 27);
-    CHECK(header->packet_size() == 29);
+    CHECK(header->size() == sizeof(input) - 2); // Packet Length - Payload Length
+    CHECK(header->packet_size() == sizeof(input));
     CHECK(header->type() == QUICPacketType::INITIAL);
     CHECK(
       (header->destination_cid() == QUICConnectionId(reinterpret_cast<const uint8_t *>("\x01\x02\x03\x04\x05\x06\x07\x08"), 8)));
@@ -88,6 +89,7 @@ TEST_CASE("QUICPacketHeader - Long", "[quic]")
       0x55,                                           // DCIL/SCIL
       0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, // Destination Connection ID
       0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, // Source Connection ID
+      0x00,                                           // Token Length (i), Token (*)
       0x19,                                           // Length (Not 0x09 because it will have 16 bytes of AEAD tag)
       0xC1, 0x23, 0x45, 0x67,                         // Packet number
       0x11, 0x22, 0x33, 0x44, 0x55,                   // Payload (dummy)
@@ -99,9 +101,9 @@ TEST_CASE("QUICPacketHeader - Long", "[quic]")
       QUICPacketType::INITIAL, QUICKeyPhase::INITIAL, {reinterpret_cast<const uint8_t *>("\x01\x02\x03\x04\x05\x06\x07\x08"), 8},
       {reinterpret_cast<const uint8_t *>("\x11\x12\x13\x14\x15\x16\x17\x18"), 8}, 0x01234567, 0, 0x11223344, std::move(payload), 5);
 
-    CHECK(header->size() == 27);
+    CHECK(header->size() == sizeof(expected) - 5);
     CHECK(header->has_key_phase() == false);
-    CHECK(header->packet_size() == 32);
+    CHECK(header->packet_size() == sizeof(expected));
     CHECK(header->type() == QUICPacketType::INITIAL);
     CHECK(
       (header->destination_cid() == QUICConnectionId(reinterpret_cast<const uint8_t *>("\x01\x02\x03\x04\x05\x06\x07\x08"), 8)));
@@ -111,7 +113,7 @@ TEST_CASE("QUICPacketHeader - Long", "[quic]")
     CHECK(header->version() == 0x11223344);
 
     header->store(buf, &len);
-    CHECK(len == 27);
+    CHECK(len == header->size());
     CHECK(memcmp(buf, expected, len) == 0);
   }
 }
diff --git a/iocore/net/quic/test/test_QUICPacketFactory.cc b/iocore/net/quic/test/test_QUICPacketFactory.cc
index cd3bb50..d56bc14 100644
--- a/iocore/net/quic/test/test_QUICPacketFactory.cc
+++ b/iocore/net/quic/test/test_QUICPacketFactory.cc
@@ -53,7 +53,7 @@ TEST_CASE("QUICPacketFactory_Create_VersionNegotiationPacket", "[quic]")
     0x55,                                           // DCIL/SCIL
     0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, // Destination Connection ID
     0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, // Source Connection ID
-    0xff, 0x00, 0x00, 0x0c,                         // Supported Version
+    0xff, 0x00, 0x00, 0x0d,                         // Supported Version
   };
   uint8_t buf[1024] = {0};
   size_t buf_len;