aboutsummaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorSimon Glass <sjg@chromium.org>2022-10-29 19:47:08 -0600
committerSimon Glass <sjg@chromium.org>2022-11-07 16:24:30 -0700
commit5ea894ac4285be2bebc2e7bdfd6451c699469f37 (patch)
tree52ab410f3ca011c24657c5498859efac5f93dc4a /test
parentfa1e420ab0259b0e8c975a6572dc3086596b980e (diff)
downloadu-boot-5ea894ac4285be2bebc2e7bdfd6451c699469f37.zip
u-boot-5ea894ac4285be2bebc2e7bdfd6451c699469f37.tar.gz
u-boot-5ea894ac4285be2bebc2e7bdfd6451c699469f37.tar.bz2
dm: test: Clear the block cache after running a test
Some tests access data in block devices and so cause the cache to fill up. This results in memory being allocated. Some tests check the malloc usage at the beginning and then again at the end, to ensure there is no memory leak caused by the test. The block cache makes this difficult, since the any test may cause entries to be allocated or even freed, if the cache becomes full. It is simpler to clear the block cache after each test. This ensures that it will not introduce noise in tests which check malloc usage. Add the logic to clear the cache, using the existing blkcache_invalidate() function. Drop the duplicate code at the same time. Signed-off-by: Simon Glass <sjg@chromium.org>
Diffstat (limited to 'test')
-rw-r--r--test/test-main.c3
1 files changed, 3 insertions, 0 deletions
diff --git a/test/test-main.c b/test/test-main.c
index fe3ef6d..867c57f 100644
--- a/test/test-main.c
+++ b/test/test-main.c
@@ -5,6 +5,7 @@
*/
#include <common.h>
+#include <blk.h>
#include <console.h>
#include <cyclic.h>
#include <dm.h>
@@ -352,6 +353,8 @@ static int test_post_run(struct unit_test_state *uts, struct unit_test *test)
free(uts->of_other);
uts->of_other = NULL;
+ blkcache_free();
+
return 0;
}