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

Heinrich Schuchardt heinrich.schuchardt at canonical.com
Fri Jan 2 16:18:59 CET 2026


On 1/2/26 13:29, Simon Glass wrote:
> Hi Heinrich,
> 
> On Wed, 31 Dec 2025 at 12:11, Heinrich Schuchardt
> <heinrich.schuchardt at canonical.com> wrote:
>>
>> 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
>>
> 
> Oddly I hit this same problem some months back but I didn't end up
> needing to patch it.
> 
> Which board are you building here and which toolchain?

I am on Ubuntu 26.04 (gcc 15.2.0-7ubuntu1) and the board was 
qemu-riscv64_smode_defconfig.

Best regards

Heinrich


More information about the U-Boot mailing list