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

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

Issue 2236973002: Landing Recent QUIC changes until 4AM, Aug 7, 2016 UTC-4 (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: flip quic_sequencer_buffer_retire_block_in_time to true 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_framer.cc ('k') | net/quic/core/quic_headers_stream_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_framer.h" 5 #include "net/quic/core/quic_framer.h"
6 6
7 #include <stdint.h> 7 #include <stdint.h>
8 8
9 #include <algorithm> 9 #include <algorithm>
10 #include <map> 10 #include <map>
(...skipping 334 matching lines...) Expand 10 before | Expand all | Expand 10 after
345 QuicPathCloseFrame path_close_frame_; 345 QuicPathCloseFrame path_close_frame_;
346 vector<string*> stream_data_; 346 vector<string*> stream_data_;
347 }; 347 };
348 348
349 class QuicFramerTest : public ::testing::TestWithParam<QuicVersion> { 349 class QuicFramerTest : public ::testing::TestWithParam<QuicVersion> {
350 public: 350 public:
351 QuicFramerTest() 351 QuicFramerTest()
352 : encrypter_(new test::TestEncrypter()), 352 : encrypter_(new test::TestEncrypter()),
353 decrypter_(new test::TestDecrypter()), 353 decrypter_(new test::TestDecrypter()),
354 start_(QuicTime::Zero() + QuicTime::Delta::FromMicroseconds(0x10)), 354 start_(QuicTime::Zero() + QuicTime::Delta::FromMicroseconds(0x10)),
355 framer_(QuicSupportedVersions(), start_, Perspective::IS_SERVER) { 355 framer_(AllSupportedVersions(), start_, Perspective::IS_SERVER) {
356 version_ = GetParam(); 356 version_ = GetParam();
357 framer_.set_version(version_); 357 framer_.set_version(version_);
358 framer_.SetDecrypter(ENCRYPTION_NONE, decrypter_); 358 framer_.SetDecrypter(ENCRYPTION_NONE, decrypter_);
359 framer_.SetEncrypter(ENCRYPTION_NONE, encrypter_); 359 framer_.SetEncrypter(ENCRYPTION_NONE, encrypter_);
360 framer_.set_visitor(&visitor_); 360 framer_.set_visitor(&visitor_);
361 framer_.set_received_entropy_calculator(&entropy_calculator_); 361 framer_.set_received_entropy_calculator(&entropy_calculator_);
362 } 362 }
363 363
364 // Helper function to get unsigned char representation of digit in the 364 // Helper function to get unsigned char representation of digit in the
365 // units place of the current QUIC version number. 365 // units place of the current QUIC version number.
(...skipping 4451 matching lines...) Expand 10 before | Expand all | Expand 10 after
4817 QuicStreamFrame stream_frame(kStreamId, true, kStreamOffset, 4817 QuicStreamFrame stream_frame(kStreamId, true, kStreamOffset,
4818 StringPiece("hello world!")); 4818 StringPiece("hello world!"));
4819 4819
4820 QuicFrames frames; 4820 QuicFrames frames;
4821 frames.push_back(QuicFrame(&stream_frame)); 4821 frames.push_back(QuicFrame(&stream_frame));
4822 4822
4823 // clang-format off 4823 // clang-format off
4824 unsigned char packet[] = { 4824 unsigned char packet[] = {
4825 // public flags (version, 8 byte connection_id) 4825 // public flags (version, 8 byte connection_id)
4826 static_cast<unsigned char>( 4826 static_cast<unsigned char>(
4827 framer_.version() > QUIC_VERSION_32 ? 0x3D : 0x3D), 4827 (FLAGS_quic_remove_v33_hacks &&
4828 framer_.version() > QUIC_VERSION_32) ? 0x39 : 0x3D),
4828 // connection_id 4829 // connection_id
4829 0x10, 0x32, 0x54, 0x76, 0x98, 0xBA, 0xDC, 0xFE, 4830 0x10, 0x32, 0x54, 0x76, 0x98, 0xBA, 0xDC, 0xFE,
4830 // version tag 4831 // version tag
4831 'Q', '0', GetQuicVersionDigitTens(), GetQuicVersionDigitOnes(), 4832 'Q', '0', GetQuicVersionDigitTens(), GetQuicVersionDigitOnes(),
4832 // packet number 4833 // packet number
4833 0xBC, 0x9A, 0x78, 0x56, 0x34, 0x12, 4834 0xBC, 0x9A, 0x78, 0x56, 0x34, 0x12,
4834 // private flags (entropy) 4835 // private flags (entropy)
4835 0x01, 4836 0x01,
4836 4837
4837 // frame type (stream frame with fin and no length) 4838 // frame type (stream frame with fin and no length)
4838 0xDF, 4839 0xDF,
4839 // stream id 4840 // stream id
4840 0x04, 0x03, 0x02, 0x01, 4841 0x04, 0x03, 0x02, 0x01,
4841 // offset 4842 // offset
4842 0x54, 0x76, 0x10, 0x32, 0xDC, 0xFE, 0x98, 0xBA, 4843 0x54, 0x76, 0x10, 0x32, 0xDC, 0xFE, 0x98, 0xBA,
4843 // data 4844 // data
4844 'h', 'e', 'l', 'l', 'o', ' ', 'w', 'o', 'r', 'l', 'd', '!', 4845 'h', 'e', 'l', 'l', 'o', ' ', 'w', 'o', 'r', 'l', 'd', '!',
4845 }; 4846 };
4846 unsigned char packet_34[] = { 4847 unsigned char packet_34[] = {
4847 // public flags (version, 8 byte connection_id) 4848 // public flags (version, 8 byte connection_id)
4848 0x3D, 4849 static_cast<unsigned char>(
4850 FLAGS_quic_remove_v33_hacks ? 0x39 : 0x3D),
4849 // connection_id 4851 // connection_id
4850 0x10, 0x32, 0x54, 0x76, 0x98, 0xBA, 0xDC, 0xFE, 4852 0x10, 0x32, 0x54, 0x76, 0x98, 0xBA, 0xDC, 0xFE,
4851 // version tag 4853 // version tag
4852 'Q', '0', GetQuicVersionDigitTens(), GetQuicVersionDigitOnes(), 4854 'Q', '0', GetQuicVersionDigitTens(), GetQuicVersionDigitOnes(),
4853 // packet number 4855 // packet number
4854 0xBC, 0x9A, 0x78, 0x56, 0x34, 0x12, 4856 0xBC, 0x9A, 0x78, 0x56, 0x34, 0x12,
4855 4857
4856 // frame type (stream frame with fin and no length) 4858 // frame type (stream frame with fin and no length)
4857 0xDF, 4859 0xDF,
4858 // stream id 4860 // stream id
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after
4970 QuicStreamFrame stream_frame(kStreamId, true, kStreamOffset, 4972 QuicStreamFrame stream_frame(kStreamId, true, kStreamOffset,
4971 StringPiece("hello world!")); 4973 StringPiece("hello world!"));
4972 4974
4973 QuicFrames frames; 4975 QuicFrames frames;
4974 frames.push_back(QuicFrame(&stream_frame)); 4976 frames.push_back(QuicFrame(&stream_frame));
4975 4977
4976 // clang-format off 4978 // clang-format off
4977 unsigned char packet[] = { 4979 unsigned char packet[] = {
4978 // public flags (8 byte connection_id) 4980 // public flags (8 byte connection_id)
4979 static_cast<unsigned char>( 4981 static_cast<unsigned char>(
4980 framer_.version() > QUIC_VERSION_32 ? 0x7D : 0x7D), 4982 (FLAGS_quic_remove_v33_hacks &&
4983 framer_.version() > QUIC_VERSION_32) ? 0x79 : 0x7D),
4981 // connection_id 4984 // connection_id
4982 0x10, 0x32, 0x54, 0x76, 4985 0x10, 0x32, 0x54, 0x76,
4983 0x98, 0xBA, 0xDC, 0xFE, 4986 0x98, 0xBA, 0xDC, 0xFE,
4984 // version tag 4987 // version tag
4985 'Q', '0', GetQuicVersionDigitTens(), GetQuicVersionDigitOnes(), 4988 'Q', '0', GetQuicVersionDigitTens(), GetQuicVersionDigitOnes(),
4986 // path_id 4989 // path_id
4987 0x42, 4990 0x42,
4988 // packet number 4991 // packet number
4989 0xBC, 0x9A, 0x78, 0x56, 4992 0xBC, 0x9A, 0x78, 0x56,
4990 0x34, 0x12, 4993 0x34, 0x12,
4991 // private flags (entropy) 4994 // private flags (entropy)
4992 0x01, 4995 0x01,
4993 4996
4994 // frame type (stream frame with fin and no length) 4997 // frame type (stream frame with fin and no length)
4995 0xDF, 4998 0xDF,
4996 // stream id 4999 // stream id
4997 0x04, 0x03, 0x02, 0x01, 5000 0x04, 0x03, 0x02, 0x01,
4998 // offset 5001 // offset
4999 0x54, 0x76, 0x10, 0x32, 5002 0x54, 0x76, 0x10, 0x32,
5000 0xDC, 0xFE, 0x98, 0xBA, 5003 0xDC, 0xFE, 0x98, 0xBA,
5001 // data 5004 // data
5002 'h', 'e', 'l', 'l', 5005 'h', 'e', 'l', 'l',
5003 'o', ' ', 'w', 'o', 5006 'o', ' ', 'w', 'o',
5004 'r', 'l', 'd', '!', 5007 'r', 'l', 'd', '!',
5005 }; 5008 };
5006 unsigned char packet_34[] = { 5009 unsigned char packet_34[] = {
5007 // public flags (8 byte connection_id) 5010 // public flags (8 byte connection_id)
5008 0x7D, 5011 static_cast<unsigned char>(
5012 FLAGS_quic_remove_v33_hacks ? 0x79 : 0x7D),
5009 // connection_id 5013 // connection_id
5010 0x10, 0x32, 0x54, 0x76, 5014 0x10, 0x32, 0x54, 0x76,
5011 0x98, 0xBA, 0xDC, 0xFE, 5015 0x98, 0xBA, 0xDC, 0xFE,
5012 // version tag 5016 // version tag
5013 'Q', '0', GetQuicVersionDigitTens(), GetQuicVersionDigitOnes(), 5017 'Q', '0', GetQuicVersionDigitTens(), GetQuicVersionDigitOnes(),
5014 // path_id 5018 // path_id
5015 0x42, 5019 0x42,
5016 // packet number 5020 // packet number
5017 0xBC, 0x9A, 0x78, 0x56, 5021 0xBC, 0x9A, 0x78, 0x56,
5018 0x34, 0x12, 5022 0x34, 0x12,
(...skipping 2109 matching lines...) Expand 10 before | Expand all | Expand 10 after
7128 } 7132 }
7129 7133
7130 // Tests for fuzzing with Dr. Fuzz 7134 // Tests for fuzzing with Dr. Fuzz
7131 // Xref http://www.chromium.org/developers/testing/dr-fuzz for more details. 7135 // Xref http://www.chromium.org/developers/testing/dr-fuzz for more details.
7132 #ifdef __cplusplus 7136 #ifdef __cplusplus
7133 extern "C" { 7137 extern "C" {
7134 #endif 7138 #endif
7135 7139
7136 // target function to be fuzzed by Dr. Fuzz 7140 // target function to be fuzzed by Dr. Fuzz
7137 void QuicFramerFuzzFunc(unsigned char* data, size_t size) { 7141 void QuicFramerFuzzFunc(unsigned char* data, size_t size) {
7138 QuicFramer framer(QuicSupportedVersions(), QuicTime::Zero(), 7142 QuicFramer framer(AllSupportedVersions(), QuicTime::Zero(),
7139 Perspective::IS_SERVER); 7143 Perspective::IS_SERVER);
7140 const char* const packet_bytes = reinterpret_cast<const char*>(data); 7144 const char* const packet_bytes = reinterpret_cast<const char*>(data);
7141 7145
7142 // Test the CryptoFramer. 7146 // Test the CryptoFramer.
7143 StringPiece crypto_input(packet_bytes, size); 7147 StringPiece crypto_input(packet_bytes, size);
7144 std::unique_ptr<CryptoHandshakeMessage> handshake_message( 7148 std::unique_ptr<CryptoHandshakeMessage> handshake_message(
7145 CryptoFramer::ParseMessage(crypto_input)); 7149 CryptoFramer::ParseMessage(crypto_input));
7146 7150
7147 // Test the regular QuicFramer with the same input. 7151 // Test the regular QuicFramer with the same input.
7148 NoOpFramerVisitor visitor; 7152 NoOpFramerVisitor visitor;
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
7183 'o', ' ', 'w', 'o', 7187 'o', ' ', 'w', 'o',
7184 'r', 'l', 'd', '!', 7188 'r', 'l', 'd', '!',
7185 }; 7189 };
7186 // clang-format on 7190 // clang-format on
7187 7191
7188 QuicFramerFuzzFunc(packet, arraysize(packet)); 7192 QuicFramerFuzzFunc(packet, arraysize(packet));
7189 } 7193 }
7190 7194
7191 } // namespace test 7195 } // namespace test
7192 } // namespace net 7196 } // namespace net
OLDNEW
« no previous file with comments | « net/quic/core/quic_framer.cc ('k') | net/quic/core/quic_headers_stream_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698