[RFC PATCH 20/31] test: cedit: use allocated address for reading file

Simon Glass sjg at chromium.org
Tue Jun 11 20:52:18 CEST 2024


Hi Sughosh,

On Fri, 7 Jun 2024 at 12:54, Sughosh Ganu <sughosh.ganu at linaro.org> wrote:
>
> Instead of a randomly selected address, use an LMB allocated one for
> reading the file into memory. With the LMB map now being persistent
> and global, the address used for reading the file might be already
> allocated as non-overwritable, resulting in a failure. Get a valid
> address from LMB and then read the file to that address.
>
> Signed-off-by: Sughosh Ganu <sughosh.ganu at linaro.org>
> ---
>  test/boot/cedit.c | 5 ++++-
>  1 file changed, 4 insertions(+), 1 deletion(-)
>
> diff --git a/test/boot/cedit.c b/test/boot/cedit.c
> index aa41719048..1f4147da89 100644
> --- a/test/boot/cedit.c
> +++ b/test/boot/cedit.c
> @@ -8,6 +8,7 @@
>  #include <cedit.h>
>  #include <env.h>
>  #include <expo.h>
> +#include <lmb.h>
>  #include <mapmem.h>
>  #include <dm/ofnode.h>
>  #include <test/ut.h>
> @@ -62,7 +63,7 @@ static int cedit_fdt(struct unit_test_state *uts)
>         struct video_priv *vid_priv;
>         extern struct expo *cur_exp;
>         struct scene_obj_menu *menu;
> -       ulong addr = 0x1000;
> +       ulong addr;
>         struct ofprop prop;
>         struct scene *scn;
>         oftree tree;
> @@ -87,6 +88,8 @@ static int cedit_fdt(struct unit_test_state *uts)
>         str = abuf_data(&tline->buf);
>         strcpy(str, "my-machine");
>
> +       addr = lmb_alloc(1024, 1024);
> +       ut_asserteq(!!addr, !0);
>         ut_assertok(run_command("cedit write_fdt hostfs - settings.dtb", 0));
>         ut_assertok(run_commandf("load hostfs - %lx settings.dtb", addr));
>         ut_assert_nextlinen("1024 bytes read");
> --
> 2.34.1
>

This is a situation where we don't want to make changes.

We know that address is valid for testing. We won't have LMB
allocations that persist across tests...even if that were to happen we
would want the test to reset the lmb state. That is how the sandbox
test-system works.

Regards,
Simon


More information about the U-Boot mailing list