summaryrefslogtreecommitdiff
path: root/chromium/net/disk_cache/backend_unittest.cc
diff options
context:
space:
mode:
authorAllan Sandfeld Jensen <allan.jensen@qt.io>2020-10-12 14:27:29 +0200
committerAllan Sandfeld Jensen <allan.jensen@qt.io>2020-10-13 09:35:20 +0000
commitc30a6232df03e1efbd9f3b226777b07e087a1122 (patch)
treee992f45784689f373bcc38d1b79a239ebe17ee23 /chromium/net/disk_cache/backend_unittest.cc
parent7b5b123ac58f58ffde0f4f6e488bcd09aa4decd3 (diff)
downloadqtwebengine-chromium-85-based.tar.gz
BASELINE: Update Chromium to 85.0.4183.14085-based
Change-Id: Iaa42f4680837c57725b1344f108c0196741f6057 Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
Diffstat (limited to 'chromium/net/disk_cache/backend_unittest.cc')
-rw-r--r--chromium/net/disk_cache/backend_unittest.cc35
1 files changed, 35 insertions, 0 deletions
diff --git a/chromium/net/disk_cache/backend_unittest.cc b/chromium/net/disk_cache/backend_unittest.cc
index 8f88d07a799..e64900765eb 100644
--- a/chromium/net/disk_cache/backend_unittest.cc
+++ b/chromium/net/disk_cache/backend_unittest.cc
@@ -5279,3 +5279,38 @@ TEST_F(DiskCacheBackendTest, SimpleDontLeakPostDoomCreate) {
// Should not have leaked files here.
}
+
+TEST_F(DiskCacheBackendTest, BlockFileDelayedWriteFailureRecovery) {
+ // Test that blockfile recovers appropriately when some entries are
+ // in a screwed up state due to an error in delayed writeback.
+ //
+ // https://crbug.com/1086727
+ InitCache();
+
+ const char kKey[] = "Key2";
+ disk_cache::Entry* entry = nullptr;
+ ASSERT_THAT(CreateEntry(kKey, &entry), IsOk());
+
+ const int kBufSize = 24320;
+ scoped_refptr<net::IOBuffer> buffer =
+ base::MakeRefCounted<net::IOBuffer>(kBufSize);
+ CacheTestFillBuffer(buffer->data(), kBufSize, true);
+
+ ASSERT_EQ(kBufSize, WriteSparseData(entry, 0, buffer.get(), kBufSize));
+
+ // Setting the size limit artificially low injects a failure on writing back
+ // data buffered above.
+ SetMaxSize(4096);
+
+ // This causes SparseControl to close the child entry corresponding to
+ // low portion of offset space, triggering the writeback --- which fails
+ // due to the space cap, and in particular fails to allocate data for
+ // a stream, so it gets address 0.
+ ASSERT_EQ(net::ERR_FAILED, WriteSparseData(entry, 16773118, buffer.get(), 4));
+
+ // Now try reading the broken child. This should report an error, not
+ // DCHECK.
+ ASSERT_EQ(net::ERR_FAILED, ReadSparseData(entry, 4, buffer.get(), 4));
+
+ entry->Close();
+}