[PATCH 2/9] test: cmd/fdt: do not assume RNG device exists

Tom Rini trini at konsulko.com
Fri Nov 14 15:22:03 CET 2025


On Fri, Nov 14, 2025 at 05:44:08AM -0700, Simon Glass wrote:
> Hi Heinrich,
> 
> On Sun, 9 Nov 2025 at 03:10, Heinrich Schuchardt
> <heinrich.schuchardt at canonical.com> wrote:
> >
> > In fdt_test_chosen() currently we test if DM_RNG is configured.
> > CONFIG_DM_RNG=y does not imply that a RNG device actually exists.
> > For instance QEMU may be called with -device virtio-rng-device or not.
> > The current test framework evicts the virtio RNG device even if QEMU is
> > called with -device virtio-rng-device.
> >
> > In the fdt_test_chosen() check if a RNG device exists.
> > Ignore 'No RNG device' messages.
> >
> > Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt at canonical.com>
> > ---
> >  test/cmd/fdt.c | 20 ++++++++++++++++----
> >  1 file changed, 16 insertions(+), 4 deletions(-)
> >
> > diff --git a/test/cmd/fdt.c b/test/cmd/fdt.c
> > index a36f2dcdda8..b950123b6da 100644
> > --- a/test/cmd/fdt.c
> > +++ b/test/cmd/fdt.c
> > @@ -10,6 +10,7 @@
> >  #include <fdt_support.h>
> >  #include <mapmem.h>
> >  #include <asm/global_data.h>
> > +#include <dm/uclass.h>
> >  #include <linux/libfdt.h>
> >  #include <test/ut.h>
> >
> > @@ -1267,6 +1268,7 @@ static int fdt_test_chosen(struct unit_test_state *uts)
> >  {
> >         const char *env_bootargs = env_get("bootargs");
> >         char fdt[8192];
> > +       struct udevice *dev;
> >         ulong addr;
> >
> >         ut_assertok(make_test_fdt(uts, fdt, sizeof(fdt), &addr));
> > @@ -1280,11 +1282,16 @@ static int fdt_test_chosen(struct unit_test_state *uts)
> >         /* Test add new chosen node without initrd */
> >         ut_assertok(run_commandf("fdt chosen"));
> >         ut_assertok(run_commandf("fdt print /chosen"));
> > -       ut_assert_nextline("chosen {");
> > +       ut_assert(0 < console_record_readline(uts->actual_str,
> > +                                             sizeof(uts->actual_str)));
> > +       if (!strcmp("No RNG device", uts->actual_str))
> > +               ut_assert(0 < console_record_readline(uts->actual_str,
> > +                                                     sizeof(uts->actual_str)));
> 
> But then this test isn't really making sure that the RNG code works.

This isn't an RNG test. That would be test/dm/rng.c or
test/dm/virtio_rng.c

-- 
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/20251114/ba62af74/attachment.sig>


More information about the U-Boot mailing list