From 463bc7b82e7b3e8298d9cb81b5d03af8b48b2148 Mon Sep 17 00:00:00 2001 From: Richard Weinberger Date: Thu, 21 Nov 2024 15:32:07 -0700 Subject: test_fs: Allow running unprivileged There is no need to mount the filesystem on the host side. All filesystem tools offer some way to fill the fs without mounting. So, create the content on the host side, create and fill the fs without mounting. No more sudo or guestmount needed. This new approach works because the tests don't care about user IDs and no device files are needed. If user IDs start to matter it's still possible to use wrapper tools like fakeroot in future while filling the fs. Signed-off-by: Richard Weinberger Signed-off-by: Simon Glass Tested-by: Mattijs Korpershoek --- test/py/tests/test_ut.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'test/py/tests/test_ut.py') diff --git a/test/py/tests/test_ut.py b/test/py/tests/test_ut.py index 6d44191976b..70ac012b3ad 100644 --- a/test/py/tests/test_ut.py +++ b/test/py/tests/test_ut.py @@ -540,8 +540,8 @@ def test_ut_dm_init(u_boot_console): u_boot_utils.run_and_log( u_boot_console, f'sfdisk {fn}', stdin=b'type=83') - fs_helper.mk_fs(u_boot_console.config, 'ext2', 0x200000, '2MB') - fs_helper.mk_fs(u_boot_console.config, 'fat32', 0x100000, '1MB') + fs_helper.mk_fs(u_boot_console.config, 'ext2', 0x200000, '2MB', None) + fs_helper.mk_fs(u_boot_console.config, 'fat32', 0x100000, '1MB', None) mmc_dev = 6 fn = os.path.join(u_boot_console.config.source_dir, f'mmc{mmc_dev}.img') -- cgit v1.2.3 From 0a4c69b1f002e53917c7699c3a122580939d98b5 Mon Sep 17 00:00:00 2001 From: Simon Glass Date: Thu, 21 Nov 2024 15:32:09 -0700 Subject: test_ut: Add an image size to setup_image() Add a parameter to indicate the size of the image to build. Signed-off-by: Simon Glass Signed-off-by: Richard Weinberger --- test/py/tests/test_ut.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) (limited to 'test/py/tests/test_ut.py') diff --git a/test/py/tests/test_ut.py b/test/py/tests/test_ut.py index 70ac012b3ad..0b716f4029c 100644 --- a/test/py/tests/test_ut.py +++ b/test/py/tests/test_ut.py @@ -28,13 +28,15 @@ def mkdir_cond(dirname): if not os.path.exists(dirname): os.mkdir(dirname) -def setup_image(cons, devnum, part_type, second_part=False, basename='mmc'): - """Create a 20MB disk image with a single partition +def setup_image(cons, devnum, part_type, img_size=20, second_part=False, + basename='mmc'): + """Create a disk image with a single partition Args: cons (ConsoleBase): Console to use devnum (int): Device number to use, e.g. 1 part_type (int): Partition type, e.g. 0xc for FAT32 + img_size (int): Image size in MiB second_part (bool): True to contain a small second partition basename (str): Base name to use in the filename, e.g. 'mmc' @@ -47,11 +49,11 @@ def setup_image(cons, devnum, part_type, second_part=False, basename='mmc'): mnt = os.path.join(cons.config.persistent_data_dir, 'mnt') mkdir_cond(mnt) - spec = f'type={part_type:x}, size=18M, bootable' + spec = f'type={part_type:x}, size={img_size - 2}M, start=1M, bootable' if second_part: spec += '\ntype=c' - u_boot_utils.run_and_log(cons, f'qemu-img create {fname} 20M') + u_boot_utils.run_and_log(cons, f'qemu-img create {fname} {img_size}M') u_boot_utils.run_and_log(cons, f'sudo sfdisk {fname}', stdin=spec.encode('utf-8')) return fname, mnt -- cgit v1.2.3 From d83143eb55cbf45ff4247f9329e053c754b2edda Mon Sep 17 00:00:00 2001 From: Richard Weinberger Date: Thu, 21 Nov 2024 15:32:10 -0700 Subject: test_ut: Allow running unprivileged Like for test_fs, no need to mess with loop mounts. Tweaks to reduce diff (keep mnt variable): Signed-off-by: Richard Weinberger Signed-off-by: Simon Glass --- test/py/tests/test_ut.py | 86 +++++++++++++++--------------------------------- 1 file changed, 26 insertions(+), 60 deletions(-) (limited to 'test/py/tests/test_ut.py') diff --git a/test/py/tests/test_ut.py b/test/py/tests/test_ut.py index 0b716f4029c..d449d0baf5e 100644 --- a/test/py/tests/test_ut.py +++ b/test/py/tests/test_ut.py @@ -8,7 +8,6 @@ test one at a time, as well setting up some files needed by the tests. # Copyright (c) 2016, NVIDIA CORPORATION. All rights reserved. """ import collections -import getpass import gzip import os import os.path @@ -43,44 +42,21 @@ def setup_image(cons, devnum, part_type, img_size=20, second_part=False, Returns: tuple: str: Filename of MMC image - str: Directory name of 'mnt' directory + str: Directory name of scratch directory """ fname = os.path.join(cons.config.source_dir, f'{basename}{devnum}.img') - mnt = os.path.join(cons.config.persistent_data_dir, 'mnt') + mnt = os.path.join(cons.config.persistent_data_dir, 'scratch') mkdir_cond(mnt) spec = f'type={part_type:x}, size={img_size - 2}M, start=1M, bootable' if second_part: spec += '\ntype=c' - u_boot_utils.run_and_log(cons, f'qemu-img create {fname} {img_size}M') - u_boot_utils.run_and_log(cons, f'sudo sfdisk {fname}', + u_boot_utils.run_and_log(cons, f'qemu-img create {fname} 20M') + u_boot_utils.run_and_log(cons, f'sfdisk {fname}', stdin=spec.encode('utf-8')) return fname, mnt -def mount_image(cons, fname, mnt, fstype): - """Create a filesystem and mount it on partition 1 - - Args: - cons (ConsoleBase): Console to use - fname (str): Filename of MMC image - mnt (str): Directory name of 'mnt' directory - fstype (str): Filesystem type ('vfat' or 'ext4') - - Returns: - str: Name of loop device used - """ - out = u_boot_utils.run_and_log(cons, f'sudo losetup --show -f -P {fname}') - loop = out.strip() - part = f'{loop}p1' - u_boot_utils.run_and_log(cons, f'sudo mkfs.{fstype} {part}') - opts = '' - if fstype == 'vfat': - opts += f' -o uid={os.getuid()},gid={os.getgid()}' - u_boot_utils.run_and_log(cons, f'sudo mount -o loop {part} {mnt}{opts}') - u_boot_utils.run_and_log(cons, f'sudo chown {getpass.getuser()} {mnt}') - return loop - def copy_prepared_image(cons, devnum, fname, basename='mmc'): """Use a prepared image since we cannot create one @@ -102,13 +78,8 @@ def setup_bootmenu_image(cons): mmc_dev = 4 fname, mnt = setup_image(cons, mmc_dev, 0x83) - loop = None - mounted = False complete = False try: - loop = mount_image(cons, fname, mnt, 'ext4') - mounted = True - script = '''# DO NOT EDIT THIS FILE # # Please edit /boot/armbianEnv.txt to set supported parameters @@ -212,15 +183,16 @@ booti ${kernel_addr_r} ${ramdisk_addr_r} ${fdt_addr_r} cons, f'echo here {kernel} {symlink}') os.symlink(kernel, symlink) + fsfile = 'ext18M.img' + 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'dd if={fsfile} of={fname} bs=1M seek=1') complete = True - except ValueError as exc: print(f'Falled to create image, failing back to prepared copy: {exc}') finally: - if mounted: - u_boot_utils.run_and_log(cons, f'sudo umount --lazy {mnt}') - if loop: - u_boot_utils.run_and_log(cons, f'sudo losetup -d {loop}') + 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: copy_prepared_image(cons, mmc_dev, fname) @@ -230,13 +202,8 @@ def setup_bootflow_image(cons): mmc_dev = 1 fname, mnt = setup_image(cons, mmc_dev, 0xc, second_part=True) - loop = None - mounted = False complete = False try: - loop = mount_image(cons, fname, mnt, 'vfat') - mounted = True - 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' @@ -274,19 +241,21 @@ label Fedora-Workstation-armhfp-31-1.9 (5.3.7-301.fc31.armv7hl) dtb_file = os.path.join(mnt, f'{dtbdir}/sandbox.dtb') u_boot_utils.run_and_log( cons, f'dtc -o {dtb_file}', stdin=b'/dts-v1/; / {};') + + fsfile = 'vfat18M.img' + 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, ['sh', '-c', f'mcopy -i {fsfile} {mnt}/* ::/']) + u_boot_utils.run_and_log(cons, f'dd if={fsfile} of={fname} bs=1M seek=1') complete = True except ValueError as exc: print(f'Falled to create image, failing back to prepared copy: {exc}') finally: - if mounted: - u_boot_utils.run_and_log(cons, f'sudo umount --lazy {mnt}') - if loop: - u_boot_utils.run_and_log(cons, f'sudo losetup -d {loop}') - + 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: copy_prepared_image(cons, mmc_dev, fname) - def setup_cros_image(cons): """Create a 20MB disk image with ChromiumOS partitions""" Partition = collections.namedtuple('part', 'start,size,name') @@ -336,8 +305,6 @@ def setup_cros_image(cons): mmc_dev = 5 fname = os.path.join(cons.config.source_dir, f'mmc{mmc_dev}.img') u_boot_utils.run_and_log(cons, f'qemu-img create {fname} 20M') - #mnt = os.path.join(cons.config.persistent_data_dir, 'mnt') - #mkdir_cond(mnt) u_boot_utils.run_and_log(cons, f'cgpt create {fname}') uuid_state = 'ebd0a0a2-b9e5-4433-87c0-68b6b72699c7' @@ -559,31 +526,30 @@ def setup_efi_image(cons): fname, mnt = setup_image(cons, devnum, 0xc, second_part=True, basename=basename) - loop = None - mounted = False complete = False try: - loop = mount_image(cons, fname, mnt, 'ext4') - mounted = True efi_dir = os.path.join(mnt, 'EFI') mkdir_cond(efi_dir) bootdir = os.path.join(efi_dir, 'BOOT') mkdir_cond(bootdir) efi_src = os.path.join(cons.config.build_dir, - f'lib/efi_loader/testapp.efi') + 'lib/efi_loader/testapp.efi') efi_dst = os.path.join(bootdir, 'BOOTSBOX.EFI') with open(efi_src, 'rb') as inf: with open(efi_dst, 'wb') as outf: outf.write(inf.read()) + fsfile = 'vfat18M.img' + 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, ['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') complete = True except ValueError as exc: print(f'Falled to create image, failing back to prepared copy: {exc}') finally: - if mounted: - u_boot_utils.run_and_log(cons, 'sudo umount --lazy %s' % mnt) - if loop: - u_boot_utils.run_and_log(cons, 'sudo losetup -d %s' % loop) + 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: copy_prepared_image(cons, devnum, fname, basename) -- cgit v1.2.3 From ac1c547092f88d6c81848d81896765a974d06300 Mon Sep 17 00:00:00 2001 From: Simon Glass Date: Thu, 21 Nov 2024 15:32:11 -0700 Subject: 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 --- test/py/tests/test_ut.py | 175 ++++++++++++++++++++++------------------------- 1 file changed, 81 insertions(+), 94 deletions(-) (limited to 'test/py/tests/test_ut.py') diff --git a/test/py/tests/test_ut.py b/test/py/tests/test_ut.py index d449d0baf5e..82cedbef039 100644 --- a/test/py/tests/test_ut.py +++ b/test/py/tests/test_ut.py @@ -79,8 +79,7 @@ def setup_bootmenu_image(cons): fname, mnt = setup_image(cons, mmc_dev, 0x83) complete = False - try: - script = '''# DO NOT EDIT THIS FILE + script = '''# DO NOT EDIT THIS FILE # # 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: # mkimage -C none -A arm -T script -d /boot/boot.cmd /boot/boot.scr ''' - bootdir = os.path.join(mnt, 'boot') - mkdir_cond(bootdir) - cmd_fname = os.path.join(bootdir, 'boot.cmd') - scr_fname = os.path.join(bootdir, 'boot.scr') - with open(cmd_fname, 'w', encoding='ascii') as outf: - print(script, file=outf) - - infname = os.path.join(cons.config.source_dir, - 'test/py/tests/bootstd/armbian.bmp.xz') - bmp_file = os.path.join(bootdir, 'boot.bmp') - u_boot_utils.run_and_log( - cons, - ['sh', '-c', f'xz -dc {infname} >{bmp_file}']) + bootdir = os.path.join(mnt, 'boot') + mkdir_cond(bootdir) + cmd_fname = os.path.join(bootdir, 'boot.cmd') + scr_fname = os.path.join(bootdir, 'boot.scr') + with open(cmd_fname, 'w', encoding='ascii') as outf: + print(script, file=outf) - u_boot_utils.run_and_log( - cons, f'mkimage -C none -A arm -T script -d {cmd_fname} {scr_fname}') + infname = os.path.join(cons.config.source_dir, + 'test/py/tests/bootstd/armbian.bmp.xz') + bmp_file = os.path.join(bootdir, 'boot.bmp') + u_boot_utils.run_and_log( + cons, + ['sh', '-c', f'xz -dc {infname} >{bmp_file}']) - kernel = 'vmlinuz-5.15.63-rockchip64' - target = os.path.join(bootdir, kernel) - with open(target, 'wb') as outf: - print('kernel', outf) + u_boot_utils.run_and_log( + cons, f'mkimage -C none -A arm -T script -d {cmd_fname} {scr_fname}') - symlink = os.path.join(bootdir, 'Image') - if os.path.exists(symlink): - os.remove(symlink) - u_boot_utils.run_and_log( - cons, f'echo here {kernel} {symlink}') - os.symlink(kernel, symlink) - - fsfile = 'ext18M.img' - 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'dd if={fsfile} of={fname} bs=1M seek=1') - complete = True - except ValueError as exc: - 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}') + kernel = 'vmlinuz-5.15.63-rockchip64' + target = os.path.join(bootdir, kernel) + with open(target, 'wb') as outf: + print('kernel', outf) + + symlink = os.path.join(bootdir, 'Image') + if os.path.exists(symlink): + os.remove(symlink) + u_boot_utils.run_and_log( + cons, f'echo here {kernel} {symlink}') + os.symlink(kernel, symlink) + + fsfile = 'ext18M.img' + 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'dd if={fsfile} of={fname} bs=1M seek=1') + complete = True + 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: 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) complete = False - try: - 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 + 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. @@ -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 fdtdir /%s/ initrd /%s''' % (vmlinux, dtbdir, initrd) - ext = os.path.join(mnt, 'extlinux') - mkdir_cond(ext) + ext = os.path.join(mnt, 'extlinux') + mkdir_cond(ext) - conf = os.path.join(ext, 'extlinux.conf') - with open(conf, 'w', encoding='ascii') as fd: - print(script, file=fd) + conf = os.path.join(ext, 'extlinux.conf') + with open(conf, 'w', encoding='ascii') as fd: + print(script, file=fd) - inf = os.path.join(cons.config.persistent_data_dir, 'inf') - with open(inf, 'wb') as fd: - fd.write(gzip.compress(b'vmlinux')) - u_boot_utils.run_and_log( - cons, f'mkimage -f auto -d {inf} {os.path.join(mnt, vmlinux)}') + inf = os.path.join(cons.config.persistent_data_dir, 'inf') + with open(inf, 'wb') as fd: + fd.write(gzip.compress(b'vmlinux')) + u_boot_utils.run_and_log( + cons, f'mkimage -f auto -d {inf} {os.path.join(mnt, vmlinux)}') - with open(os.path.join(mnt, initrd), 'w', encoding='ascii') as fd: - print('initrd', file=fd) + with open(os.path.join(mnt, initrd), 'w', encoding='ascii') as 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') - u_boot_utils.run_and_log( - cons, f'dtc -o {dtb_file}', stdin=b'/dts-v1/; / {};') - - fsfile = 'vfat18M.img' - 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, ['sh', '-c', f'mcopy -i {fsfile} {mnt}/* ::/']) - u_boot_utils.run_and_log(cons, f'dd if={fsfile} of={fname} bs=1M seek=1') - complete = True - except ValueError as exc: - 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}') + dtb_file = os.path.join(mnt, f'{dtbdir}/sandbox.dtb') + u_boot_utils.run_and_log( + cons, f'dtc -o {dtb_file}', stdin=b'/dts-v1/; / {};') + + fsfile = 'vfat18M.img' + 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, ['sh', '-c', f'mcopy -i {fsfile} {mnt}/* ::/']) + u_boot_utils.run_and_log(cons, f'dd if={fsfile} of={fname} bs=1M seek=1') + complete = True + 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: copy_prepared_image(cons, mmc_dev, fname) @@ -527,29 +519,24 @@ def setup_efi_image(cons): basename=basename) complete = False - try: - efi_dir = os.path.join(mnt, 'EFI') - mkdir_cond(efi_dir) - bootdir = os.path.join(efi_dir, 'BOOT') - mkdir_cond(bootdir) - efi_src = os.path.join(cons.config.build_dir, - 'lib/efi_loader/testapp.efi') - efi_dst = os.path.join(bootdir, 'BOOTSBOX.EFI') - with open(efi_src, 'rb') as inf: - with open(efi_dst, 'wb') as outf: - outf.write(inf.read()) - fsfile = 'vfat18M.img' - 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, ['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') - complete = True - except ValueError as exc: - 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}') + efi_dir = os.path.join(mnt, 'EFI') + mkdir_cond(efi_dir) + bootdir = os.path.join(efi_dir, 'BOOT') + mkdir_cond(bootdir) + efi_src = os.path.join(cons.config.build_dir, + 'lib/efi_loader/testapp.efi') + efi_dst = os.path.join(bootdir, 'BOOTSBOX.EFI') + with open(efi_src, 'rb') as inf: + with open(efi_dst, 'wb') as outf: + outf.write(inf.read()) + fsfile = 'vfat18M.img' + 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, ['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') + complete = True + 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: copy_prepared_image(cons, devnum, fname, basename) -- cgit v1.2.3 From 2042ed38a8d0756041b2d5a4909e1a4d34de507a Mon Sep 17 00:00:00 2001 From: Simon Glass Date: Thu, 21 Nov 2024 15:32:12 -0700 Subject: test_ut: Use the built mkimage The mkimage tool is not present in the docker image. Use the one in the build directory. Signed-off-by: Simon Glass --- test/py/tests/test_ut.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'test/py/tests/test_ut.py') diff --git a/test/py/tests/test_ut.py b/test/py/tests/test_ut.py index 82cedbef039..6c3b360d5fd 100644 --- a/test/py/tests/test_ut.py +++ b/test/py/tests/test_ut.py @@ -167,8 +167,9 @@ booti ${kernel_addr_r} ${ramdisk_addr_r} ${fdt_addr_r} cons, ['sh', '-c', f'xz -dc {infname} >{bmp_file}']) + mkimage = cons.config.build_dir + '/tools/mkimage' 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' target = os.path.join(bootdir, kernel) @@ -225,8 +226,9 @@ label Fedora-Workstation-armhfp-31-1.9 (5.3.7-301.fc31.armv7hl) inf = os.path.join(cons.config.persistent_data_dir, 'inf') with open(inf, 'wb') as fd: fd.write(gzip.compress(b'vmlinux')) + mkimage = cons.config.build_dir + '/tools/mkimage' 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: print('initrd', file=fd) -- cgit v1.2.3 From 6e32ca33ae65b55c48392e79b243c85b717cae5b Mon Sep 17 00:00:00 2001 From: Simon Glass Date: Thu, 21 Nov 2024 15:32:13 -0700 Subject: test_ut: Drop support for fallback files We don't need the fallback anymore. Remove the code which uses these files. Signed-off-by: Simon Glass Signed-off-by: Richard Weinberger --- test/py/tests/test_ut.py | 28 ---------------------------- 1 file changed, 28 deletions(-) (limited to 'test/py/tests/test_ut.py') diff --git a/test/py/tests/test_ut.py b/test/py/tests/test_ut.py index 6c3b360d5fd..9b6b6b20c85 100644 --- a/test/py/tests/test_ut.py +++ b/test/py/tests/test_ut.py @@ -57,19 +57,6 @@ def setup_image(cons, devnum, part_type, img_size=20, second_part=False, stdin=spec.encode('utf-8')) return fname, mnt -def copy_prepared_image(cons, devnum, fname, basename='mmc'): - """Use a prepared image since we cannot create one - - Args: - cons (ConsoleBase): Console touse - devnum (int): device number - fname (str): Filename of MMC image - basename (str): Base name to use in the filename, e.g. 'mmc' - """ - infname = os.path.join(cons.config.source_dir, - f'test/py/tests/bootstd/{basename}{devnum}.img.xz') - u_boot_utils.run_and_log(cons, ['sh', '-c', f'xz -dc {infname} >{fname}']) - def setup_bootmenu_image(cons): """Create a 20MB disk image with a single ext4 partition @@ -78,7 +65,6 @@ def setup_bootmenu_image(cons): mmc_dev = 4 fname, mnt = setup_image(cons, mmc_dev, 0x83) - complete = False script = '''# DO NOT EDIT THIS FILE # # Please edit /boot/armbianEnv.txt to set supported parameters @@ -187,19 +173,14 @@ booti ${kernel_addr_r} ${ramdisk_addr_r} ${fdt_addr_r} 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'dd if={fsfile} of={fname} bs=1M seek=1') - complete = True 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: - copy_prepared_image(cons, mmc_dev, fname) - def setup_bootflow_image(cons): """Create a 20MB disk image with a single FAT partition""" mmc_dev = 1 fname, mnt = setup_image(cons, mmc_dev, 0xc, second_part=True) - complete = False 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' @@ -244,11 +225,8 @@ label Fedora-Workstation-armhfp-31-1.9 (5.3.7-301.fc31.armv7hl) 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, f'dd if={fsfile} of={fname} bs=1M seek=1') - complete = True 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: - copy_prepared_image(cons, mmc_dev, fname) def setup_cros_image(cons): """Create a 20MB disk image with ChromiumOS partitions""" @@ -520,7 +498,6 @@ def setup_efi_image(cons): fname, mnt = setup_image(cons, devnum, 0xc, second_part=True, basename=basename) - complete = False efi_dir = os.path.join(mnt, 'EFI') mkdir_cond(efi_dir) bootdir = os.path.join(efi_dir, 'BOOT') @@ -536,14 +513,9 @@ def setup_efi_image(cons): 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, f'dd if={fsfile} of={fname} bs=1M seek=1') - complete = True 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: - copy_prepared_image(cons, devnum, fname, basename) - - @pytest.mark.buildconfigspec('cmd_bootflow') @pytest.mark.buildconfigspec('sandbox') def test_ut_dm_init_bootstd(u_boot_console): -- cgit v1.2.3