mirror of
https://github.com/u-boot/u-boot.git
synced 2025-04-24 06:24:17 +00:00
test_ut: Drop exeception handling
We don't need the fallback anymore. As a first step to removing it, drop the try...except clauses and unindent the code. This produces a large diff but there are no other code changes. Signed-off-by: Simon Glass <sjg@chromium.org>
This commit is contained in:
parent
360315b360
commit
22eef59dd3
1 changed files with 78 additions and 91 deletions
|
@ -79,8 +79,7 @@ def setup_bootmenu_image(cons):
|
||||||
fname, mnt = setup_image(cons, mmc_dev, 0x83)
|
fname, mnt = setup_image(cons, mmc_dev, 0x83)
|
||||||
|
|
||||||
complete = False
|
complete = False
|
||||||
try:
|
script = '''# DO NOT EDIT THIS FILE
|
||||||
script = '''# DO NOT EDIT THIS FILE
|
|
||||||
#
|
#
|
||||||
# Please edit /boot/armbianEnv.txt to set supported parameters
|
# Please edit /boot/armbianEnv.txt to set supported parameters
|
||||||
#
|
#
|
||||||
|
@ -154,45 +153,42 @@ booti ${kernel_addr_r} ${ramdisk_addr_r} ${fdt_addr_r}
|
||||||
# Recompile with:
|
# Recompile with:
|
||||||
# mkimage -C none -A arm -T script -d /boot/boot.cmd /boot/boot.scr
|
# mkimage -C none -A arm -T script -d /boot/boot.cmd /boot/boot.scr
|
||||||
'''
|
'''
|
||||||
bootdir = os.path.join(mnt, 'boot')
|
bootdir = os.path.join(mnt, 'boot')
|
||||||
mkdir_cond(bootdir)
|
mkdir_cond(bootdir)
|
||||||
cmd_fname = os.path.join(bootdir, 'boot.cmd')
|
cmd_fname = os.path.join(bootdir, 'boot.cmd')
|
||||||
scr_fname = os.path.join(bootdir, 'boot.scr')
|
scr_fname = os.path.join(bootdir, 'boot.scr')
|
||||||
with open(cmd_fname, 'w', encoding='ascii') as outf:
|
with open(cmd_fname, 'w', encoding='ascii') as outf:
|
||||||
print(script, file=outf)
|
print(script, file=outf)
|
||||||
|
|
||||||
infname = os.path.join(cons.config.source_dir,
|
infname = os.path.join(cons.config.source_dir,
|
||||||
'test/py/tests/bootstd/armbian.bmp.xz')
|
'test/py/tests/bootstd/armbian.bmp.xz')
|
||||||
bmp_file = os.path.join(bootdir, 'boot.bmp')
|
bmp_file = os.path.join(bootdir, 'boot.bmp')
|
||||||
u_boot_utils.run_and_log(
|
u_boot_utils.run_and_log(
|
||||||
cons,
|
cons,
|
||||||
['sh', '-c', f'xz -dc {infname} >{bmp_file}'])
|
['sh', '-c', f'xz -dc {infname} >{bmp_file}'])
|
||||||
|
|
||||||
u_boot_utils.run_and_log(
|
u_boot_utils.run_and_log(
|
||||||
cons, f'mkimage -C none -A arm -T script -d {cmd_fname} {scr_fname}')
|
cons, f'mkimage -C none -A arm -T script -d {cmd_fname} {scr_fname}')
|
||||||
|
|
||||||
kernel = 'vmlinuz-5.15.63-rockchip64'
|
kernel = 'vmlinuz-5.15.63-rockchip64'
|
||||||
target = os.path.join(bootdir, kernel)
|
target = os.path.join(bootdir, kernel)
|
||||||
with open(target, 'wb') as outf:
|
with open(target, 'wb') as outf:
|
||||||
print('kernel', outf)
|
print('kernel', outf)
|
||||||
|
|
||||||
symlink = os.path.join(bootdir, 'Image')
|
symlink = os.path.join(bootdir, 'Image')
|
||||||
if os.path.exists(symlink):
|
if os.path.exists(symlink):
|
||||||
os.remove(symlink)
|
os.remove(symlink)
|
||||||
u_boot_utils.run_and_log(
|
u_boot_utils.run_and_log(
|
||||||
cons, f'echo here {kernel} {symlink}')
|
cons, f'echo here {kernel} {symlink}')
|
||||||
os.symlink(kernel, symlink)
|
os.symlink(kernel, symlink)
|
||||||
|
|
||||||
fsfile = 'ext18M.img'
|
fsfile = 'ext18M.img'
|
||||||
u_boot_utils.run_and_log(cons, f'fallocate -l 18M {fsfile}')
|
u_boot_utils.run_and_log(cons, f'fallocate -l 18M {fsfile}')
|
||||||
u_boot_utils.run_and_log(cons, f'mkfs.ext4 {fsfile} -d {mnt}')
|
u_boot_utils.run_and_log(cons, f'mkfs.ext4 {fsfile} -d {mnt}')
|
||||||
u_boot_utils.run_and_log(cons, f'dd if={fsfile} of={fname} bs=1M seek=1')
|
u_boot_utils.run_and_log(cons, f'dd if={fsfile} of={fname} bs=1M seek=1')
|
||||||
complete = True
|
complete = True
|
||||||
except ValueError as exc:
|
u_boot_utils.run_and_log(cons, f'rm -rf {mnt}')
|
||||||
print(f'Falled to create image, failing back to prepared copy: {exc}')
|
u_boot_utils.run_and_log(cons, f'rm -f {fsfile}')
|
||||||
finally:
|
|
||||||
u_boot_utils.run_and_log(cons, f'rm -rf {mnt}')
|
|
||||||
u_boot_utils.run_and_log(cons, f'rm -f {fsfile}')
|
|
||||||
|
|
||||||
if not complete:
|
if not complete:
|
||||||
copy_prepared_image(cons, mmc_dev, fname)
|
copy_prepared_image(cons, mmc_dev, fname)
|
||||||
|
@ -203,11 +199,10 @@ def setup_bootflow_image(cons):
|
||||||
fname, mnt = setup_image(cons, mmc_dev, 0xc, second_part=True)
|
fname, mnt = setup_image(cons, mmc_dev, 0xc, second_part=True)
|
||||||
|
|
||||||
complete = False
|
complete = False
|
||||||
try:
|
vmlinux = 'vmlinuz-5.3.7-301.fc31.armv7hl'
|
||||||
vmlinux = 'vmlinuz-5.3.7-301.fc31.armv7hl'
|
initrd = 'initramfs-5.3.7-301.fc31.armv7hl.img'
|
||||||
initrd = 'initramfs-5.3.7-301.fc31.armv7hl.img'
|
dtbdir = 'dtb-5.3.7-301.fc31.armv7hl'
|
||||||
dtbdir = 'dtb-5.3.7-301.fc31.armv7hl'
|
script = '''# extlinux.conf generated by appliance-creator
|
||||||
script = '''# extlinux.conf generated by appliance-creator
|
|
||||||
ui menu.c32
|
ui menu.c32
|
||||||
menu autoboot Welcome to Fedora-Workstation-armhfp-31-1.9. Automatic boot in # second{,s}. Press a key for options.
|
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 title Fedora-Workstation-armhfp-31-1.9 Boot Options.
|
||||||
|
@ -220,39 +215,36 @@ label Fedora-Workstation-armhfp-31-1.9 (5.3.7-301.fc31.armv7hl)
|
||||||
append ro root=UUID=9732b35b-4cd5-458b-9b91-80f7047e0b8a rhgb quiet LANG=en_US.UTF-8 cma=192MB cma=256MB
|
append ro root=UUID=9732b35b-4cd5-458b-9b91-80f7047e0b8a rhgb quiet LANG=en_US.UTF-8 cma=192MB cma=256MB
|
||||||
fdtdir /%s/
|
fdtdir /%s/
|
||||||
initrd /%s''' % (vmlinux, dtbdir, initrd)
|
initrd /%s''' % (vmlinux, dtbdir, initrd)
|
||||||
ext = os.path.join(mnt, 'extlinux')
|
ext = os.path.join(mnt, 'extlinux')
|
||||||
mkdir_cond(ext)
|
mkdir_cond(ext)
|
||||||
|
|
||||||
conf = os.path.join(ext, 'extlinux.conf')
|
conf = os.path.join(ext, 'extlinux.conf')
|
||||||
with open(conf, 'w', encoding='ascii') as fd:
|
with open(conf, 'w', encoding='ascii') as fd:
|
||||||
print(script, file=fd)
|
print(script, file=fd)
|
||||||
|
|
||||||
inf = os.path.join(cons.config.persistent_data_dir, 'inf')
|
inf = os.path.join(cons.config.persistent_data_dir, 'inf')
|
||||||
with open(inf, 'wb') as fd:
|
with open(inf, 'wb') as fd:
|
||||||
fd.write(gzip.compress(b'vmlinux'))
|
fd.write(gzip.compress(b'vmlinux'))
|
||||||
u_boot_utils.run_and_log(
|
u_boot_utils.run_and_log(
|
||||||
cons, f'mkimage -f auto -d {inf} {os.path.join(mnt, vmlinux)}')
|
cons, f'mkimage -f auto -d {inf} {os.path.join(mnt, vmlinux)}')
|
||||||
|
|
||||||
with open(os.path.join(mnt, initrd), 'w', encoding='ascii') as fd:
|
with open(os.path.join(mnt, initrd), 'w', encoding='ascii') as fd:
|
||||||
print('initrd', file=fd)
|
print('initrd', file=fd)
|
||||||
|
|
||||||
mkdir_cond(os.path.join(mnt, dtbdir))
|
mkdir_cond(os.path.join(mnt, dtbdir))
|
||||||
|
|
||||||
dtb_file = os.path.join(mnt, f'{dtbdir}/sandbox.dtb')
|
dtb_file = os.path.join(mnt, f'{dtbdir}/sandbox.dtb')
|
||||||
u_boot_utils.run_and_log(
|
u_boot_utils.run_and_log(
|
||||||
cons, f'dtc -o {dtb_file}', stdin=b'/dts-v1/; / {};')
|
cons, f'dtc -o {dtb_file}', stdin=b'/dts-v1/; / {};')
|
||||||
|
|
||||||
fsfile = 'vfat18M.img'
|
fsfile = 'vfat18M.img'
|
||||||
u_boot_utils.run_and_log(cons, f'fallocate -l 18M {fsfile}')
|
u_boot_utils.run_and_log(cons, f'fallocate -l 18M {fsfile}')
|
||||||
u_boot_utils.run_and_log(cons, f'mkfs.vfat {fsfile}')
|
u_boot_utils.run_and_log(cons, f'mkfs.vfat {fsfile}')
|
||||||
u_boot_utils.run_and_log(cons, ['sh', '-c', f'mcopy -i {fsfile} {mnt}/* ::/'])
|
u_boot_utils.run_and_log(cons, ['sh', '-c', f'mcopy -i {fsfile} {mnt}/* ::/'])
|
||||||
u_boot_utils.run_and_log(cons, f'dd if={fsfile} of={fname} bs=1M seek=1')
|
u_boot_utils.run_and_log(cons, f'dd if={fsfile} of={fname} bs=1M seek=1')
|
||||||
complete = True
|
complete = True
|
||||||
except ValueError as exc:
|
u_boot_utils.run_and_log(cons, f'rm -rf {mnt}')
|
||||||
print(f'Falled to create image, failing back to prepared copy: {exc}')
|
u_boot_utils.run_and_log(cons, f'rm -f {fsfile}')
|
||||||
finally:
|
|
||||||
u_boot_utils.run_and_log(cons, f'rm -rf {mnt}')
|
|
||||||
u_boot_utils.run_and_log(cons, f'rm -f {fsfile}')
|
|
||||||
if not complete:
|
if not complete:
|
||||||
copy_prepared_image(cons, mmc_dev, fname)
|
copy_prepared_image(cons, mmc_dev, fname)
|
||||||
|
|
||||||
|
@ -576,29 +568,24 @@ def setup_efi_image(cons):
|
||||||
basename=basename)
|
basename=basename)
|
||||||
|
|
||||||
complete = False
|
complete = False
|
||||||
try:
|
efi_dir = os.path.join(mnt, 'EFI')
|
||||||
efi_dir = os.path.join(mnt, 'EFI')
|
mkdir_cond(efi_dir)
|
||||||
mkdir_cond(efi_dir)
|
bootdir = os.path.join(efi_dir, 'BOOT')
|
||||||
bootdir = os.path.join(efi_dir, 'BOOT')
|
mkdir_cond(bootdir)
|
||||||
mkdir_cond(bootdir)
|
efi_src = os.path.join(cons.config.build_dir,
|
||||||
efi_src = os.path.join(cons.config.build_dir,
|
'lib/efi_loader/testapp.efi')
|
||||||
'lib/efi_loader/testapp.efi')
|
efi_dst = os.path.join(bootdir, 'BOOTSBOX.EFI')
|
||||||
efi_dst = os.path.join(bootdir, 'BOOTSBOX.EFI')
|
with open(efi_src, 'rb') as inf:
|
||||||
with open(efi_src, 'rb') as inf:
|
with open(efi_dst, 'wb') as outf:
|
||||||
with open(efi_dst, 'wb') as outf:
|
outf.write(inf.read())
|
||||||
outf.write(inf.read())
|
fsfile = 'vfat18M.img'
|
||||||
fsfile = 'vfat18M.img'
|
u_boot_utils.run_and_log(cons, f'fallocate -l 18M {fsfile}')
|
||||||
u_boot_utils.run_and_log(cons, f'fallocate -l 18M {fsfile}')
|
u_boot_utils.run_and_log(cons, f'mkfs.vfat {fsfile}')
|
||||||
u_boot_utils.run_and_log(cons, f'mkfs.vfat {fsfile}')
|
u_boot_utils.run_and_log(cons, ['sh', '-c', f'mcopy -vs -i {fsfile} {mnt}/* ::/'])
|
||||||
u_boot_utils.run_and_log(cons, ['sh', '-c', f'mcopy -vs -i {fsfile} {mnt}/* ::/'])
|
u_boot_utils.run_and_log(cons, f'dd if={fsfile} of={fname} bs=1M seek=1')
|
||||||
u_boot_utils.run_and_log(cons, f'dd if={fsfile} of={fname} bs=1M seek=1')
|
complete = True
|
||||||
complete = True
|
u_boot_utils.run_and_log(cons, f'rm -rf {mnt}')
|
||||||
except ValueError as exc:
|
u_boot_utils.run_and_log(cons, f'rm -f {fsfile}')
|
||||||
print(f'Falled to create image, failing back to prepared copy: {exc}')
|
|
||||||
|
|
||||||
finally:
|
|
||||||
u_boot_utils.run_and_log(cons, f'rm -rf {mnt}')
|
|
||||||
u_boot_utils.run_and_log(cons, f'rm -f {fsfile}')
|
|
||||||
|
|
||||||
if not complete:
|
if not complete:
|
||||||
copy_prepared_image(cons, devnum, fname, basename)
|
copy_prepared_image(cons, devnum, fname, basename)
|
||||||
|
|
Loading…
Add table
Reference in a new issue