Commit 642f858b authored by Xing Liu's avatar Xing Liu Committed by Commit Bot

Write to file with small buffers in ParallelDownloadTest.

Currently we do a disk IO and network IO with large chunk of memory
in ParallelDownloadTest, which cause stack underflow issues on certain
platform.

This CL fixed the disk IO by writing to file with 64KB buffer. The tests
will be enabled after the network IO part is fixed.

Bug: 817801
Change-Id: I49431cf0b66dc76ed893217126f189bb44f2e839
Reviewed-on: https://chromium-review.googlesource.com/952763Reviewed-by: default avatarDavid Trainor <dtrainor@chromium.org>
Commit-Queue: Xing Liu <xingliu@chromium.org>
Cr-Commit-Position: refs/heads/master@{#541701}
parent 90346c96
...@@ -927,18 +927,23 @@ class ParallelDownloadTest : public DownloadContentTest { ...@@ -927,18 +927,23 @@ class ParallelDownloadTest : public DownloadContentTest {
TestDownloadHttpResponse::Parameters& parameters) { TestDownloadHttpResponse::Parameters& parameters) {
std::string output; std::string output;
int64_t total_bytes = 0u; int64_t total_bytes = 0u;
const int64_t kBufferSize = 64 * 1024;
{ {
base::ScopedAllowBlockingForTesting allow_io_for_test_setup; base::ScopedAllowBlockingForTesting allow_io_for_test_setup;
base::File file(path, base::File::FLAG_CREATE | base::File::FLAG_WRITE); base::File file(path, base::File::FLAG_CREATE | base::File::FLAG_WRITE);
for (const auto& slice : slices) { for (const auto& slice : slices) {
total_bytes += slice.received_bytes;
EXPECT_TRUE(file.IsValid()); EXPECT_TRUE(file.IsValid());
output = TestDownloadHttpResponse::GetPatternBytes( int64_t length = slice.offset + slice.received_bytes;
parameters.pattern_generator_seed, slice.offset, for (int64_t offset = slice.offset; offset < length;) {
slice.received_bytes); int64_t bytes_to_write =
EXPECT_EQ(slice.received_bytes, file.Write(slice.offset, output.data(), length - offset > kBufferSize ? kBufferSize : length - offset;
slice.received_bytes)); output = TestDownloadHttpResponse::GetPatternBytes(
parameters.pattern_generator_seed, offset, bytes_to_write);
EXPECT_EQ(bytes_to_write,
file.Write(offset, output.data(), bytes_to_write));
total_bytes += bytes_to_write;
offset += bytes_to_write;
}
} }
file.Close(); file.Close();
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment