test: Support testing malloc() failures
It is helpful to test that out-of-memory checks work correctly in code
that calls malloc().
Add a simple way to force failure after a given number of malloc() calls.
Fix a header guard to avoid a build error on sandbox_vpl.
Signed-off-by: Simon Glass <sjg@chromium.org>
Reviewed-by: Sean Anderson <seanga2@gmail.com>
diff --git a/test/test-main.c b/test/test-main.c
index 90a324b..7a38716 100644
--- a/test/test-main.c
+++ b/test/test-main.c
@@ -47,6 +47,7 @@
uts->force_fail_alloc = false;
uts->skip_post_probe = false;
gd->dm_root = NULL;
+ malloc_disable_testing();
if (CONFIG_IS_ENABLED(UT_DM) && !CONFIG_IS_ENABLED(OF_PLATDATA))
memset(dm_testdrv_op_count, '\0', sizeof(dm_testdrv_op_count));
arch_reset_for_test();