[PATCH v4 29/47] test/py: Correct sizing of created disks

Tom Rini trini at konsulko.com
Fri Mar 7 15:15:40 CET 2025


On Thu, Mar 06, 2025 at 09:03:56AM -0700, Simon Glass wrote:

> At present the disks end up being 1MB shorter than they should be,
> since dd truncates by default.
> 
> Move the code into a function and update it to avoid truncation.
> 
> This resolves various warnings when running sandbox tests, of the form:
> 
>    mmc_bread() MMC: block number 0x9801 exceeds max(0x9800)
> 
> caused by the FAT partition being scanning.
> 
> Signed-off-by: Simon Glass <sjg at chromium.org>
> ---
> 
> (no changes since v3)
> 
> Changes in v3:
> - Add new patch to correct sizing of created disks
> 
>  test/py/tests/test_ut.py | 17 ++++++++++++++---
>  1 file changed, 14 insertions(+), 3 deletions(-)
> 
> diff --git a/test/py/tests/test_ut.py b/test/py/tests/test_ut.py
> index ea0c43cd4fc..b8adb597e11 100644
> --- a/test/py/tests/test_ut.py
> +++ b/test/py/tests/test_ut.py
> @@ -57,6 +57,17 @@ def setup_image(ubman, devnum, part_type, img_size=20, second_part=False,
>                               stdin=spec.encode('utf-8'))
>      return fname, mnt
>  
> +def copy_partition(ubman, fsfile, outname):
> +    """Copy a partition into a disk iamge
> +
> +    Args:
> +        ubman (ConsoleBase): U-Boot fixture
> +        fsfile (str): Name of partition file
> +        outname (str): Name of full-disk file to update
> +    """
> +    utils.run_and_log(ubman,
> +                      f'dd if={fsfile} of={outname} bs=1M seek=1 conv=notrunc')

Ah, interesting.

> +
>  def setup_bootmenu_image(ubman):
>      """Create a 20MB disk image with a single ext4 partition
>  
> @@ -172,7 +183,7 @@ booti ${kernel_addr_r} ${ramdisk_addr_r} ${fdt_addr_r}
>      fsfile = 'ext18M.img'
>      utils.run_and_log(ubman, f'fallocate -l 18M {fsfile}')
>      utils.run_and_log(ubman, f'mkfs.ext4 {fsfile} -d {mnt}')
> -    utils.run_and_log(ubman, f'dd if={fsfile} of={fname} bs=1M seek=1')
> +    copy_partition(ubman, fsfile, fname)
>      utils.run_and_log(ubman, f'rm -rf {mnt}')
>      utils.run_and_log(ubman, f'rm -f {fsfile}')
>  
> @@ -224,7 +235,7 @@ label Fedora-Workstation-armhfp-31-1.9 (5.3.7-301.fc31.armv7hl)
>      utils.run_and_log(ubman, f'fallocate -l 18M {fsfile}')
>      utils.run_and_log(ubman, f'mkfs.vfat {fsfile}')
>      utils.run_and_log(ubman, ['sh', '-c', f'mcopy -i {fsfile} {mnt}/* ::/'])
> -    utils.run_and_log(ubman, f'dd if={fsfile} of={fname} bs=1M seek=1')
> +    copy_partition(ubman, fsfile, fname)
>      utils.run_and_log(ubman, f'rm -rf {mnt}')
>      utils.run_and_log(ubman, f'rm -f {fsfile}')
>  
> @@ -562,7 +573,7 @@ def setup_efi_image(ubman):
>      utils.run_and_log(ubman, f'fallocate -l 18M {fsfile}')
>      utils.run_and_log(ubman, f'mkfs.vfat {fsfile}')
>      utils.run_and_log(ubman, ['sh', '-c', f'mcopy -vs -i {fsfile} {mnt}/* ::/'])
> -    utils.run_and_log(ubman, f'dd if={fsfile} of={fname} bs=1M seek=1')
> +    copy_partition(ubman, fsfile, fname)
>      utils.run_and_log(ubman, f'rm -rf {mnt}')
>      utils.run_and_log(ubman, f'rm -f {fsfile}')

It's on my TODO list to make all of these use the mk_fs helper instead,
I noticed this yesterday or the day before.

-- 
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/20250307/8104bad9/attachment.sig>


More information about the U-Boot mailing list