aboutsummaryrefslogtreecommitdiff
path: root/include/test
diff options
context:
space:
mode:
authorSimon Glass2019-12-29 21:19:23 -0700
committerSimon Glass2020-01-07 16:02:38 -0700
commit8109863f535e0851b50a333d4e7fdaa2006ac019 (patch)
tree20f07f01be8decdace7d737f37113ebc4158d5dc /include/test
parent42a8db5c5ba8541b43a1aea439b3605195b122de (diff)
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 'include/test')
-rw-r--r--include/test/ut.h16
1 files changed, 16 insertions, 0 deletions
diff --git a/include/test/ut.h b/include/test/ut.h
index fbfde10719f..f616c202f35 100644
--- a/include/test/ut.h
+++ b/include/test/ut.h
@@ -149,4 +149,20 @@ void ut_failf(struct unit_test_state *uts, const char *fname, int line,
/* Assert that an operation succeeds (returns 0) */
#define ut_assertok(cond) ut_asserteq(0, cond)
+/**
+ * ut_check_free() - Return the number of bytes free in the malloc() pool
+ *
+ * @return bytes free
+ */
+ulong ut_check_free(void);
+
+/**
+ * ut_check_delta() - Return the number of bytes allocated/freed
+ *
+ * @last: Last value from ut_check_free
+ * @return free memory delta from @last; positive means more memory has been
+ * allocated, negative means less has been allocated (i.e. some is freed)
+ */
+long ut_check_delta(ulong last);
+
#endif