Merge "Fix flakiness of mallinfo test."
diff --git a/tests/malloc_test.cpp b/tests/malloc_test.cpp
index a3fe5af..1431cc1 100644
--- a/tests/malloc_test.cpp
+++ b/tests/malloc_test.cpp
@@ -588,10 +588,13 @@
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) {