From 4e56228637b5e82fad30ce11b231a5bfe1cf46ea Mon Sep 17 00:00:00 2001 From: Christopher Ferris Date: Thu, 7 Feb 2019 14:20:03 -0800 Subject: Fix flakiness of mallinfo test. The test was really only supposed to verify that mallinfo eventually increase after allocations of certain sizes. Sometimes the mallinfo returned decreases due to some compaction event, so don't fail in that case. Bug: 124060188 Test: Ran the test 2000 times (32 bit and 64 bit). It would fail within about Test: 200 test iterations before. Change-Id: Ie019107be163dcf275cedf4d1bc5759278def483 --- tests/malloc_test.cpp | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) (limited to 'tests/malloc_test.cpp') diff --git a/tests/malloc_test.cpp b/tests/malloc_test.cpp index a3fe5af33..1431cc134 100644 --- a/tests/malloc_test.cpp +++ b/tests/malloc_test.cpp @@ -588,10 +588,13 @@ TEST(malloc, mallinfo) { size_t new_allocated = mallinfo().uordblks; if (allocated != new_allocated) { size_t usable_size = malloc_usable_size(ptrs[i]); - ASSERT_GE(new_allocated, allocated + usable_size) - << "Failed at size " << size << " usable size " << usable_size; - pass = true; - break; + // Only check if the total got bigger by at least allocation size. + // Sometimes the mallinfo numbers can go backwards due to compaction + // and/or freeing of cached data. + if (new_allocated >= allocated + usable_size) { + pass = true; + break; + } } } for (void* ptr : ptrs) { -- cgit v1.2.3