test: Split out core of Fedora image into a new function

To permit easier adding of other images, move the Fedora-specific
portions of setup_bootflow_image() into a separate function.

Signed-off-by: Simon Glass <sjg@chromium.org>
This commit is contained in:
Simon Glass 2026-04-04 08:03:12 -06:00 committed by Tom Rini
parent 57e1788ee1
commit e3077e03e6

View File

@ -159,27 +159,22 @@ booti ${kernel_addr_r} ${ramdisk_addr_r} ${fdt_addr_r}
fsh.cleanup()
def setup_bootflow_image(ubman):
"""Create a 20MB disk image with a single FAT partition"""
mmc_dev = 1
fname, mnt = fs_helper.setup_image(ubman, mmc_dev, 0xc, second_part=True)
def setup_bootflow_image(ubman, devnum, basename, vmlinux, initrd, dtbdir,
script):
"""Create a 20MB disk image with a single FAT partition
vmlinux = 'vmlinuz-5.3.7-301.fc31.armv7hl'
initrd = 'initramfs-5.3.7-301.fc31.armv7hl.img'
dtbdir = 'dtb-5.3.7-301.fc31.armv7hl'
script = '''# extlinux.conf generated by appliance-creator
ui menu.c32
menu autoboot Welcome to Fedora-Workstation-armhfp-31-1.9. Automatic boot in # second{,s}. Press a key for options.
menu title Fedora-Workstation-armhfp-31-1.9 Boot Options.
menu hidden
timeout 20
totaltimeout 600
Args:
ubman (ConsoleBase): Console to use
devnum (int): Device number to use, e.g. 1
basename (str): Base name to use in the filename, e.g. 'mmc'
vmlinux (str): Kernel filename
initrd (str): Ramdisk filename
dtbdir (str or None): Devicetree filename
script (str): Script to place in the extlinux.conf file
"""
fname, mnt = fs_helper.setup_image(ubman, devnum, 0xc, second_part=True,
basename=basename)
label Fedora-Workstation-armhfp-31-1.9 (5.3.7-301.fc31.armv7hl)
kernel /%s
append ro root=UUID=9732b35b-4cd5-458b-9b91-80f7047e0b8a rhgb quiet LANG=en_US.UTF-8 cma=192MB cma=256MB
fdtdir /%s/
initrd /%s''' % (vmlinux, dtbdir, initrd)
ext = os.path.join(mnt, 'extlinux')
mkdir_cond(ext)
@ -197,11 +192,12 @@ label Fedora-Workstation-armhfp-31-1.9 (5.3.7-301.fc31.armv7hl)
with open(os.path.join(mnt, initrd), 'w', encoding='ascii') as fd:
print('initrd', file=fd)
mkdir_cond(os.path.join(mnt, dtbdir))
if dtbdir:
mkdir_cond(os.path.join(mnt, dtbdir))
dtb_file = os.path.join(mnt, f'{dtbdir}/sandbox.dtb')
utils.run_and_log(
ubman, f'dtc -o {dtb_file}', stdin=b'/dts-v1/; / {};')
dtb_file = os.path.join(mnt, f'{dtbdir}/sandbox.dtb')
utils.run_and_log(
ubman, f'dtc -o {dtb_file}', stdin=b'/dts-v1/; / {};')
fsfile = 'vfat18M.img'
utils.run_and_log(ubman, f'fallocate -l 18M {fsfile}')
@ -211,6 +207,33 @@ label Fedora-Workstation-armhfp-31-1.9 (5.3.7-301.fc31.armv7hl)
utils.run_and_log(ubman, f'rm -rf {mnt}')
utils.run_and_log(ubman, f'rm -f {fsfile}')
def setup_fedora_image(ubman, devnum, basename):
"""Create a 20MB Fedora disk image with a single FAT partition
Args:
ubman (ConsoleBase): Console to use
devnum (int): Device number to use, e.g. 1
basename (str): Base name to use in the filename, e.g. 'mmc'
"""
vmlinux = 'vmlinuz-5.3.7-301.fc31.armv7hl'
initrd = 'initramfs-5.3.7-301.fc31.armv7hl.img'
dtbdir = 'dtb-5.3.7-301.fc31.armv7hl'
script = '''# extlinux.conf generated by appliance-creator
ui menu.c32
menu autoboot Welcome to Fedora-Workstation-armhfp-31-1.9. Automatic boot in # second{,s}. Press a key for options.
menu title Fedora-Workstation-armhfp-31-1.9 Boot Options.
menu hidden
timeout 20
totaltimeout 600
label Fedora-Workstation-armhfp-31-1.9 (5.3.7-301.fc31.armv7hl)
kernel /%s
append ro root=UUID=9732b35b-4cd5-458b-9b91-80f7047e0b8a rhgb quiet LANG=en_US.UTF-8 cma=192MB cma=256MB
fdtdir /%s/
initrd /%s''' % (vmlinux, dtbdir, initrd)
setup_bootflow_image(ubman, devnum, basename, vmlinux, initrd, dtbdir,
script)
def setup_cros_image(ubman):
"""Create a 20MB disk image with ChromiumOS partitions"""
Partition = collections.namedtuple('part', 'start,size,name')
@ -606,7 +629,7 @@ def setup_rauc_image(ubman):
def test_ut_dm_init_bootstd(ubman):
"""Initialise data for bootflow tests"""
setup_bootflow_image(ubman)
setup_fedora_image(ubman, 1, 'mmc')
setup_bootmenu_image(ubman)
setup_cedit_file(ubman)
setup_cros_image(ubman)