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

Side by Side Diff: net/quic/core/quic_connection_test.cc

Issue 2249813002: Create EXPECT_QUIC_BUG macro, and modify QUIC tests to use it. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 4 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 unified diff | Download patch
« no previous file with comments | « net/quic/core/quic_config_test.cc ('k') | net/quic/core/quic_flow_controller_test.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "net/quic/core/quic_connection.h" 5 #include "net/quic/core/quic_connection.h"
6 6
7 #include <errno.h> 7 #include <errno.h>
8 #include <memory> 8 #include <memory>
9 #include <ostream> 9 #include <ostream>
10 #include <utility> 10 #include <utility>
(...skipping 691 matching lines...) Expand 10 before | Expand all | Expand 10 after
702 creator_(QuicConnectionPeer::GetPacketCreator(&connection_)), 702 creator_(QuicConnectionPeer::GetPacketCreator(&connection_)),
703 generator_(QuicConnectionPeer::GetPacketGenerator(&connection_)), 703 generator_(QuicConnectionPeer::GetPacketGenerator(&connection_)),
704 manager_(QuicConnectionPeer::GetSentPacketManager(&connection_, 704 manager_(QuicConnectionPeer::GetSentPacketManager(&connection_,
705 kDefaultPathId)), 705 kDefaultPathId)),
706 frame1_(1, false, 0, StringPiece(data1)), 706 frame1_(1, false, 0, StringPiece(data1)),
707 frame2_(1, false, 3, StringPiece(data2)), 707 frame2_(1, false, 3, StringPiece(data2)),
708 packet_number_length_(PACKET_6BYTE_PACKET_NUMBER), 708 packet_number_length_(PACKET_6BYTE_PACKET_NUMBER),
709 connection_id_length_(PACKET_8BYTE_CONNECTION_ID) { 709 connection_id_length_(PACKET_8BYTE_CONNECTION_ID) {
710 connection_.set_defer_send_in_response_to_packets(GetParam().ack_response == 710 connection_.set_defer_send_in_response_to_packets(GetParam().ack_response ==
711 AckResponse::kDefer); 711 AckResponse::kDefer);
712 FLAGS_quic_always_log_bugs_for_tests = true;
713 connection_.set_visitor(&visitor_); 712 connection_.set_visitor(&visitor_);
714 connection_.SetSendAlgorithm(kDefaultPathId, send_algorithm_); 713 connection_.SetSendAlgorithm(kDefaultPathId, send_algorithm_);
715 connection_.SetLossAlgorithm(kDefaultPathId, loss_algorithm_.get()); 714 connection_.SetLossAlgorithm(kDefaultPathId, loss_algorithm_.get());
716 framer_.set_received_entropy_calculator(&entropy_calculator_); 715 framer_.set_received_entropy_calculator(&entropy_calculator_);
717 peer_framer_.set_received_entropy_calculator(&peer_entropy_calculator_); 716 peer_framer_.set_received_entropy_calculator(&peer_entropy_calculator_);
718 EXPECT_CALL(*send_algorithm_, TimeUntilSend(_, _)) 717 EXPECT_CALL(*send_algorithm_, TimeUntilSend(_, _))
719 .WillRepeatedly(Return(QuicTime::Delta::Zero())); 718 .WillRepeatedly(Return(QuicTime::Delta::Zero()));
720 EXPECT_CALL(*send_algorithm_, OnPacketSent(_, _, _, _, _)) 719 EXPECT_CALL(*send_algorithm_, OnPacketSent(_, _, _, _, _))
721 .Times(AnyNumber()); 720 .Times(AnyNumber());
722 EXPECT_CALL(*send_algorithm_, RetransmissionDelay()) 721 EXPECT_CALL(*send_algorithm_, RetransmissionDelay())
(...skipping 644 matching lines...) Expand 10 before | Expand all | Expand 10 after
1367 EXPECT_FALSE(QuicConnectionPeer::GetConnectionClosePacket(&connection_) == 1366 EXPECT_FALSE(QuicConnectionPeer::GetConnectionClosePacket(&connection_) ==
1368 nullptr); 1367 nullptr);
1369 } 1368 }
1370 1369
1371 TEST_P(QuicConnectionTest, RejectUnencryptedStreamData) { 1370 TEST_P(QuicConnectionTest, RejectUnencryptedStreamData) {
1372 // Process an unencrypted packet from the non-crypto stream. 1371 // Process an unencrypted packet from the non-crypto stream.
1373 frame1_.stream_id = 3; 1372 frame1_.stream_id = 3;
1374 EXPECT_CALL(visitor_, OnSuccessfulVersionNegotiation(_)); 1373 EXPECT_CALL(visitor_, OnSuccessfulVersionNegotiation(_));
1375 EXPECT_CALL(visitor_, OnConnectionClosed(QUIC_UNENCRYPTED_STREAM_DATA, _, 1374 EXPECT_CALL(visitor_, OnConnectionClosed(QUIC_UNENCRYPTED_STREAM_DATA, _,
1376 ConnectionCloseSource::FROM_SELF)); 1375 ConnectionCloseSource::FROM_SELF));
1377 EXPECT_DFATAL(ProcessDataPacket(kDefaultPathId, 1, !kEntropyFlag), ""); 1376 EXPECT_QUIC_BUG(ProcessDataPacket(kDefaultPathId, 1, !kEntropyFlag), "");
1378 EXPECT_FALSE(QuicConnectionPeer::GetConnectionClosePacket(&connection_) == 1377 EXPECT_FALSE(QuicConnectionPeer::GetConnectionClosePacket(&connection_) ==
1379 nullptr); 1378 nullptr);
1380 const vector<QuicConnectionCloseFrame>& connection_close_frames = 1379 const vector<QuicConnectionCloseFrame>& connection_close_frames =
1381 writer_->connection_close_frames(); 1380 writer_->connection_close_frames();
1382 EXPECT_EQ(1u, connection_close_frames.size()); 1381 EXPECT_EQ(1u, connection_close_frames.size());
1383 EXPECT_EQ(QUIC_UNENCRYPTED_STREAM_DATA, 1382 EXPECT_EQ(QUIC_UNENCRYPTED_STREAM_DATA,
1384 connection_close_frames[0].error_code); 1383 connection_close_frames[0].error_code);
1385 } 1384 }
1386 1385
1387 TEST_P(QuicConnectionTest, TruncatedAck) { 1386 TEST_P(QuicConnectionTest, TruncatedAck) {
(...skipping 3387 matching lines...) Expand 10 before | Expand all | Expand 10 after
4775 // Ensure that this has caused the ACK alarm to be set. 4774 // Ensure that this has caused the ACK alarm to be set.
4776 QuicAlarm* ack_alarm = QuicConnectionPeer::GetAckAlarm(&connection_); 4775 QuicAlarm* ack_alarm = QuicConnectionPeer::GetAckAlarm(&connection_);
4777 EXPECT_TRUE(ack_alarm->IsSet()); 4776 EXPECT_TRUE(ack_alarm->IsSet());
4778 } 4777 }
4779 4778
4780 TEST_P(QuicConnectionTest, NoDataNoFin) { 4779 TEST_P(QuicConnectionTest, NoDataNoFin) {
4781 // Make sure that a call to SendStreamWithData, with no data and no FIN, does 4780 // Make sure that a call to SendStreamWithData, with no data and no FIN, does
4782 // not result in a QuicAckNotifier being used-after-free (fail under ASAN). 4781 // not result in a QuicAckNotifier being used-after-free (fail under ASAN).
4783 // Regression test for b/18594622 4782 // Regression test for b/18594622
4784 scoped_refptr<MockAckListener> listener(new MockAckListener); 4783 scoped_refptr<MockAckListener> listener(new MockAckListener);
4785 EXPECT_DFATAL( 4784 EXPECT_QUIC_BUG(
4786 connection_.SendStreamDataWithString(3, "", 0, !kFin, listener.get()), 4785 connection_.SendStreamDataWithString(3, "", 0, !kFin, listener.get()),
4787 "Attempt to send empty stream frame"); 4786 "Attempt to send empty stream frame");
4788 } 4787 }
4789 4788
4790 TEST_P(QuicConnectionTest, DoNotSendGoAwayTwice) { 4789 TEST_P(QuicConnectionTest, DoNotSendGoAwayTwice) {
4791 EXPECT_FALSE(connection_.goaway_sent()); 4790 EXPECT_FALSE(connection_.goaway_sent());
4792 EXPECT_CALL(*send_algorithm_, OnPacketSent(_, _, _, _, _)).Times(1); 4791 EXPECT_CALL(*send_algorithm_, OnPacketSent(_, _, _, _, _)).Times(1);
4793 connection_.SendGoAway(QUIC_PEER_GOING_AWAY, kHeadersStreamId, "Going Away."); 4792 connection_.SendGoAway(QUIC_PEER_GOING_AWAY, kHeadersStreamId, "Going Away.");
4794 EXPECT_TRUE(connection_.goaway_sent()); 4793 EXPECT_TRUE(connection_.goaway_sent());
4795 EXPECT_CALL(*send_algorithm_, OnPacketSent(_, _, _, _, _)).Times(0); 4794 EXPECT_CALL(*send_algorithm_, OnPacketSent(_, _, _, _, _)).Times(0);
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
4834 EXPECT_CALL(*send_algorithm_, OnPacketSent(_, _, _, _, _)).Times(1); 4833 EXPECT_CALL(*send_algorithm_, OnPacketSent(_, _, _, _, _)).Times(1);
4835 connection_.SendPing(); 4834 connection_.SendPing();
4836 EXPECT_FALSE(connection_.HasQueuedData()); 4835 EXPECT_FALSE(connection_.HasQueuedData());
4837 } 4836 }
4838 4837
4839 TEST_P(QuicConnectionTest, SendingUnencryptedStreamDataFails) { 4838 TEST_P(QuicConnectionTest, SendingUnencryptedStreamDataFails) {
4840 FLAGS_quic_never_write_unencrypted_data = true; 4839 FLAGS_quic_never_write_unencrypted_data = true;
4841 EXPECT_CALL(visitor_, 4840 EXPECT_CALL(visitor_,
4842 OnConnectionClosed(QUIC_ATTEMPT_TO_SEND_UNENCRYPTED_STREAM_DATA, 4841 OnConnectionClosed(QUIC_ATTEMPT_TO_SEND_UNENCRYPTED_STREAM_DATA,
4843 _, ConnectionCloseSource::FROM_SELF)); 4842 _, ConnectionCloseSource::FROM_SELF));
4844 EXPECT_DFATAL(connection_.SendStreamDataWithString(3, "", 0, kFin, nullptr), 4843 EXPECT_QUIC_BUG(connection_.SendStreamDataWithString(3, "", 0, kFin, nullptr),
4845 "Cannot send stream data without encryption."); 4844 "Cannot send stream data without encryption.");
4846 EXPECT_FALSE(connection_.connected()); 4845 EXPECT_FALSE(connection_.connected());
4847 } 4846 }
4848 4847
4849 TEST_P(QuicConnectionTest, EnableMultipathNegotiation) { 4848 TEST_P(QuicConnectionTest, EnableMultipathNegotiation) {
4850 // Test multipath negotiation during crypto handshake. Multipath is enabled 4849 // Test multipath negotiation during crypto handshake. Multipath is enabled
4851 // when both endpoints enable multipath. 4850 // when both endpoints enable multipath.
4852 ValueRestore<bool> old_flag(&FLAGS_quic_enable_multipath, true); 4851 ValueRestore<bool> old_flag(&FLAGS_quic_enable_multipath, true);
4853 EXPECT_TRUE(connection_.connected()); 4852 EXPECT_TRUE(connection_.connected());
4854 EXPECT_FALSE(QuicConnectionPeer::IsMultipathEnabled(&connection_)); 4853 EXPECT_FALSE(QuicConnectionPeer::IsMultipathEnabled(&connection_));
4855 EXPECT_CALL(*send_algorithm_, SetFromConfig(_, _)); 4854 EXPECT_CALL(*send_algorithm_, SetFromConfig(_, _));
(...skipping 25 matching lines...) Expand all
4881 4880
4882 TEST_P(QuicConnectionTest, BadMultipathFlag) { 4881 TEST_P(QuicConnectionTest, BadMultipathFlag) {
4883 EXPECT_CALL(visitor_, OnConnectionClosed(QUIC_BAD_MULTIPATH_FLAG, _, 4882 EXPECT_CALL(visitor_, OnConnectionClosed(QUIC_BAD_MULTIPATH_FLAG, _,
4884 ConnectionCloseSource::FROM_SELF)); 4883 ConnectionCloseSource::FROM_SELF));
4885 4884
4886 // Receieve a packet with multipath flag on when multipath is not enabled. 4885 // Receieve a packet with multipath flag on when multipath is not enabled.
4887 EXPECT_TRUE(connection_.connected()); 4886 EXPECT_TRUE(connection_.connected());
4888 EXPECT_FALSE(QuicConnectionPeer::IsMultipathEnabled(&connection_)); 4887 EXPECT_FALSE(QuicConnectionPeer::IsMultipathEnabled(&connection_));
4889 peer_creator_.SetCurrentPath(/*path_id=*/1u, 1u, 10u); 4888 peer_creator_.SetCurrentPath(/*path_id=*/1u, 1u, 10u);
4890 QuicStreamFrame stream_frame(1u, false, 0u, StringPiece()); 4889 QuicStreamFrame stream_frame(1u, false, 0u, StringPiece());
4891 EXPECT_DFATAL( 4890 EXPECT_QUIC_BUG(
4892 ProcessFramePacket(QuicFrame(&stream_frame)), 4891 ProcessFramePacket(QuicFrame(&stream_frame)),
4893 "Received a packet with multipath flag but multipath is not enabled."); 4892 "Received a packet with multipath flag but multipath is not enabled.");
4894 EXPECT_FALSE(connection_.connected()); 4893 EXPECT_FALSE(connection_.connected());
4895 } 4894 }
4896 4895
4897 TEST_P(QuicConnectionTest, OnPathDegrading) { 4896 TEST_P(QuicConnectionTest, OnPathDegrading) {
4898 QuicByteCount packet_size; 4897 QuicByteCount packet_size;
4899 const size_t kMinTimeoutsBeforePathDegrading = 2; 4898 const size_t kMinTimeoutsBeforePathDegrading = 2;
4900 4899
4901 EXPECT_CALL(*send_algorithm_, OnPacketSent(_, _, _, _, _)) 4900 EXPECT_CALL(*send_algorithm_, OnPacketSent(_, _, _, _, _))
(...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after
5034 EXPECT_CALL(*send_algorithm_, OnApplicationLimited(_)).Times(0); 5033 EXPECT_CALL(*send_algorithm_, OnApplicationLimited(_)).Times(0);
5035 EXPECT_CALL(visitor_, WillingAndAbleToWrite()).WillRepeatedly(Return(true)); 5034 EXPECT_CALL(visitor_, WillingAndAbleToWrite()).WillRepeatedly(Return(true));
5036 BlockOnNextWrite(); 5035 BlockOnNextWrite();
5037 5036
5038 connection_.SendStreamData3(); 5037 connection_.SendStreamData3();
5039 } 5038 }
5040 5039
5041 } // namespace 5040 } // namespace
5042 } // namespace test 5041 } // namespace test
5043 } // namespace net 5042 } // namespace net
OLDNEW
« no previous file with comments | « net/quic/core/quic_config_test.cc ('k') | net/quic/core/quic_flow_controller_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698