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

Side by Side Diff: base/debug/thread_heap_usage_tracker_unittest.cc

Issue 2902043007: allocator: rename use_experimental_allocator_shim to use_allocator_shim (Closed)
Patch Set: Created 3 years, 6 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 | « base/debug/thread_heap_usage_tracker.cc ('k') | base/process/memory_linux.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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/debug/thread_heap_usage_tracker.h" 5 #include "base/debug/thread_heap_usage_tracker.h"
6 6
7 #include <map> 7 #include <map>
8 8
9 #include "base/allocator/allocator_shim.h" 9 #include "base/allocator/allocator_shim.h"
10 #include "base/allocator/features.h" 10 #include "base/allocator/features.h"
(...skipping 535 matching lines...) Expand 10 before | Expand all | Expand 10 after
546 alloc = MockAllocAligned(1, kAllocSize); 546 alloc = MockAllocAligned(1, kAllocSize);
547 estimate = MockGetSizeEstimate(alloc); 547 estimate = MockGetSizeEstimate(alloc);
548 ASSERT_TRUE(estimate == 0 || estimate >= kAllocSize); 548 ASSERT_TRUE(estimate == 0 || estimate >= kAllocSize);
549 549
550 alloc = MockRealloc(alloc, kAllocSize); 550 alloc = MockRealloc(alloc, kAllocSize);
551 estimate = MockGetSizeEstimate(alloc); 551 estimate = MockGetSizeEstimate(alloc);
552 ASSERT_TRUE(estimate == 0 || estimate >= kAllocSize); 552 ASSERT_TRUE(estimate == 0 || estimate >= kAllocSize);
553 MockFree(alloc); 553 MockFree(alloc);
554 } 554 }
555 555
556 #if BUILDFLAG(USE_EXPERIMENTAL_ALLOCATOR_SHIM) 556 #if BUILDFLAG(USE_ALLOCATOR_SHIM)
557 class ThreadHeapUsageShimTest : public testing::Test { 557 class ThreadHeapUsageShimTest : public testing::Test {
558 #if defined(OS_MACOSX) 558 #if defined(OS_MACOSX)
559 void SetUp() override { allocator::InitializeAllocatorShim(); } 559 void SetUp() override { allocator::InitializeAllocatorShim(); }
560 void TearDown() override { allocator::UninterceptMallocZonesForTesting(); } 560 void TearDown() override { allocator::UninterceptMallocZonesForTesting(); }
561 #endif 561 #endif
562 }; 562 };
563 563
564 TEST_F(ThreadHeapUsageShimTest, HooksIntoMallocWhenShimAvailable) { 564 TEST_F(ThreadHeapUsageShimTest, HooksIntoMallocWhenShimAvailable) {
565 ASSERT_FALSE(ThreadHeapUsageTracker::IsHeapTrackingEnabled()); 565 ASSERT_FALSE(ThreadHeapUsageTracker::IsHeapTrackingEnabled());
566 566
(...skipping 27 matching lines...) Expand all
594 // Verify that at least the bytes above were recorded. 594 // Verify that at least the bytes above were recorded.
595 EXPECT_LE(u1.alloc_bytes + kAllocSize, u2.alloc_bytes); 595 EXPECT_LE(u1.alloc_bytes + kAllocSize, u2.alloc_bytes);
596 596
597 // Verify that at least the one free operation above was recorded. 597 // Verify that at least the one free operation above was recorded.
598 EXPECT_LE(u2.free_ops + 1, u3.free_ops); 598 EXPECT_LE(u2.free_ops + 1, u3.free_ops);
599 599
600 TestingThreadHeapUsageTracker::DisableHeapTrackingForTesting(); 600 TestingThreadHeapUsageTracker::DisableHeapTrackingForTesting();
601 601
602 ASSERT_FALSE(ThreadHeapUsageTracker::IsHeapTrackingEnabled()); 602 ASSERT_FALSE(ThreadHeapUsageTracker::IsHeapTrackingEnabled());
603 } 603 }
604 #endif // BUILDFLAG(USE_EXPERIMENTAL_ALLOCATOR_SHIM) 604 #endif // BUILDFLAG(USE_ALLOCATOR_SHIM)
605 605
606 } // namespace debug 606 } // namespace debug
607 } // namespace base 607 } // namespace base
OLDNEW
« no previous file with comments | « base/debug/thread_heap_usage_tracker.cc ('k') | base/process/memory_linux.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698