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

Side by Side Diff: net/disk_cache/entry_unittest.cc

Issue 485753002: A small stress test that SimpleCache can't seem to handle. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase Created 6 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 | « no previous file | no next file » | 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 "base/basictypes.h" 5 #include "base/basictypes.h"
6 #include "base/bind.h" 6 #include "base/bind.h"
7 #include "base/bind_helpers.h" 7 #include "base/bind_helpers.h"
8 #include "base/file_util.h" 8 #include "base/file_util.h"
9 #include "base/files/file.h" 9 #include "base/files/file.h"
10 #include "base/strings/string_util.h" 10 #include "base/strings/string_util.h"
(...skipping 2324 matching lines...) Expand 10 before | Expand all | Expand 10 after
2335 // atomic renaming of recently open files. Those guarantees are not provided in 2335 // atomic renaming of recently open files. Those guarantees are not provided in
2336 // general on Windows. 2336 // general on Windows.
2337 #if defined(OS_POSIX) 2337 #if defined(OS_POSIX)
2338 2338
2339 TEST_F(DiskCacheEntryTest, SimpleCacheInternalAsyncIO) { 2339 TEST_F(DiskCacheEntryTest, SimpleCacheInternalAsyncIO) {
2340 SetSimpleCacheMode(); 2340 SetSimpleCacheMode();
2341 InitCache(); 2341 InitCache();
2342 InternalAsyncIO(); 2342 InternalAsyncIO();
2343 } 2343 }
2344 2344
2345 TEST_F(DiskCacheEntryTest, SimpleCacheStress) {
2346 SetSimpleCacheMode();
2347 InitCache();
2348
2349 disk_cache::Entry* entry = NULL;
2350
2351 std::string stream0 = "0";
2352 std::string stream1 = "1";
2353 scoped_refptr<net::StringIOBuffer> buff0(new net::StringIOBuffer(stream0));
2354 scoped_refptr<net::StringIOBuffer> buff1(new net::StringIOBuffer(stream1));
2355
2356 for (int i = 0; i < 100; ++i) {
2357 ASSERT_EQ(net::OK, CreateEntry("foo", &entry));
2358 EXPECT_EQ(buff0->size(),
2359 WriteData(entry, 0, 0, buff0.get(), buff0->size(), false));
2360 EXPECT_EQ(buff1->size(),
2361 WriteData(entry, 1, 0, buff1.get(), buff1->size(), false));
2362 entry->Close();
2363 entry = NULL;
2364
2365 ASSERT_EQ(net::OK, OpenEntry("foo", &entry));
2366 entry->Doom();
2367 entry->Close();
2368 entry = NULL;
2369 }
2370 }
2371
2345 TEST_F(DiskCacheEntryTest, SimpleCacheExternalAsyncIO) { 2372 TEST_F(DiskCacheEntryTest, SimpleCacheExternalAsyncIO) {
2346 SetSimpleCacheMode(); 2373 SetSimpleCacheMode();
2347 InitCache(); 2374 InitCache();
2348 ExternalAsyncIO(); 2375 ExternalAsyncIO();
2349 } 2376 }
2350 2377
2351 TEST_F(DiskCacheEntryTest, SimpleCacheReleaseBuffer) { 2378 TEST_F(DiskCacheEntryTest, SimpleCacheReleaseBuffer) {
2352 SetSimpleCacheMode(); 2379 SetSimpleCacheMode();
2353 InitCache(); 2380 InitCache();
2354 for (int i = 0; i < disk_cache::kSimpleEntryStreamCount; ++i) { 2381 for (int i = 0; i < disk_cache::kSimpleEntryStreamCount; ++i) {
(...skipping 1607 matching lines...) Expand 10 before | Expand all | Expand 10 after
3962 EXPECT_EQ(kSize, callback.GetResult(ret)); 3989 EXPECT_EQ(kSize, callback.GetResult(ret));
3963 3990
3964 // Make sure the first range was removed when the second was written. 3991 // Make sure the first range was removed when the second was written.
3965 ret = entry->ReadSparseData(0, buffer, kSize, callback.callback()); 3992 ret = entry->ReadSparseData(0, buffer, kSize, callback.callback());
3966 EXPECT_EQ(0, callback.GetResult(ret)); 3993 EXPECT_EQ(0, callback.GetResult(ret));
3967 3994
3968 entry->Close(); 3995 entry->Close();
3969 } 3996 }
3970 3997
3971 #endif // defined(OS_POSIX) 3998 #endif // defined(OS_POSIX)
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698