diff options
author | Simon Glass <sjg@chromium.org> | 2019-12-29 21:19:23 -0700 |
---|---|---|
committer | Simon Glass <sjg@chromium.org> | 2020-01-07 16:02:38 -0700 |
commit | 8109863f535e0851b50a333d4e7fdaa2006ac019 (patch) | |
tree | 20f07f01be8decdace7d737f37113ebc4158d5dc /test | |
parent | 42a8db5c5ba8541b43a1aea439b3605195b122de (diff) | |
download | u-boot-8109863f535e0851b50a333d4e7fdaa2006ac019.zip u-boot-8109863f535e0851b50a333d4e7fdaa2006ac019.tar.gz u-boot-8109863f535e0851b50a333d4e7fdaa2006ac019.tar.bz2 |
test: Add functions to find the amount of allocated memory
The malloc() implementations provides a way of finding out the approximate
amount of memory that is allocated. Add helper functions to make it easier
to access this and see changes over time. This is useful for tests that
want to check if memory has been allocated or freed.
Signed-off-by: Simon Glass <sjg@chromium.org>
Diffstat (limited to 'test')
-rw-r--r-- | test/ut.c | 14 |
1 files changed, 14 insertions, 0 deletions
@@ -6,6 +6,7 @@ */ #include <common.h> +#include <malloc.h> #include <test/test.h> #include <test/ut.h> @@ -32,3 +33,16 @@ void ut_failf(struct unit_test_state *uts, const char *fname, int line, putc('\n'); uts->fail_count++; } + +ulong ut_check_free(void) +{ + struct mallinfo info = mallinfo(); + + return info.uordblks; +} + +long ut_check_delta(ulong last) +{ + return ut_check_free() - last; +} + |