[PATCH 2/4] test: do not imply os_malloc() outside of the sandbox

Heinrich Schuchardt heinrich.schuchardt at canonical.com
Wed Dec 31 20:10:52 CET 2025


When compiling with CONFIG_CC_OPTIMIZE_FOR_DEBUG=y the C compiler does not
execute all optimization paths and add a reference to os_malloc().

Remove the reference if CONFIG_SANDBOX=n using #ifdef.

Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt at canonical.com>
---
 test/test-main.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/test/test-main.c b/test/test-main.c
index 3254325e8b1..1815d60acf7 100644
--- a/test/test-main.c
+++ b/test/test-main.c
@@ -734,6 +734,7 @@ int ut_run_list(struct unit_test_state *uts, const char *category,
 
 	uts->of_root = gd_of_root();
 	uts->runs_per_test = runs_per_test;
+#ifdef CONFIG_SANDBOX
 	if (fdt_action() == FDTCHK_COPY && gd->fdt_blob) {
 		uts->fdt_size = fdt_totalsize(gd->fdt_blob);
 		uts->fdt_copy = os_malloc(uts->fdt_size);
@@ -743,6 +744,7 @@ int ut_run_list(struct unit_test_state *uts, const char *category,
 		}
 		memcpy(uts->fdt_copy, gd->fdt_blob, uts->fdt_size);
 	}
+#endif
 	uts->force_run = force_run;
 	ret = ut_run_tests(uts, prefix, tests, count, select_name,
 			   test_insert);
-- 
2.51.0



More information about the U-Boot mailing list