OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 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 | 4 |
5 #include "base/metrics/persistent_memory_allocator.h" | 5 #include "base/metrics/persistent_memory_allocator.h" |
6 | 6 |
| 7 #include <memory> |
| 8 |
7 #include "base/files/file.h" | 9 #include "base/files/file.h" |
8 #include "base/files/file_util.h" | 10 #include "base/files/file_util.h" |
9 #include "base/files/memory_mapped_file.h" | 11 #include "base/files/memory_mapped_file.h" |
10 #include "base/files/scoped_temp_dir.h" | 12 #include "base/files/scoped_temp_dir.h" |
11 #include "base/memory/scoped_ptr.h" | |
12 #include "base/memory/shared_memory.h" | 13 #include "base/memory/shared_memory.h" |
13 #include "base/metrics/histogram.h" | 14 #include "base/metrics/histogram.h" |
14 #include "base/rand_util.h" | 15 #include "base/rand_util.h" |
15 #include "base/strings/safe_sprintf.h" | 16 #include "base/strings/safe_sprintf.h" |
16 #include "base/threading/simple_thread.h" | 17 #include "base/threading/simple_thread.h" |
17 #include "testing/gmock/include/gmock/gmock.h" | 18 #include "testing/gmock/include/gmock/gmock.h" |
18 | 19 |
19 namespace { | 20 namespace { |
20 | 21 |
21 const uint32_t TEST_MEMORY_SIZE = 1 << 20; // 1 MiB | 22 const uint32_t TEST_MEMORY_SIZE = 1 << 20; // 1 MiB |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
72 uint32_t type; | 73 uint32_t type; |
73 unsigned count = 0; | 74 unsigned count = 0; |
74 for (allocator_->CreateIterator(&iter); | 75 for (allocator_->CreateIterator(&iter); |
75 allocator_->GetNextIterable(&iter, &type) != 0;) { | 76 allocator_->GetNextIterable(&iter, &type) != 0;) { |
76 count++; | 77 count++; |
77 } | 78 } |
78 return count; | 79 return count; |
79 } | 80 } |
80 | 81 |
81 protected: | 82 protected: |
82 scoped_ptr<char[]> mem_segment_; | 83 std::unique_ptr<char[]> mem_segment_; |
83 scoped_ptr<PersistentMemoryAllocator> allocator_; | 84 std::unique_ptr<PersistentMemoryAllocator> allocator_; |
84 }; | 85 }; |
85 | 86 |
86 TEST_F(PersistentMemoryAllocatorTest, AllocateAndIterate) { | 87 TEST_F(PersistentMemoryAllocatorTest, AllocateAndIterate) { |
87 std::string base_name(TEST_NAME); | 88 std::string base_name(TEST_NAME); |
88 EXPECT_EQ(TEST_ID, allocator_->Id()); | 89 EXPECT_EQ(TEST_ID, allocator_->Id()); |
89 EXPECT_TRUE(allocator_->used_histogram_); | 90 EXPECT_TRUE(allocator_->used_histogram_); |
90 EXPECT_EQ("UMA.PersistentAllocator." + base_name + ".UsedPct", | 91 EXPECT_EQ("UMA.PersistentAllocator." + base_name + ".UsedPct", |
91 allocator_->used_histogram_->histogram_name()); | 92 allocator_->used_histogram_->histogram_name()); |
92 EXPECT_TRUE(allocator_->allocs_histogram_); | 93 EXPECT_TRUE(allocator_->allocs_histogram_); |
93 EXPECT_EQ("UMA.PersistentAllocator." + base_name + ".Allocs", | 94 EXPECT_EQ("UMA.PersistentAllocator." + base_name + ".Allocs", |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
147 allocator_->CreateIterator(&iter, block1); | 148 allocator_->CreateIterator(&iter, block1); |
148 EXPECT_EQ(block2, allocator_->GetNextIterable(&iter, &type)); | 149 EXPECT_EQ(block2, allocator_->GetNextIterable(&iter, &type)); |
149 EXPECT_EQ(0U, allocator_->GetNextIterable(&iter, &type)); | 150 EXPECT_EQ(0U, allocator_->GetNextIterable(&iter, &type)); |
150 | 151 |
151 // Ensure nothing has gone noticably wrong. | 152 // Ensure nothing has gone noticably wrong. |
152 EXPECT_FALSE(allocator_->IsFull()); | 153 EXPECT_FALSE(allocator_->IsFull()); |
153 EXPECT_FALSE(allocator_->IsCorrupt()); | 154 EXPECT_FALSE(allocator_->IsCorrupt()); |
154 | 155 |
155 // Check the internal histogram record of used memory. | 156 // Check the internal histogram record of used memory. |
156 allocator_->UpdateTrackingHistograms(); | 157 allocator_->UpdateTrackingHistograms(); |
157 scoped_ptr<HistogramSamples> used_samples( | 158 std::unique_ptr<HistogramSamples> used_samples( |
158 allocator_->used_histogram_->SnapshotSamples()); | 159 allocator_->used_histogram_->SnapshotSamples()); |
159 EXPECT_TRUE(used_samples); | 160 EXPECT_TRUE(used_samples); |
160 EXPECT_EQ(1, used_samples->TotalCount()); | 161 EXPECT_EQ(1, used_samples->TotalCount()); |
161 | 162 |
162 // Check the internal histogram record of allocation requests. | 163 // Check the internal histogram record of allocation requests. |
163 scoped_ptr<HistogramSamples> allocs_samples( | 164 std::unique_ptr<HistogramSamples> allocs_samples( |
164 allocator_->allocs_histogram_->SnapshotSamples()); | 165 allocator_->allocs_histogram_->SnapshotSamples()); |
165 EXPECT_TRUE(allocs_samples); | 166 EXPECT_TRUE(allocs_samples); |
166 EXPECT_EQ(2, allocs_samples->TotalCount()); | 167 EXPECT_EQ(2, allocs_samples->TotalCount()); |
167 EXPECT_EQ(0, allocs_samples->GetCount(0)); | 168 EXPECT_EQ(0, allocs_samples->GetCount(0)); |
168 EXPECT_EQ(1, allocs_samples->GetCount(sizeof(TestObject1))); | 169 EXPECT_EQ(1, allocs_samples->GetCount(sizeof(TestObject1))); |
169 EXPECT_EQ(1, allocs_samples->GetCount(sizeof(TestObject2))); | 170 EXPECT_EQ(1, allocs_samples->GetCount(sizeof(TestObject2))); |
170 #if !DCHECK_IS_ON() // DCHECK builds will die at a NOTREACHED(). | 171 #if !DCHECK_IS_ON() // DCHECK builds will die at a NOTREACHED(). |
171 EXPECT_EQ(0U, allocator_->Allocate(TEST_MEMORY_SIZE + 1, 0)); | 172 EXPECT_EQ(0U, allocator_->Allocate(TEST_MEMORY_SIZE + 1, 0)); |
172 allocs_samples = allocator_->allocs_histogram_->SnapshotSamples(); | 173 allocs_samples = allocator_->allocs_histogram_->SnapshotSamples(); |
173 EXPECT_EQ(3, allocs_samples->TotalCount()); | 174 EXPECT_EQ(3, allocs_samples->TotalCount()); |
174 EXPECT_EQ(1, allocs_samples->GetCount(0)); | 175 EXPECT_EQ(1, allocs_samples->GetCount(0)); |
175 #endif | 176 #endif |
176 | 177 |
177 // Check that an objcet's type can be changed. | 178 // Check that an objcet's type can be changed. |
178 EXPECT_EQ(2U, allocator_->GetType(block2)); | 179 EXPECT_EQ(2U, allocator_->GetType(block2)); |
179 allocator_->SetType(block2, 3); | 180 allocator_->SetType(block2, 3); |
180 EXPECT_EQ(3U, allocator_->GetType(block2)); | 181 EXPECT_EQ(3U, allocator_->GetType(block2)); |
181 allocator_->SetType(block2, 2); | 182 allocator_->SetType(block2, 2); |
182 EXPECT_EQ(2U, allocator_->GetType(block2)); | 183 EXPECT_EQ(2U, allocator_->GetType(block2)); |
183 | 184 |
184 // Create second allocator (read/write) using the same memory segment. | 185 // Create second allocator (read/write) using the same memory segment. |
185 scoped_ptr<PersistentMemoryAllocator> allocator2( | 186 std::unique_ptr<PersistentMemoryAllocator> allocator2( |
186 new PersistentMemoryAllocator( | 187 new PersistentMemoryAllocator(mem_segment_.get(), TEST_MEMORY_SIZE, |
187 mem_segment_.get(), TEST_MEMORY_SIZE, TEST_MEMORY_PAGE, 0, "", | 188 TEST_MEMORY_PAGE, 0, "", false)); |
188 false)); | |
189 EXPECT_EQ(TEST_ID, allocator2->Id()); | 189 EXPECT_EQ(TEST_ID, allocator2->Id()); |
190 EXPECT_FALSE(allocator2->used_histogram_); | 190 EXPECT_FALSE(allocator2->used_histogram_); |
191 EXPECT_FALSE(allocator2->allocs_histogram_); | 191 EXPECT_FALSE(allocator2->allocs_histogram_); |
192 EXPECT_NE(allocator2->allocs_histogram_, allocator_->allocs_histogram_); | 192 EXPECT_NE(allocator2->allocs_histogram_, allocator_->allocs_histogram_); |
193 | 193 |
194 // Ensure that iteration and access through second allocator works. | 194 // Ensure that iteration and access through second allocator works. |
195 allocator2->CreateIterator(&iter); | 195 allocator2->CreateIterator(&iter); |
196 EXPECT_EQ(block1, allocator2->GetNextIterable(&iter, &type)); | 196 EXPECT_EQ(block1, allocator2->GetNextIterable(&iter, &type)); |
197 EXPECT_EQ(block2, allocator2->GetNextIterable(&iter, &type)); | 197 EXPECT_EQ(block2, allocator2->GetNextIterable(&iter, &type)); |
198 EXPECT_EQ(0U, allocator2->GetNextIterable(&iter, &type)); | 198 EXPECT_EQ(0U, allocator2->GetNextIterable(&iter, &type)); |
199 EXPECT_NE(nullptr, allocator2->GetAsObject<TestObject1>(block1, 1)); | 199 EXPECT_NE(nullptr, allocator2->GetAsObject<TestObject1>(block1, 1)); |
200 EXPECT_NE(nullptr, allocator2->GetAsObject<TestObject2>(block2, 2)); | 200 EXPECT_NE(nullptr, allocator2->GetAsObject<TestObject2>(block2, 2)); |
201 | 201 |
202 // Create a third allocator (read-only) using the same memory segment. | 202 // Create a third allocator (read-only) using the same memory segment. |
203 scoped_ptr<const PersistentMemoryAllocator> allocator3( | 203 std::unique_ptr<const PersistentMemoryAllocator> allocator3( |
204 new PersistentMemoryAllocator( | 204 new PersistentMemoryAllocator(mem_segment_.get(), TEST_MEMORY_SIZE, |
205 mem_segment_.get(), TEST_MEMORY_SIZE, TEST_MEMORY_PAGE, 0, "", true)); | 205 TEST_MEMORY_PAGE, 0, "", true)); |
206 EXPECT_EQ(TEST_ID, allocator3->Id()); | 206 EXPECT_EQ(TEST_ID, allocator3->Id()); |
207 EXPECT_FALSE(allocator3->used_histogram_); | 207 EXPECT_FALSE(allocator3->used_histogram_); |
208 EXPECT_FALSE(allocator3->allocs_histogram_); | 208 EXPECT_FALSE(allocator3->allocs_histogram_); |
209 | 209 |
210 // Ensure that iteration and access through third allocator works. | 210 // Ensure that iteration and access through third allocator works. |
211 allocator3->CreateIterator(&iter); | 211 allocator3->CreateIterator(&iter); |
212 EXPECT_EQ(block1, allocator3->GetNextIterable(&iter, &type)); | 212 EXPECT_EQ(block1, allocator3->GetNextIterable(&iter, &type)); |
213 EXPECT_EQ(block2, allocator3->GetNextIterable(&iter, &type)); | 213 EXPECT_EQ(block2, allocator3->GetNextIterable(&iter, &type)); |
214 EXPECT_EQ(0U, allocator3->GetNextIterable(&iter, &type)); | 214 EXPECT_EQ(0U, allocator3->GetNextIterable(&iter, &type)); |
215 EXPECT_NE(nullptr, allocator3->GetAsObject<TestObject1>(block1, 1)); | 215 EXPECT_NE(nullptr, allocator3->GetAsObject<TestObject1>(block1, 1)); |
(...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
389 | 389 |
390 | 390 |
391 //----- SharedPersistentMemoryAllocator ---------------------------------------- | 391 //----- SharedPersistentMemoryAllocator ---------------------------------------- |
392 | 392 |
393 TEST(SharedPersistentMemoryAllocatorTest, CreationTest) { | 393 TEST(SharedPersistentMemoryAllocatorTest, CreationTest) { |
394 SharedMemoryHandle shared_handle; | 394 SharedMemoryHandle shared_handle; |
395 | 395 |
396 PersistentMemoryAllocator::MemoryInfo meminfo1; | 396 PersistentMemoryAllocator::MemoryInfo meminfo1; |
397 Reference r123, r456, r789; | 397 Reference r123, r456, r789; |
398 { | 398 { |
399 scoped_ptr<SharedMemory> shmem1(new SharedMemory()); | 399 std::unique_ptr<SharedMemory> shmem1(new SharedMemory()); |
400 ASSERT_TRUE(shmem1->CreateAndMapAnonymous(TEST_MEMORY_SIZE)); | 400 ASSERT_TRUE(shmem1->CreateAndMapAnonymous(TEST_MEMORY_SIZE)); |
401 SharedPersistentMemoryAllocator local(std::move(shmem1), TEST_ID, "", | 401 SharedPersistentMemoryAllocator local(std::move(shmem1), TEST_ID, "", |
402 false); | 402 false); |
403 EXPECT_FALSE(local.IsReadonly()); | 403 EXPECT_FALSE(local.IsReadonly()); |
404 r123 = local.Allocate(123, 123); | 404 r123 = local.Allocate(123, 123); |
405 r456 = local.Allocate(456, 456); | 405 r456 = local.Allocate(456, 456); |
406 r789 = local.Allocate(789, 789); | 406 r789 = local.Allocate(789, 789); |
407 local.MakeIterable(r123); | 407 local.MakeIterable(r123); |
408 local.SetType(r456, 654); | 408 local.SetType(r456, 654); |
409 local.MakeIterable(r789); | 409 local.MakeIterable(r789); |
410 local.GetMemoryInfo(&meminfo1); | 410 local.GetMemoryInfo(&meminfo1); |
411 EXPECT_FALSE(local.IsFull()); | 411 EXPECT_FALSE(local.IsFull()); |
412 EXPECT_FALSE(local.IsCorrupt()); | 412 EXPECT_FALSE(local.IsCorrupt()); |
413 | 413 |
414 ASSERT_TRUE(local.shared_memory()->ShareToProcess( | 414 ASSERT_TRUE(local.shared_memory()->ShareToProcess( |
415 GetCurrentProcessHandle(), | 415 GetCurrentProcessHandle(), |
416 &shared_handle)); | 416 &shared_handle)); |
417 } | 417 } |
418 | 418 |
419 // Read-only test. | 419 // Read-only test. |
420 scoped_ptr<SharedMemory> shmem2(new SharedMemory(shared_handle, | 420 std::unique_ptr<SharedMemory> shmem2(new SharedMemory(shared_handle, |
421 /*readonly=*/true)); | 421 /*readonly=*/true)); |
422 ASSERT_TRUE(shmem2->Map(TEST_MEMORY_SIZE)); | 422 ASSERT_TRUE(shmem2->Map(TEST_MEMORY_SIZE)); |
423 | 423 |
424 SharedPersistentMemoryAllocator shalloc2(std::move(shmem2), 0, "", true); | 424 SharedPersistentMemoryAllocator shalloc2(std::move(shmem2), 0, "", true); |
425 EXPECT_TRUE(shalloc2.IsReadonly()); | 425 EXPECT_TRUE(shalloc2.IsReadonly()); |
426 EXPECT_EQ(TEST_ID, shalloc2.Id()); | 426 EXPECT_EQ(TEST_ID, shalloc2.Id()); |
427 EXPECT_FALSE(shalloc2.IsFull()); | 427 EXPECT_FALSE(shalloc2.IsFull()); |
428 EXPECT_FALSE(shalloc2.IsCorrupt()); | 428 EXPECT_FALSE(shalloc2.IsCorrupt()); |
429 | 429 |
430 PersistentMemoryAllocator::Iterator iter2; | 430 PersistentMemoryAllocator::Iterator iter2; |
431 uint32_t type; | 431 uint32_t type; |
432 shalloc2.CreateIterator(&iter2); | 432 shalloc2.CreateIterator(&iter2); |
433 EXPECT_EQ(r123, shalloc2.GetNextIterable(&iter2, &type)); | 433 EXPECT_EQ(r123, shalloc2.GetNextIterable(&iter2, &type)); |
434 EXPECT_EQ(r789, shalloc2.GetNextIterable(&iter2, &type)); | 434 EXPECT_EQ(r789, shalloc2.GetNextIterable(&iter2, &type)); |
435 EXPECT_EQ(0U, shalloc2.GetNextIterable(&iter2, &type)); | 435 EXPECT_EQ(0U, shalloc2.GetNextIterable(&iter2, &type)); |
436 | 436 |
437 EXPECT_EQ(123U, shalloc2.GetType(r123)); | 437 EXPECT_EQ(123U, shalloc2.GetType(r123)); |
438 EXPECT_EQ(654U, shalloc2.GetType(r456)); | 438 EXPECT_EQ(654U, shalloc2.GetType(r456)); |
439 EXPECT_EQ(789U, shalloc2.GetType(r789)); | 439 EXPECT_EQ(789U, shalloc2.GetType(r789)); |
440 | 440 |
441 PersistentMemoryAllocator::MemoryInfo meminfo2; | 441 PersistentMemoryAllocator::MemoryInfo meminfo2; |
442 shalloc2.GetMemoryInfo(&meminfo2); | 442 shalloc2.GetMemoryInfo(&meminfo2); |
443 EXPECT_EQ(meminfo1.total, meminfo2.total); | 443 EXPECT_EQ(meminfo1.total, meminfo2.total); |
444 EXPECT_EQ(meminfo1.free, meminfo2.free); | 444 EXPECT_EQ(meminfo1.free, meminfo2.free); |
445 | 445 |
446 // Read/write test. | 446 // Read/write test. |
447 scoped_ptr<SharedMemory> shmem3(new SharedMemory(shared_handle, | 447 std::unique_ptr<SharedMemory> shmem3(new SharedMemory(shared_handle, |
448 /*readonly=*/false)); | 448 /*readonly=*/false)); |
449 ASSERT_TRUE(shmem3->Map(TEST_MEMORY_SIZE)); | 449 ASSERT_TRUE(shmem3->Map(TEST_MEMORY_SIZE)); |
450 | 450 |
451 SharedPersistentMemoryAllocator shalloc3(std::move(shmem3), 0, "", false); | 451 SharedPersistentMemoryAllocator shalloc3(std::move(shmem3), 0, "", false); |
452 EXPECT_FALSE(shalloc3.IsReadonly()); | 452 EXPECT_FALSE(shalloc3.IsReadonly()); |
453 EXPECT_EQ(TEST_ID, shalloc3.Id()); | 453 EXPECT_EQ(TEST_ID, shalloc3.Id()); |
454 EXPECT_FALSE(shalloc3.IsFull()); | 454 EXPECT_FALSE(shalloc3.IsFull()); |
455 EXPECT_FALSE(shalloc3.IsCorrupt()); | 455 EXPECT_FALSE(shalloc3.IsCorrupt()); |
456 | 456 |
457 PersistentMemoryAllocator::Iterator iter3; | 457 PersistentMemoryAllocator::Iterator iter3; |
458 shalloc3.CreateIterator(&iter3); | 458 shalloc3.CreateIterator(&iter3); |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
498 local.MakeIterable(r789); | 498 local.MakeIterable(r789); |
499 local.GetMemoryInfo(&meminfo1); | 499 local.GetMemoryInfo(&meminfo1); |
500 EXPECT_FALSE(local.IsFull()); | 500 EXPECT_FALSE(local.IsFull()); |
501 EXPECT_FALSE(local.IsCorrupt()); | 501 EXPECT_FALSE(local.IsCorrupt()); |
502 | 502 |
503 File writer(file_path, File::FLAG_CREATE | File::FLAG_WRITE); | 503 File writer(file_path, File::FLAG_CREATE | File::FLAG_WRITE); |
504 ASSERT_TRUE(writer.IsValid()); | 504 ASSERT_TRUE(writer.IsValid()); |
505 writer.Write(0, (const char*)local.data(), local.used()); | 505 writer.Write(0, (const char*)local.data(), local.used()); |
506 } | 506 } |
507 | 507 |
508 scoped_ptr<MemoryMappedFile> mmfile(new MemoryMappedFile()); | 508 std::unique_ptr<MemoryMappedFile> mmfile(new MemoryMappedFile()); |
509 mmfile->Initialize(file_path); | 509 mmfile->Initialize(file_path); |
510 EXPECT_TRUE(mmfile->IsValid()); | 510 EXPECT_TRUE(mmfile->IsValid()); |
511 const size_t mmlength = mmfile->length(); | 511 const size_t mmlength = mmfile->length(); |
512 EXPECT_GE(meminfo1.total, mmlength); | 512 EXPECT_GE(meminfo1.total, mmlength); |
513 | 513 |
514 FilePersistentMemoryAllocator file(std::move(mmfile), 0, ""); | 514 FilePersistentMemoryAllocator file(std::move(mmfile), 0, ""); |
515 EXPECT_TRUE(file.IsReadonly()); | 515 EXPECT_TRUE(file.IsReadonly()); |
516 EXPECT_EQ(TEST_ID, file.Id()); | 516 EXPECT_EQ(TEST_ID, file.Id()); |
517 EXPECT_FALSE(file.IsFull()); | 517 EXPECT_FALSE(file.IsFull()); |
518 EXPECT_FALSE(file.IsCorrupt()); | 518 EXPECT_FALSE(file.IsCorrupt()); |
(...skipping 19 matching lines...) Expand all Loading... |
538 | 538 |
539 TEST(FilePersistentMemoryAllocatorTest, AcceptableTest) { | 539 TEST(FilePersistentMemoryAllocatorTest, AcceptableTest) { |
540 ScopedTempDir temp_dir; | 540 ScopedTempDir temp_dir; |
541 ASSERT_TRUE(temp_dir.CreateUniqueTempDir()); | 541 ASSERT_TRUE(temp_dir.CreateUniqueTempDir()); |
542 FilePath file_path_base = temp_dir.path().AppendASCII("persistent_memory_"); | 542 FilePath file_path_base = temp_dir.path().AppendASCII("persistent_memory_"); |
543 | 543 |
544 LocalPersistentMemoryAllocator local(TEST_MEMORY_SIZE, TEST_ID, ""); | 544 LocalPersistentMemoryAllocator local(TEST_MEMORY_SIZE, TEST_ID, ""); |
545 local.Allocate(1, 1); | 545 local.Allocate(1, 1); |
546 local.Allocate(11, 11); | 546 local.Allocate(11, 11); |
547 const size_t minsize = local.used(); | 547 const size_t minsize = local.used(); |
548 scoped_ptr<char[]> garbage(new char[minsize]); | 548 std::unique_ptr<char[]> garbage(new char[minsize]); |
549 RandBytes(garbage.get(), minsize); | 549 RandBytes(garbage.get(), minsize); |
550 | 550 |
551 scoped_ptr<MemoryMappedFile> mmfile; | 551 std::unique_ptr<MemoryMappedFile> mmfile; |
552 char filename[100]; | 552 char filename[100]; |
553 for (size_t filesize = minsize; filesize > 0; --filesize) { | 553 for (size_t filesize = minsize; filesize > 0; --filesize) { |
554 strings::SafeSPrintf(filename, "memory_%d_A", filesize); | 554 strings::SafeSPrintf(filename, "memory_%d_A", filesize); |
555 FilePath file_path = temp_dir.path().AppendASCII(filename); | 555 FilePath file_path = temp_dir.path().AppendASCII(filename); |
556 ASSERT_FALSE(PathExists(file_path)); | 556 ASSERT_FALSE(PathExists(file_path)); |
557 { | 557 { |
558 File writer(file_path, File::FLAG_CREATE | File::FLAG_WRITE); | 558 File writer(file_path, File::FLAG_CREATE | File::FLAG_WRITE); |
559 ASSERT_TRUE(writer.IsValid()); | 559 ASSERT_TRUE(writer.IsValid()); |
560 writer.Write(0, (const char*)local.data(), filesize); | 560 writer.Write(0, (const char*)local.data(), filesize); |
561 } | 561 } |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
611 } else { | 611 } else { |
612 // For filesize >= minsize, the file must be acceptable. This | 612 // For filesize >= minsize, the file must be acceptable. This |
613 // else clause (file-not-acceptable) should be reached only if | 613 // else clause (file-not-acceptable) should be reached only if |
614 // filesize < minsize. | 614 // filesize < minsize. |
615 EXPECT_GT(minsize, filesize); | 615 EXPECT_GT(minsize, filesize); |
616 } | 616 } |
617 } | 617 } |
618 } | 618 } |
619 | 619 |
620 } // namespace base | 620 } // namespace base |
OLD | NEW |