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

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

Issue 2519333006: Add CHECK's to debug QuicStreamSequencerBuffer in weird state. Add a destruction indicator to detec… (Closed)
Patch Set: using CHECK_GT Created 4 years 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
OLDNEW
1 // Copyright (c) 2015 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2015 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 #include "net/quic/core/quic_stream_sequencer_buffer.h" 4 #include "net/quic/core/quic_stream_sequencer_buffer.h"
5 5
6 #include <algorithm> 6 #include <algorithm>
7 #include <limits> 7 #include <limits>
8 #include <map> 8 #include <map>
9 #include <string> 9 #include <string>
10 #include <utility> 10 #include <utility>
(...skipping 314 matching lines...) Expand 10 before | Expand all | Expand 10 after
325 LOG(ERROR) << error_details_; 325 LOG(ERROR) << error_details_;
326 EXPECT_EQ(100u, read); 326 EXPECT_EQ(100u, read);
327 EXPECT_EQ(100u, buffer_->BytesConsumed()); 327 EXPECT_EQ(100u, buffer_->BytesConsumed());
328 EXPECT_EQ(source, string(dest, read)); 328 EXPECT_EQ(source, string(dest, read));
329 EXPECT_EQ(1u, helper_->frame_arrival_time_map()->size()); 329 EXPECT_EQ(1u, helper_->frame_arrival_time_map()->size());
330 // The first block should be released as its data has been read out. 330 // The first block should be released as its data has been read out.
331 EXPECT_EQ(nullptr, helper_->GetBlock(0)); 331 EXPECT_EQ(nullptr, helper_->GetBlock(0));
332 EXPECT_TRUE(helper_->CheckBufferInvariants()); 332 EXPECT_TRUE(helper_->CheckBufferInvariants());
333 } 333 }
334 334
335 TEST_F(QuicStreamSequencerBufferTest, ReadvError) {
336 string source = string(100, 'b');
337 clock_.AdvanceTime(QuicTime::Delta::FromSeconds(1));
338 QuicTime t1 = clock_.ApproximateNow();
339 // Write something into [0, 100).
340 size_t written;
341 buffer_->OnStreamData(0, source, t1, &written, &error_details_);
342 EXPECT_TRUE(helper_->GetBlock(0) != nullptr);
343 EXPECT_TRUE(buffer_->HasBytesToRead());
344 // Read into a iovec array with total capacity of 120 bytes.
345 iovec iov{nullptr, 120};
346 size_t read;
347 EXPECT_EQ(QUIC_STREAM_SEQUENCER_INVALID_STATE,
348 buffer_->Readv(&iov, 1, &read, &error_details_));
349 EXPECT_EQ(0u,
350 error_details_.find(
351 "QuicStreamSequencerBuffer error: Readv() dest == nullptr: true"
352 " blocks_[0] == nullptr: false"));
353 }
354
355 TEST_F(QuicStreamSequencerBufferTest, ReadvAcrossBlocks) { 335 TEST_F(QuicStreamSequencerBufferTest, ReadvAcrossBlocks) {
356 string source(kBlockSizeBytes + 50, 'a'); 336 string source(kBlockSizeBytes + 50, 'a');
357 // Write 1st block to full and extand 50 bytes to next block. 337 // Write 1st block to full and extand 50 bytes to next block.
358 size_t written; 338 size_t written;
359 buffer_->OnStreamData(0, source, clock_.ApproximateNow(), &written, 339 buffer_->OnStreamData(0, source, clock_.ApproximateNow(), &written,
360 &error_details_); 340 &error_details_);
361 EXPECT_EQ(source.size(), helper_->ReadableBytes()); 341 EXPECT_EQ(source.size(), helper_->ReadableBytes());
362 // Iteratively read 512 bytes from buffer_-> Overwrite dest[] each time. 342 // Iteratively read 512 bytes from buffer_-> Overwrite dest[] each time.
363 char dest[512]; 343 char dest[512];
364 while (helper_->ReadableBytes()) { 344 while (helper_->ReadableBytes()) {
(...skipping 683 matching lines...) Expand 10 before | Expand all | Expand 10 after
1048 EXPECT_LE(bytes_to_buffer_, total_bytes_read_) << "iterations: " 1028 EXPECT_LE(bytes_to_buffer_, total_bytes_read_) << "iterations: "
1049 << iterations; 1029 << iterations;
1050 EXPECT_LE(bytes_to_buffer_, total_bytes_written_); 1030 EXPECT_LE(bytes_to_buffer_, total_bytes_written_);
1051 } 1031 }
1052 1032
1053 } // anonymous namespace 1033 } // anonymous namespace
1054 1034
1055 } // namespace test 1035 } // namespace test
1056 1036
1057 } // namespace net 1037 } // namespace net
OLDNEW
« no previous file with comments | « net/quic/core/quic_stream_sequencer_buffer.cc ('k') | net/quic/core/quic_stream_sequencer_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698