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

Unified Diff: base/tracked_objects_unittest.cc

Issue 2859493002: Tracked objects: Bump cumulative byte count storage to 64 bits to avoid saturation (Closed)
Patch Set: Fix 64 bit compile, doofus!. Created 3 years, 8 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « base/tracked_objects.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/tracked_objects_unittest.cc
diff --git a/base/tracked_objects_unittest.cc b/base/tracked_objects_unittest.cc
index f208e3c9818fca3f5d1d54ea298471c883c64091..80b40643e5bb027e9bef4c2bef3ddda119674eb8 100644
--- a/base/tracked_objects_unittest.cc
+++ b/base/tracked_objects_unittest.cc
@@ -346,13 +346,20 @@ TEST_F(TrackedObjectsTest, DeathDataTestRecordAllocations) {
EXPECT_EQ(data->alloc_overhead_bytes(), 3 * kAllocOverheadBytes);
EXPECT_EQ(data->max_allocated_bytes(), kLargerMaxAllocatedBytes);
- // Saturate everything.
+ // Saturate everything but aggregate byte counts. The byte counts will be
+ // pushed past the 32 bit value range.
+ data->RecordAllocations(INT_MAX, INT_MAX, INT_MAX, INT_MAX, INT_MAX, INT_MAX);
data->RecordAllocations(INT_MAX, INT_MAX, INT_MAX, INT_MAX, INT_MAX, INT_MAX);
EXPECT_EQ(data->alloc_ops(), INT_MAX);
EXPECT_EQ(data->free_ops(), INT_MAX);
- EXPECT_EQ(data->allocated_bytes(), INT_MAX);
- EXPECT_EQ(data->freed_bytes(), INT_MAX);
- EXPECT_EQ(data->alloc_overhead_bytes(), INT_MAX);
+ // The cumulative byte counts are 64 bit wide, and won't saturate easily.
+ EXPECT_EQ(data->allocated_bytes(),
+ 2 * static_cast<int64_t>(INT_MAX) +
+ static_cast<int64_t>(3 * kAllocatedBytes));
+ EXPECT_EQ(data->freed_bytes(),
+ 2 * static_cast<int64_t>(INT_MAX) + 3 * kFreedBytes);
+ EXPECT_EQ(data->alloc_overhead_bytes(),
+ 2 * static_cast<int64_t>(INT_MAX) + 3 * kAllocOverheadBytes);
EXPECT_EQ(data->max_allocated_bytes(), INT_MAX);
}
« no previous file with comments | « base/tracked_objects.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698