summaryrefslogtreecommitdiff
path: root/test/dm
diff options
context:
space:
mode:
authorSimon Glass <sjg@chromium.org>2015-09-12 08:45:20 -0600
committerSimon Glass <sjg@chromium.org>2015-10-05 15:47:49 +0100
commitcbfc2ff9da392d61cd456703ea6256996eb8beb1 (patch)
treeab5db87e61244b1986adf2531356b9422f658547 /test/dm
parent84d26e296ab62b172f73b5367d9b7295309dfdd5 (diff)
downloadu-boot-imx-cbfc2ff9da392d61cd456703ea6256996eb8beb1.zip
u-boot-imx-cbfc2ff9da392d61cd456703ea6256996eb8beb1.tar.gz
u-boot-imx-cbfc2ff9da392d61cd456703ea6256996eb8beb1.tar.bz2
dm: test: Show the amount of leaked memory on error
Adjust the memory leak tests to show the amount of memory leaked. This can be a useful signal as to what is wrong. Signed-off-by: Simon Glass <sjg@chromium.org>
Diffstat (limited to 'test/dm')
-rw-r--r--test/dm/core.c7
1 files changed, 6 insertions, 1 deletions
diff --git a/test/dm/core.c b/test/dm/core.c
index 976a706..9fbc70d 100644
--- a/test/dm/core.c
+++ b/test/dm/core.c
@@ -77,7 +77,7 @@ void dm_leak_check_start(struct unit_test_state *uts)
int dm_leak_check_end(struct unit_test_state *uts)
{
struct mallinfo end;
- int id;
+ int id, diff;
/* Don't delete the root class, since we started with that */
for (id = UCLASS_ROOT + 1; id < UCLASS_COUNT; id++) {
@@ -90,6 +90,11 @@ int dm_leak_check_end(struct unit_test_state *uts)
}
end = mallinfo();
+ diff = end.uordblks - uts->start.uordblks;
+ if (diff > 0)
+ printf("Leak: lost %#xd bytes\n", diff);
+ else if (diff < 0)
+ printf("Leak: gained %#xd bytes\n", -diff);
ut_asserteq(uts->start.uordblks, end.uordblks);
return 0;