[RFC PATCH 11/20] test: boot: add image_loader unit tests
Tom Rini
trini at konsulko.com
Thu Feb 19 15:04:21 CET 2026
On Thu, Feb 19, 2026 at 06:10:58AM -0700, Simon Glass wrote:
> Hi Daniel,
>
> On Mon, 16 Feb 2026 at 14:23, Daniel Golle <daniel at makrotopia.org> wrote:
> >
> > Add unit tests for the image_loader framework covering its core
> > logic with a mock storage backend:
> >
> > - map() allocates, reads and records a region
> > - map() returns cached pointer for already-mapped range
> > - map() returns correct offset within a larger region
> > - map() re-reads when extending a region to a larger size
> > - map_to() reads to a specified address and records it
> > - lookup() returns NULL for unmapped ranges
> > - alloc_ptr advances with correct alignment
> > - map() returns NULL when the translation table is full
> > - cleanup() calls backend and resets state
> > - map() with multiple disjoint regions
> > - read beyond image size returns error
> >
> > Also fix IMAGE_LOADER_MAX_REGIONS Kconfig to depend on IMAGE_LOADER
> > and default to 16 unconditionally (the previous 'default 0' fallback
> > caused the regions array to be zero-sized when IMAGE_LOADER was
> > enabled after initial defconfig generation).
> >
> > Register the new 'image_loader' test suite in test/cmd_ut.c so it
> > can be run via 'ut image_loader'.
> >
> > Signed-off-by: Daniel Golle <daniel at makrotopia.org>
> > ---
> > boot/Kconfig | 4 +-
> > test/boot/Makefile | 2 +
> > test/boot/image_loader.c | 429 +++++++++++++++++++++++++++++++++++++++
> > test/cmd_ut.c | 2 +
> > 4 files changed, 435 insertions(+), 2 deletions(-)
> > create mode 100644 test/boot/image_loader.c
> >
> > diff --git a/boot/Kconfig b/boot/Kconfig
> > index 1f870c7d251..efc06f3cd1a 100644
> > --- a/boot/Kconfig
> > +++ b/boot/Kconfig
> > @@ -1179,8 +1179,8 @@ config IMAGE_LOADER
> >
> > config IMAGE_LOADER_MAX_REGIONS
> > int "Maximum number of mapped regions in image loader"
> > - default 16 if IMAGE_LOADER
> > - default 0
> > + depends on IMAGE_LOADER
> > + default 16
> > help
> > Maximum number of distinct image regions that can be mapped
> > into RAM simultaneously. 16 is sufficient for typical FIT
>
> As Tom mentioned, this is in the wrong patch. But really we should
> just remove it and use an alist
Lets not have another argument about your alist stuff please.
--
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 228 bytes
Desc: not available
URL: <https://lists.denx.de/pipermail/u-boot/attachments/20260219/26c9aa80/attachment.sig>
More information about the U-Boot
mailing list