Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(864)

Unified Diff: net/quic/quic_connection_test.cc

Issue 1395423009: relnote: add test cases to catch failure on uninitialized self_address_ (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@Add_comment_104108540
Patch Set: Minor cleanup Created 5 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« net/quic/quic_connection.cc ('K') | « net/quic/quic_connection.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/quic/quic_connection_test.cc
diff --git a/net/quic/quic_connection_test.cc b/net/quic/quic_connection_test.cc
index 1225d185db263d51d3ef4ae2f82efba4a706f2d6..441c46cb5da8691cd8171e307c43cb74e701f88b 100644
--- a/net/quic/quic_connection_test.cc
+++ b/net/quic/quic_connection_test.cc
@@ -239,6 +239,7 @@ class TestPacketWriter : public QuicPacketWriter {
framer_(SupportedVersions(version_)),
last_packet_size_(0),
write_blocked_(false),
+ write_should_fail_(false),
block_on_next_write_(false),
is_write_blocked_data_buffered_(false),
final_bytes_of_last_packet_(0),
@@ -274,6 +275,11 @@ class TestPacketWriter : public QuicPacketWriter {
if (IsWriteBlocked()) {
return WriteResult(WRITE_STATUS_BLOCKED, -1);
}
+
+ if (ShouldWriteFail()) {
+ return WriteResult(WRITE_STATUS_ERROR, 0);
+ }
+
last_packet_size_ = packet.length();
if (!write_pause_time_delta_.IsZero()) {
@@ -286,10 +292,14 @@ class TestPacketWriter : public QuicPacketWriter {
return is_write_blocked_data_buffered_;
}
+ bool ShouldWriteFail() { return write_should_fail_; }
+
bool IsWriteBlocked() const override { return write_blocked_; }
void SetWritable() override { write_blocked_ = false; }
+ void SetShouldWriteFail() { write_should_fail_ = true; }
+
QuicByteCount GetMaxPacketSize(
const IPEndPoint& /*peer_address*/) const override {
return max_packet_size_;
@@ -383,6 +393,7 @@ class TestPacketWriter : public QuicPacketWriter {
SimpleQuicFramer framer_;
size_t last_packet_size_;
bool write_blocked_;
+ bool write_should_fail_;
bool block_on_next_write_;
bool is_write_blocked_data_buffered_;
uint32 final_bytes_of_last_packet_;
@@ -3649,6 +3660,16 @@ TEST_P(QuicConnectionTest, SendScheduler) {
EXPECT_EQ(0u, connection_.NumQueuedPackets());
}
+TEST_P(QuicConnectionTest, FailToSendFirstPacket) {
+ // Test that the connection does not crash when it fails to send the first
+ // packet at which point self_address_ might be uninitialized.
+ EXPECT_CALL(visitor_, OnConnectionClosed(_, _)).Times(1);
+ QuicPacket* packet = ConstructDataPacket(1, 0, !kEntropyFlag);
+ writer_->SetShouldWriteFail();
+ connection_.SendPacket(ENCRYPTION_NONE, 1, packet, kTestEntropyHash,
+ HAS_RETRANSMITTABLE_DATA, false, false);
+}
+
TEST_P(QuicConnectionTest, SendSchedulerEAGAIN) {
QuicPacket* packet = ConstructDataPacket(1, 0, !kEntropyFlag);
BlockOnNextWrite();
« net/quic/quic_connection.cc ('K') | « net/quic/quic_connection.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698