[PATCH v2] test/py: net_boot: Add test cases for net boot

Tom Rini trini at konsulko.com
Fri Jan 12 16:46:05 CET 2024


On Fri, Jan 12, 2024 at 03:31:25PM +0530, Love Kumar wrote:

> Add tests for booting image using tftpboot/pxe boot commands, tftpboot
> boot case loads the FIT image into DDR and boots using bootm command
> whereas pxe boot cases downloads the pxe configuration file from the
> TFTP server and interprets it to boot the images mentioned in the pxe
> configurations file.
> This test relies on boardenv_* containing configuration values including
> the parameter 'pattern'. tftpboot/pxe boot cases boots the Linux till the
> boot log pattern value is matched. For example, if the parameter
> 'pattern' is defined as 'login:', it will boot till login prompt.
> 
> Signed-off-by: Love Kumar <love.kumar at amd.com>
[snip]
> +def setup_tftpboot_boot(u_boot_console):
> +    f = u_boot_console.config.env.get('env__net_tftp_bootable_file', None)
> +    if not f:
> +        pytest.skip('No TFTP bootable file to read')
> +
> +    test_net.test_net_dhcp(u_boot_console)
> +    test_net.test_net_setup_static(u_boot_console)

This means we skip the tests unless both DHCP and static networking are
configured and it's valid to only configure DHCP (or static), so I would
suggest re-running static only if dhcp fails.

[snip]
> + at pytest.mark.buildconfigspec('cmd_net')
> +def test_net_tftpboot_boot(u_boot_console):
> +    """Boot the loaded image
> +
> +    A boot file (fit image) is downloaded from the TFTP server and booted using
> +    bootm command with the default fit configuration, its boot log pattern are
> +    validated.
> +
> +    The details of the file to download are provided by the boardenv_* file;
> +    see the comment at the beginning of this file.
> +    """

I guess we need a way to skip just this test? My valid FIT image doesn't
have a default config.

[snip]
> +    addr, pattern, timeout, imcfg = setup_tftpboot_boot(u_boot_console)
> +    response = u_boot_console.run_command('imi %x' % addr)
> +    if not imcfg or not imcfg in response:
> +        pytest.skip('The custom configuration not found')
> +
> +    with u_boot_console.temporary_timeout(timeout):
> +        try:
> +            u_boot_console.run_command(
> +                'bootm %x#%s' % (addr, imcfg), wait_for_prompt=False
> +            )
> +            u_boot_console.wait_for(pattern)
> +        finally:
> +            u_boot_console.drain_console()
> +            u_boot_console.cleanup_spawn()

Lets skip running imi to confirm the FIT image has the config, bootm
addr#invalid-config will fail itself (and my test FIT is so big we
timeout).

But I am happy the direction this is going in, with some local hacks for
the above I was able to do the tftpboot + bootm test on hardware. I'll
follow
https://wiki.debian.org/PXEBootInstall#Provide_the_boot_image to get a
PXE setup as well for next time.

-- 
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 659 bytes
Desc: not available
URL: <https://lists.denx.de/pipermail/u-boot/attachments/20240112/bbc72150/attachment.sig>


More information about the U-Boot mailing list