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 2017/09/30 09:52:37 UTC
[trafficserver] branch quic-latest updated (4774200 -> 110d21d)
This is an automated email from the ASF dual-hosted git repository.
maskit pushed a change to branch quic-latest
in repository https://gitbox.apache.org/repos/asf/trafficserver.git.
from 4774200 fix mock complie error
new ebe0a75 Fix tests
new 110d21d Add nullptr check for error reason phrease
The 2 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails. The revisions
listed as "add" were already present in the repository and have only
been added to this reference.
Summary of changes:
iocore/net/quic/QUICFrame.cc | 12 +++--
iocore/net/quic/QUICFrame.h | 2 +-
iocore/net/quic/test/Makefile.am | 21 ++++++++
iocore/net/quic/test/test_QUICFlowController.cc | 64 +++++++++++------------
iocore/net/quic/test/test_QUICFrame.cc | 67 +++++++++++++++++++++++--
5 files changed, 126 insertions(+), 40 deletions(-)
--
To stop receiving notification emails like this one, please contact
['"commits@trafficserver.apache.org" <co...@trafficserver.apache.org>'].
[trafficserver] 01/02: Fix tests
Posted by ma...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
maskit pushed a commit to branch quic-latest
in repository https://gitbox.apache.org/repos/asf/trafficserver.git
commit ebe0a758b53b53e026db31c7c7b58d435de3abbd
Author: Masakazu Kitajo <ma...@apache.org>
AuthorDate: Sat Sep 30 18:01:20 2017 +0900
Fix tests
---
iocore/net/quic/test/Makefile.am | 20 ++++++++
iocore/net/quic/test/test_QUICFlowController.cc | 64 ++++++++++++-------------
2 files changed, 52 insertions(+), 32 deletions(-)
diff --git a/iocore/net/quic/test/Makefile.am b/iocore/net/quic/test/Makefile.am
index a958fe8..917aeeb 100644
--- a/iocore/net/quic/test/Makefile.am
+++ b/iocore/net/quic/test/Makefile.am
@@ -128,6 +128,10 @@ test_QUICFrame_SOURCES = \
../QUICCrypto.cc \
$(QUICCrypto_impl) \
../QUICTypes.cc \
+ ../QUICStream.cc \
+ ../QUICStreamState.cc \
+ ../QUICDebugNames.cc \
+ ../QUICFlowController.cc \
../../SSLNextProtocolSet.cc
test_QUICFrame_LDADD = \
@@ -366,11 +370,20 @@ test_QUICTypeUtil_LDFLAGS = \
@AM_LDFLAGS@
test_QUICTypeUtil_LDADD = \
+ $(top_builddir)/iocore/eventsystem/libinkevent.a \
$(top_builddir)/lib/ts/libtsutil.la
test_QUICTypeUtil_SOURCES = \
main.cc \
test_QUICTypeUtil.cc \
+ ../QUICStream.cc \
+ ../QUICStreamState.cc \
+ ../QUICFlowController.cc \
+ ../QUICDebugNames.cc \
+ ../QUICFrame.cc \
+ ../QUICPacket.cc \
+ ../QUICCrypto.cc \
+ $(QUICCrypto_impl) \
../QUICTypes.cc
#
@@ -394,6 +407,10 @@ test_QUICAckFrameCreator_SOURCES = \
../QUICTypes.cc \
../QUICFrame.cc \
../QUICPacket.cc \
+ ../QUICStream.cc \
+ ../QUICStreamState.cc \
+ ../QUICFlowController.cc \
+ ../QUICDebugNames.cc \
../QUICCrypto.cc \
$(QUICCrypto_impl) \
../../SSLNextProtocolSet.cc
@@ -462,6 +479,9 @@ test_QUICFlowController_SOURCES = \
main.cc \
test_QUICFlowController.cc \
../QUICFlowController.cc \
+ ../QUICStream.cc \
+ ../QUICStreamState.cc \
+ ../QUICDebugNames.cc \
../QUICTypes.cc \
../QUICPacket.cc \
../QUICCrypto.cc \
diff --git a/iocore/net/quic/test/test_QUICFlowController.cc b/iocore/net/quic/test/test_QUICFlowController.cc
index 9c7996b..e98278b 100644
--- a/iocore/net/quic/test/test_QUICFlowController.cc
+++ b/iocore/net/quic/test/test_QUICFlowController.cc
@@ -29,7 +29,7 @@
TEST_CASE("QUICFlowController_Local_Connection", "[quic]")
{
- QUICError error;
+ std::unique_ptr<QUICError> error = nullptr;
MockQUICFrameTransmitter tx;
QUICLocalConnectionFlowController fc(1024, &tx);
@@ -40,35 +40,35 @@ TEST_CASE("QUICFlowController_Local_Connection", "[quic]")
error = fc.update(256);
CHECK(fc.current_offset() == 256);
CHECK(fc.current_limit() == 1024);
- CHECK(error.cls == QUICErrorClass::NONE);
+ CHECK(error->cls == QUICErrorClass::NONE);
error = fc.update(512);
CHECK(fc.current_offset() == 512);
CHECK(fc.current_limit() == 1024);
- CHECK(error.cls == QUICErrorClass::NONE);
+ CHECK(error->cls == QUICErrorClass::NONE);
// Retransmit
error = fc.update(512);
CHECK(fc.current_offset() == 512);
CHECK(fc.current_limit() == 1024);
- CHECK(error.cls == QUICErrorClass::NONE);
+ CHECK(error->cls == QUICErrorClass::NONE);
error = fc.update(1024);
CHECK(fc.current_offset() == 1024);
CHECK(fc.current_limit() == 1024);
- CHECK(error.cls == QUICErrorClass::NONE);
+ CHECK(error->cls == QUICErrorClass::NONE);
// Delay
error = fc.update(512);
CHECK(fc.current_offset() == 1024);
CHECK(fc.current_limit() == 1024);
- CHECK(error.cls == QUICErrorClass::NONE);
+ CHECK(error->cls == QUICErrorClass::NONE);
// Exceed limit
error = fc.update(1280);
CHECK(fc.current_offset() == 1024);
CHECK(fc.current_limit() == 1024);
- CHECK(error.code == QUICErrorCode::FLOW_CONTROL_ERROR);
+ CHECK(error->code == QUICErrorCode::FLOW_CONTROL_ERROR);
// MAX_STREAM_DATA
CHECK(tx.frameCount[static_cast<int>(QUICFrameType::MAX_DATA)] == 0);
@@ -80,12 +80,12 @@ TEST_CASE("QUICFlowController_Local_Connection", "[quic]")
error = fc.update(1280);
CHECK(fc.current_offset() == 1280);
CHECK(fc.current_limit() == 2048);
- CHECK(error.cls == QUICErrorClass::NONE);
+ CHECK(error->cls == QUICErrorClass::NONE);
}
TEST_CASE("QUICFlowController_Remote_Connection", "[quic]")
{
- QUICError error;
+ std::unique_ptr<QUICError> error = nullptr;
MockQUICFrameTransmitter tx;
QUICRemoteConnectionFlowController fc(1024, &tx);
@@ -96,36 +96,36 @@ TEST_CASE("QUICFlowController_Remote_Connection", "[quic]")
error = fc.update(256);
CHECK(fc.current_offset() == 256);
CHECK(fc.current_limit() == 1024);
- CHECK(error.cls == QUICErrorClass::NONE);
+ CHECK(error->cls == QUICErrorClass::NONE);
error = fc.update(512);
CHECK(fc.current_offset() == 512);
CHECK(fc.current_limit() == 1024);
- CHECK(error.cls == QUICErrorClass::NONE);
+ CHECK(error->cls == QUICErrorClass::NONE);
// Retransmit
error = fc.update(512);
CHECK(fc.current_offset() == 512);
CHECK(fc.current_limit() == 1024);
- CHECK(error.cls == QUICErrorClass::NONE);
+ CHECK(error->cls == QUICErrorClass::NONE);
error = fc.update(1024);
CHECK(fc.current_offset() == 1024);
CHECK(fc.current_limit() == 1024);
- CHECK(error.cls == QUICErrorClass::NONE);
+ CHECK(error->cls == QUICErrorClass::NONE);
// Delay
error = fc.update(512);
CHECK(fc.current_offset() == 1024);
CHECK(fc.current_limit() == 1024);
- CHECK(error.cls == QUICErrorClass::NONE);
+ CHECK(error->cls == QUICErrorClass::NONE);
// Exceed limit
CHECK(tx.frameCount[static_cast<int>(QUICFrameType::BLOCKED)] == 0);
error = fc.update(1280);
CHECK(fc.current_offset() == 1024);
CHECK(fc.current_limit() == 1024);
- CHECK(error.cls != QUICErrorClass::NONE);
+ CHECK(error->cls != QUICErrorClass::NONE);
CHECK(tx.frameCount[static_cast<int>(QUICFrameType::BLOCKED)] == 1);
// MAX_STREAM_DATA
@@ -136,12 +136,12 @@ TEST_CASE("QUICFlowController_Remote_Connection", "[quic]")
error = fc.update(1280);
CHECK(fc.current_offset() == 1280);
CHECK(fc.current_limit() == 2048);
- CHECK(error.cls == QUICErrorClass::NONE);
+ CHECK(error->cls == QUICErrorClass::NONE);
}
TEST_CASE("QUICFlowController_Local_Stream", "[quic]")
{
- QUICError error;
+ std::unique_ptr<QUICError> error = nullptr;
MockQUICFrameTransmitter tx;
QUICLocalStreamFlowController fc(1024, &tx, 0);
@@ -152,35 +152,35 @@ TEST_CASE("QUICFlowController_Local_Stream", "[quic]")
error = fc.update(256);
CHECK(fc.current_offset() == 256);
CHECK(fc.current_limit() == 1024);
- CHECK(error.cls == QUICErrorClass::NONE);
+ CHECK(error->cls == QUICErrorClass::NONE);
error = fc.update(512);
CHECK(fc.current_offset() == 512);
CHECK(fc.current_limit() == 1024);
- CHECK(error.cls == QUICErrorClass::NONE);
+ CHECK(error->cls == QUICErrorClass::NONE);
// Retransmit
error = fc.update(512);
CHECK(fc.current_offset() == 512);
CHECK(fc.current_limit() == 1024);
- CHECK(error.cls == QUICErrorClass::NONE);
+ CHECK(error->cls == QUICErrorClass::NONE);
error = fc.update(1024);
CHECK(fc.current_offset() == 1024);
CHECK(fc.current_limit() == 1024);
- CHECK(error.cls == QUICErrorClass::NONE);
+ CHECK(error->cls == QUICErrorClass::NONE);
// Delay
error = fc.update(512);
CHECK(fc.current_offset() == 1024);
CHECK(fc.current_limit() == 1024);
- CHECK(error.cls == QUICErrorClass::NONE);
+ CHECK(error->cls == QUICErrorClass::NONE);
// Exceed limit
error = fc.update(1280);
CHECK(fc.current_offset() == 1024);
CHECK(fc.current_limit() == 1024);
- CHECK(error.code == QUICErrorCode::FLOW_CONTROL_ERROR);
+ CHECK(error->code == QUICErrorCode::FLOW_CONTROL_ERROR);
// MAX_STREAM_DATA
CHECK(tx.frameCount[static_cast<int>(QUICFrameType::MAX_STREAM_DATA)] == 0);
@@ -192,12 +192,12 @@ TEST_CASE("QUICFlowController_Local_Stream", "[quic]")
error = fc.update(1280);
CHECK(fc.current_offset() == 1280);
CHECK(fc.current_limit() == 2048);
- CHECK(error.cls == QUICErrorClass::NONE);
+ CHECK(error->cls == QUICErrorClass::NONE);
}
TEST_CASE("QUICFlowController_Remote_Stream", "[quic]")
{
- QUICError error;
+ std::unique_ptr<QUICError> error = nullptr;
MockQUICFrameTransmitter tx;
QUICRemoteStreamFlowController fc(1024, &tx, 0);
@@ -208,36 +208,36 @@ TEST_CASE("QUICFlowController_Remote_Stream", "[quic]")
error = fc.update(256);
CHECK(fc.current_offset() == 256);
CHECK(fc.current_limit() == 1024);
- CHECK(error.cls == QUICErrorClass::NONE);
+ CHECK(error->cls == QUICErrorClass::NONE);
error = fc.update(512);
CHECK(fc.current_offset() == 512);
CHECK(fc.current_limit() == 1024);
- CHECK(error.cls == QUICErrorClass::NONE);
+ CHECK(error->cls == QUICErrorClass::NONE);
// Retransmit
error = fc.update(512);
CHECK(fc.current_offset() == 512);
CHECK(fc.current_limit() == 1024);
- CHECK(error.cls == QUICErrorClass::NONE);
+ CHECK(error->cls == QUICErrorClass::NONE);
error = fc.update(1024);
CHECK(fc.current_offset() == 1024);
CHECK(fc.current_limit() == 1024);
- CHECK(error.cls == QUICErrorClass::NONE);
+ CHECK(error->cls == QUICErrorClass::NONE);
// Delay
error = fc.update(512);
CHECK(fc.current_offset() == 1024);
CHECK(fc.current_limit() == 1024);
- CHECK(error.cls == QUICErrorClass::NONE);
+ CHECK(error->cls == QUICErrorClass::NONE);
// Exceed limit
CHECK(tx.frameCount[static_cast<int>(QUICFrameType::STREAM_BLOCKED)] == 0);
error = fc.update(1280);
CHECK(fc.current_offset() == 1024);
CHECK(fc.current_limit() == 1024);
- CHECK(error.cls != QUICErrorClass::NONE);
+ CHECK(error->cls != QUICErrorClass::NONE);
CHECK(tx.frameCount[static_cast<int>(QUICFrameType::STREAM_BLOCKED)] == 1);
// MAX_STREAM_DATA
@@ -248,5 +248,5 @@ TEST_CASE("QUICFlowController_Remote_Stream", "[quic]")
error = fc.update(1280);
CHECK(fc.current_offset() == 1280);
CHECK(fc.current_limit() == 2048);
- CHECK(error.cls == QUICErrorClass::NONE);
+ CHECK(error->cls == QUICErrorClass::NONE);
}
--
To stop receiving notification emails like this one, please contact
"commits@trafficserver.apache.org" <co...@trafficserver.apache.org>.
[trafficserver] 02/02: Add nullptr check for error reason phrease
Posted by ma...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
maskit pushed a commit to branch quic-latest
in repository https://gitbox.apache.org/repos/asf/trafficserver.git
commit 110d21d5b8482915bfc4ad1cea64d127af95b4c9
Author: Masakazu Kitajo <ma...@apache.org>
AuthorDate: Sat Sep 30 18:48:22 2017 +0900
Add nullptr check for error reason phrease
---
iocore/net/quic/QUICFrame.cc | 12 ++++--
iocore/net/quic/QUICFrame.h | 2 +-
iocore/net/quic/test/Makefile.am | 1 +
iocore/net/quic/test/test_QUICFrame.cc | 67 ++++++++++++++++++++++++++++++++--
4 files changed, 74 insertions(+), 8 deletions(-)
diff --git a/iocore/net/quic/QUICFrame.cc b/iocore/net/quic/QUICFrame.cc
index 0db9d8c..69951d4 100644
--- a/iocore/net/quic/QUICFrame.cc
+++ b/iocore/net/quic/QUICFrame.cc
@@ -807,8 +807,10 @@ QUICConnectionCloseFrame::store(uint8_t *buf, size_t *len) const
p += n;
QUICTypeUtil::write_uint_as_nbytes(this->_reason_phrase_length, 2, p, &n);
p += n;
- memcpy(p, this->_reason_phrase, this->_reason_phrase_length);
- p += this->_reason_phrase_length;
+ if (this->_reason_phrase_length > 0) {
+ memcpy(p, this->_reason_phrase, this->_reason_phrase_length);
+ p += this->_reason_phrase_length;
+ }
*len = p - buf;
}
@@ -1337,7 +1339,11 @@ QUICFrameFactory::create_connection_close_frame(QUICErrorCode error_code, uint16
std::unique_ptr<QUICConnectionCloseFrame, QUICFrameDeleterFunc>
QUICFrameFactory::create_connection_close_frame(QUICConnectionErrorUPtr error)
{
- return QUICFrameFactory::create_connection_close_frame(error->code, strlen(error->msg), error->msg);
+ if (error->msg) {
+ return QUICFrameFactory::create_connection_close_frame(error->code, strlen(error->msg), error->msg);
+ } else {
+ return QUICFrameFactory::create_connection_close_frame(error->code);
+ }
}
std::unique_ptr<QUICMaxDataFrame, QUICFrameDeleterFunc>
diff --git a/iocore/net/quic/QUICFrame.h b/iocore/net/quic/QUICFrame.h
index 15c098c..0b1e554 100644
--- a/iocore/net/quic/QUICFrame.h
+++ b/iocore/net/quic/QUICFrame.h
@@ -602,7 +602,7 @@ public:
* Creates a CONNECTION_CLOSE frame.
*/
static std::unique_ptr<QUICConnectionCloseFrame, QUICFrameDeleterFunc> create_connection_close_frame(
- QUICErrorCode error_code, uint16_t reason_phrase_length, const char *reason_phrase);
+ QUICErrorCode error_code, uint16_t reason_phrase_length = 0, const char *reason_phrase = nullptr);
static std::unique_ptr<QUICConnectionCloseFrame, QUICFrameDeleterFunc> create_connection_close_frame(
QUICConnectionErrorUPtr error);
diff --git a/iocore/net/quic/test/Makefile.am b/iocore/net/quic/test/Makefile.am
index 917aeeb..487e532 100644
--- a/iocore/net/quic/test/Makefile.am
+++ b/iocore/net/quic/test/Makefile.am
@@ -117,6 +117,7 @@ test_QUICFrame_CPPFLAGS = \
$(AM_CPPFLAGS)
test_QUICFrame_LDFLAGS = \
+ $(top_builddir)/proxy/shared/libUglyLogStubs.a \
@AM_LDFLAGS@
test_QUICFrame_SOURCES = \
diff --git a/iocore/net/quic/test/test_QUICFrame.cc b/iocore/net/quic/test/test_QUICFrame.cc
index 6540147..be140b3 100644
--- a/iocore/net/quic/test/test_QUICFrame.cc
+++ b/iocore/net/quic/test/test_QUICFrame.cc
@@ -23,7 +23,9 @@
#include "catch.hpp"
+#include "quic/Mock.h"
#include "quic/QUICFrame.h"
+#include "quic/QUICStream.h"
TEST_CASE("QUICFrame Type", "[quic]")
{
@@ -374,6 +376,21 @@ TEST_CASE("Load ConnectionClose Frame", "[quic]")
CHECK(connectionCloseFrame1->error_code() == QUICErrorCode::NO_ERROR);
CHECK(connectionCloseFrame1->reason_phrase_length() == 5);
CHECK(memcmp(connectionCloseFrame1->reason_phrase(), buf1 + 7, 5) == 0);
+
+ // No reason phrase
+ uint8_t buf2[] = {
+ 0x02, // Type
+ 0x80, 0x00, 0x00, 0x00, // Error Code
+ 0x00, 0x00, // Reason Phrase Length
+ };
+ std::shared_ptr<const QUICFrame> frame2 = QUICFrameFactory::create(buf2, sizeof(buf1));
+ CHECK(frame2->type() == QUICFrameType::CONNECTION_CLOSE);
+ CHECK(frame2->size() == 7);
+ std::shared_ptr<const QUICConnectionCloseFrame> connectionCloseFrame2 =
+ std::dynamic_pointer_cast<const QUICConnectionCloseFrame>(frame2);
+ CHECK(connectionCloseFrame2 != nullptr);
+ CHECK(connectionCloseFrame2->error_code() == QUICErrorCode::NO_ERROR);
+ CHECK(connectionCloseFrame2->reason_phrase_length() == 0);
}
TEST_CASE("Store ConnectionClose Frame", "[quic]")
@@ -381,16 +398,26 @@ TEST_CASE("Store ConnectionClose Frame", "[quic]")
uint8_t buf[65535];
size_t len;
- uint8_t expected[] = {
+ uint8_t expected1[] = {
0x02, // Type
0x80, 0x00, 0x00, 0x00, // Error Code
0x00, 0x05, // Reason Phrase Length
0x41, 0x42, 0x43, 0x44, 0x45 // Reason Phrase ("ABCDE");
};
- QUICConnectionCloseFrame connectionCloseFrame(QUICErrorCode::NO_ERROR, 5, "ABCDE");
- connectionCloseFrame.store(buf, &len);
+ QUICConnectionCloseFrame connectionCloseFrame1(QUICErrorCode::NO_ERROR, 5, "ABCDE");
+ connectionCloseFrame1.store(buf, &len);
CHECK(len == 12);
- CHECK(memcmp(buf, expected, len) == 0);
+ CHECK(memcmp(buf, expected1, len) == 0);
+
+ uint8_t expected2[] = {
+ 0x02, // Type
+ 0x80, 0x00, 0x00, 0x00, // Error Code
+ 0x00, 0x00, // Reason Phrase Length
+ };
+ QUICConnectionCloseFrame connectionCloseFrame2(QUICErrorCode::NO_ERROR, 0, nullptr);
+ connectionCloseFrame2.store(buf, &len);
+ CHECK(len == 7);
+ CHECK(memcmp(buf, expected2, len) == 0);
}
TEST_CASE("Load MaxData Frame", "[quic]")
@@ -681,3 +708,35 @@ TEST_CASE("QUICFrameFactory Fast Create Unknown Frame", "[quic]")
std::shared_ptr<const QUICFrame> frame1 = factory.fast_create(buf1, sizeof(buf1));
CHECK(frame1 == nullptr);
}
+
+TEST_CASE("QUICFrameFactory Create CONNECTION_CLOSE with a QUICConnectionError", "[quic]")
+{
+ std::unique_ptr<QUICConnectionError> error =
+ std::unique_ptr<QUICConnectionError>(new QUICConnectionError(QUICErrorClass::QUIC_TRANSPORT, QUICErrorCode::INTERNAL_ERROR));
+ std::unique_ptr<QUICConnectionCloseFrame, QUICFrameDeleterFunc> connection_close_frame1 =
+ QUICFrameFactory::create_connection_close_frame(std::move(error));
+ CHECK(connection_close_frame1->error_code() == QUICErrorCode::INTERNAL_ERROR);
+ CHECK(connection_close_frame1->reason_phrase_length() == 0);
+ CHECK(connection_close_frame1->reason_phrase() == nullptr);
+
+ error = std::unique_ptr<QUICConnectionError>(
+ new QUICConnectionError(QUICErrorClass::QUIC_TRANSPORT, QUICErrorCode::INTERNAL_ERROR, "test"));
+ std::unique_ptr<QUICConnectionCloseFrame, QUICFrameDeleterFunc> connection_close_frame2 =
+ QUICFrameFactory::create_connection_close_frame(std::move(error));
+ CHECK(connection_close_frame2->error_code() == QUICErrorCode::INTERNAL_ERROR);
+ CHECK(connection_close_frame2->reason_phrase_length() == 4);
+ CHECK(memcmp(connection_close_frame2->reason_phrase(), "test", 4) == 0);
+}
+
+TEST_CASE("QUICFrameFactory Create RST_STREAM with a QUICStreamError", "[quic]")
+{
+ QUICStream stream;
+ stream.init(new MockQUICFrameTransmitter(), 0x1234, 0, 0);
+ std::unique_ptr<QUICStreamError> error =
+ std::unique_ptr<QUICStreamError>(new QUICStreamError(&stream, QUICErrorClass::QUIC_TRANSPORT, QUICErrorCode::INTERNAL_ERROR));
+ std::unique_ptr<QUICRstStreamFrame, QUICFrameDeleterFunc> rst_stream_frame1 =
+ QUICFrameFactory::create_rst_stream_frame(std::move(error));
+ CHECK(rst_stream_frame1->error_code() == QUICErrorCode::INTERNAL_ERROR);
+ CHECK(rst_stream_frame1->stream_id() == 0x1234);
+ CHECK(rst_stream_frame1->final_offset() == 0);
+}
--
To stop receiving notification emails like this one, please contact
"commits@trafficserver.apache.org" <co...@trafficserver.apache.org>.