summaryrefslogtreecommitdiffstats
path: root/include/dm
diff options
context:
space:
mode:
authorSimon Glass <sjg@chromium.org>2014-10-04 11:29:50 -0600
committerSimon Glass <sjg@chromium.org>2014-10-23 19:29:53 -0600
commit756ac0bb1526c8c661ad3ff673cd17c7602ab46e (patch)
tree0c72b1317e1d9be6f0ab0ee353e8c9ac878e5037 /include/dm
parentd44f597b12b8f8099c3c52c3eb09540966cafe79 (diff)
downloadtalos-obmc-uboot-756ac0bb1526c8c661ad3ff673cd17c7602ab46e.tar.gz
talos-obmc-uboot-756ac0bb1526c8c661ad3ff673cd17c7602ab46e.zip
test: dm: Support memory leak checking as a core feature
Check the state of the malloc() heap before each test is run, so that tests can verify that all is well at the end. Provide helper functions to mark the heap and to check that it returns to its initial state. Signed-off-by: Simon Glass <sjg@chromium.org>
Diffstat (limited to 'include/dm')
-rw-r--r--include/dm/test.h23
1 files changed, 23 insertions, 0 deletions
diff --git a/include/dm/test.h b/include/dm/test.h
index 235d728bfb..f08c05da81 100644
--- a/include/dm/test.h
+++ b/include/dm/test.h
@@ -8,6 +8,7 @@
#define __DM_TEST_H
#include <dm.h>
+#include <malloc.h>
/**
* struct dm_test_cdata - configuration data for test instance
@@ -120,6 +121,7 @@ struct dm_test_state {
int force_fail_alloc;
int skip_post_probe;
struct udevice *removed;
+ struct mallinfo start;
};
/* Test flags for each test */
@@ -178,6 +180,27 @@ int dm_check_operations(struct dm_test_state *dms, struct udevice *dev,
int dm_check_devices(struct dm_test_state *dms, int num_devices);
/**
+ * dm_leak_check_start() - Prepare to check for a memory leak
+ *
+ * Call this before allocating memory to record the amount of memory being
+ * used.
+ *
+ * @dms: Overall test state
+ */
+void dm_leak_check_start(struct dm_test_state *dms);
+
+/**
+ * dm_leak_check_end() - Check that no memory has leaked
+ *
+ * Call this after dm_leak_check_start() and after you have hopefuilly freed
+ * all the memory that was allocated. This function will print an error if
+ * it sees a different amount of total memory allocated than before.
+ *
+ * @dms: Overall test state
+ */int dm_leak_check_end(struct dm_test_state *dms);
+
+
+/**
* dm_test_main() - Run all the tests
*
* This runs all available driver model tests
OpenPOWER on IntegriCloud