test/py: Drop assigning ubman to cons
Now that we have a shorter name, we don't need this sort of thing. Just
use ubman instead.
Signed-off-by: Simon Glass <sjg@chromium.org>
diff --git a/test/py/tests/test_ut.py b/test/py/tests/test_ut.py
index d7cf95d..ea0c43c 100644
--- a/test/py/tests/test_ut.py
+++ b/test/py/tests/test_ut.py
@@ -27,12 +27,12 @@
if not os.path.exists(dirname):
os.mkdir(dirname)
-def setup_image(cons, devnum, part_type, img_size=20, second_part=False,
+def setup_image(ubman, 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
+ ubman (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
@@ -44,26 +44,26 @@
str: Filename of MMC image
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, 'scratch')
+ fname = os.path.join(ubman.config.source_dir, f'{basename}{devnum}.img')
+ mnt = os.path.join(ubman.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'
- utils.run_and_log(cons, f'qemu-img create {fname} 20M')
- utils.run_and_log(cons, f'sfdisk {fname}',
+ utils.run_and_log(ubman, f'qemu-img create {fname} 20M')
+ utils.run_and_log(ubman, f'sfdisk {fname}',
stdin=spec.encode('utf-8'))
return fname, mnt
-def setup_bootmenu_image(cons):
+def setup_bootmenu_image(ubman):
"""Create a 20MB disk image with a single ext4 partition
This is modelled on Armbian 22.08 Jammy
"""
mmc_dev = 4
- fname, mnt = setup_image(cons, mmc_dev, 0x83)
+ fname, mnt = setup_image(ubman, mmc_dev, 0x83)
script = '''# DO NOT EDIT THIS FILE
#
@@ -146,16 +146,16 @@
with open(cmd_fname, 'w', encoding='ascii') as outf:
print(script, file=outf)
- infname = os.path.join(cons.config.source_dir,
+ infname = os.path.join(ubman.config.source_dir,
'test/py/tests/bootstd/armbian.bmp.xz')
bmp_file = os.path.join(bootdir, 'boot.bmp')
utils.run_and_log(
- cons,
+ ubman,
['sh', '-c', f'xz -dc {infname} >{bmp_file}'])
- mkimage = cons.config.build_dir + '/tools/mkimage'
+ mkimage = ubman.config.build_dir + '/tools/mkimage'
utils.run_and_log(
- cons, f'{mkimage} -C none -A arm -T script -d {cmd_fname} {scr_fname}')
+ ubman, 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)
@@ -166,20 +166,20 @@
if os.path.exists(symlink):
os.remove(symlink)
utils.run_and_log(
- cons, f'echo here {kernel} {symlink}')
+ ubman, f'echo here {kernel} {symlink}')
os.symlink(kernel, symlink)
fsfile = 'ext18M.img'
- utils.run_and_log(cons, f'fallocate -l 18M {fsfile}')
- utils.run_and_log(cons, f'mkfs.ext4 {fsfile} -d {mnt}')
- utils.run_and_log(cons, f'dd if={fsfile} of={fname} bs=1M seek=1')
- utils.run_and_log(cons, f'rm -rf {mnt}')
- utils.run_and_log(cons, f'rm -f {fsfile}')
+ 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')
+ utils.run_and_log(ubman, f'rm -rf {mnt}')
+ utils.run_and_log(ubman, f'rm -f {fsfile}')
-def setup_bootflow_image(cons):
+def setup_bootflow_image(ubman):
"""Create a 20MB disk image with a single FAT partition"""
mmc_dev = 1
- fname, mnt = setup_image(cons, mmc_dev, 0xc, second_part=True)
+ fname, mnt = setup_image(ubman, mmc_dev, 0xc, second_part=True)
vmlinux = 'vmlinuz-5.3.7-301.fc31.armv7hl'
initrd = 'initramfs-5.3.7-301.fc31.armv7hl.img'
@@ -204,12 +204,12 @@
with open(conf, 'w', encoding='ascii') as fd:
print(script, file=fd)
- inf = os.path.join(cons.config.persistent_data_dir, 'inf')
+ inf = os.path.join(ubman.config.persistent_data_dir, 'inf')
with open(inf, 'wb') as fd:
fd.write(gzip.compress(b'vmlinux'))
- mkimage = cons.config.build_dir + '/tools/mkimage'
+ mkimage = ubman.config.build_dir + '/tools/mkimage'
utils.run_and_log(
- cons, f'{mkimage} -f auto -d {inf} {os.path.join(mnt, vmlinux)}')
+ ubman, 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)
@@ -218,27 +218,27 @@
dtb_file = os.path.join(mnt, f'{dtbdir}/sandbox.dtb')
utils.run_and_log(
- cons, f'dtc -o {dtb_file}', stdin=b'/dts-v1/; / {};')
+ ubman, f'dtc -o {dtb_file}', stdin=b'/dts-v1/; / {};')
fsfile = 'vfat18M.img'
- utils.run_and_log(cons, f'fallocate -l 18M {fsfile}')
- utils.run_and_log(cons, f'mkfs.vfat {fsfile}')
- utils.run_and_log(cons, ['sh', '-c', f'mcopy -i {fsfile} {mnt}/* ::/'])
- utils.run_and_log(cons, f'dd if={fsfile} of={fname} bs=1M seek=1')
- utils.run_and_log(cons, f'rm -rf {mnt}')
- utils.run_and_log(cons, f'rm -f {fsfile}')
+ 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')
+ utils.run_and_log(ubman, f'rm -rf {mnt}')
+ utils.run_and_log(ubman, f'rm -f {fsfile}')
-def setup_cros_image(cons):
+def setup_cros_image(ubman):
"""Create a 20MB disk image with ChromiumOS partitions"""
Partition = collections.namedtuple('part', 'start,size,name')
parts = {}
disk_data = None
- def pack_kernel(cons, arch, kern, dummy):
+ def pack_kernel(ubman, arch, kern, dummy):
"""Pack a kernel containing some fake data
Args:
- cons (ConsoleBase): Console to use
+ ubman (ConsoleBase): Console to use
arch (str): Architecture to use ('x86' or 'arm')
kern (str): Filename containing kernel
dummy (str): Dummy filename to use for config and bootloader
@@ -246,10 +246,10 @@
Return:
bytes: Packed-kernel data
"""
- kern_part = os.path.join(cons.config.result_dir,
+ kern_part = os.path.join(ubman.config.result_dir,
f'kern-part-{arch}.bin')
utils.run_and_log(
- cons,
+ ubman,
f'futility vbutil_kernel --pack {kern_part} '
'--keyblock doc/chromium/files/devkeys/kernel.keyblock '
'--signprivate doc/chromium/files/devkeys/kernel_data_key.vbprivk '
@@ -275,9 +275,9 @@
disk_data = disk_data[:start] + data + disk_data[start + len(data):]
mmc_dev = 5
- fname = os.path.join(cons.config.source_dir, f'mmc{mmc_dev}.img')
- utils.run_and_log(cons, f'qemu-img create {fname} 20M')
- utils.run_and_log(cons, f'cgpt create {fname}')
+ fname = os.path.join(ubman.config.source_dir, f'mmc{mmc_dev}.img')
+ utils.run_and_log(ubman, f'qemu-img create {fname} 20M')
+ utils.run_and_log(ubman, f'cgpt create {fname}')
uuid_state = 'ebd0a0a2-b9e5-4433-87c0-68b6b72699c7'
uuid_kern = 'fe3a2a5d-4f32-41a7-b725-accc3285a309'
@@ -317,12 +317,12 @@
else:
size = int(size_str)
utils.run_and_log(
- cons,
+ ubman,
f"cgpt add -i {part['num']} -b {ptr} -s {size} -t {part['type']} {fname}")
ptr += size
- utils.run_and_log(cons, f'cgpt boot -p {fname}')
- out = utils.run_and_log(cons, f'cgpt show -q {fname}')
+ utils.run_and_log(ubman, f'cgpt boot -p {fname}')
+ out = utils.run_and_log(ubman, f'cgpt show -q {fname}')
# We expect something like this:
# 8239 2048 1 Basic data
@@ -344,14 +344,14 @@
parts[int(num)] = Partition(int(start), int(size), name)
# Set up the kernel command-line
- dummy = os.path.join(cons.config.result_dir, 'dummy.txt')
+ dummy = os.path.join(ubman.config.result_dir, 'dummy.txt')
with open(dummy, 'wb') as outf:
outf.write(b'BOOT_IMAGE=/vmlinuz-5.15.0-121-generic root=/dev/nvme0n1p1 ro quiet splash vt.handoff=7')
# For now we just use dummy kernels. This limits testing to just detecting
# a signed kernel. We could add support for the x86 data structures so that
# testing could cover getting the cmdline, setup.bin and other pieces.
- kern = os.path.join(cons.config.result_dir, 'kern.bin')
+ kern = os.path.join(ubman.config.result_dir, 'kern.bin')
with open(kern, 'wb') as outf:
outf.write(b'kernel\n')
@@ -359,15 +359,15 @@
disk_data = inf.read()
# put x86 kernel in partition 2 and arm one in partition 4
- set_part_data(2, pack_kernel(cons, 'x86', kern, dummy))
- set_part_data(4, pack_kernel(cons, 'arm', kern, dummy))
+ set_part_data(2, pack_kernel(ubman, 'x86', kern, dummy))
+ set_part_data(4, pack_kernel(ubman, 'arm', kern, dummy))
with open(fname, 'wb') as outf:
outf.write(disk_data)
return fname
-def setup_android_image(cons):
+def setup_android_image(ubman):
"""Create a 20MB disk image with Android partitions"""
Partition = collections.namedtuple('part', 'start,size,name')
parts = {}
@@ -388,9 +388,9 @@
disk_data = disk_data[:start] + data + disk_data[start + len(data):]
mmc_dev = 7
- fname = os.path.join(cons.config.source_dir, f'mmc{mmc_dev}.img')
- utils.run_and_log(cons, f'qemu-img create {fname} 20M')
- utils.run_and_log(cons, f'cgpt create {fname}')
+ fname = os.path.join(ubman.config.source_dir, f'mmc{mmc_dev}.img')
+ utils.run_and_log(ubman, f'qemu-img create {fname} 20M')
+ utils.run_and_log(ubman, f'cgpt create {fname}')
ptr = 40
@@ -413,12 +413,12 @@
else:
size = int(size_str)
utils.run_and_log(
- cons,
+ ubman,
f"cgpt add -i {part['num']} -b {ptr} -s {size} -l {part['label']} -t basicdata {fname}")
ptr += size
- utils.run_and_log(cons, f'cgpt boot -p {fname}')
- out = utils.run_and_log(cons, f'cgpt show -q {fname}')
+ utils.run_and_log(ubman, f'cgpt boot -p {fname}')
+ out = utils.run_and_log(ubman, f'cgpt show -q {fname}')
# Create a dict (indexed by partition number) containing the above info
for line in out.splitlines():
@@ -428,13 +428,13 @@
with open(fname, 'rb') as inf:
disk_data = inf.read()
- test_abootimg.AbootimgTestDiskImage(cons, 'bootv4.img', test_abootimg.boot_img_hex)
- boot_img = os.path.join(cons.config.result_dir, 'bootv4.img')
+ test_abootimg.AbootimgTestDiskImage(ubman, 'bootv4.img', test_abootimg.boot_img_hex)
+ boot_img = os.path.join(ubman.config.result_dir, 'bootv4.img')
with open(boot_img, 'rb') as inf:
set_part_data(2, inf.read())
- test_abootimg.AbootimgTestDiskImage(cons, 'vendor_boot.img', test_abootimg.vboot_img_hex)
- vendor_boot_img = os.path.join(cons.config.result_dir, 'vendor_boot.img')
+ test_abootimg.AbootimgTestDiskImage(ubman, 'vendor_boot.img', test_abootimg.vboot_img_hex)
+ vendor_boot_img = os.path.join(ubman.config.result_dir, 'vendor_boot.img')
with open(vendor_boot_img, 'rb') as inf:
set_part_data(4, inf.read())
@@ -444,9 +444,9 @@
print(f'wrote to {fname}')
mmc_dev = 8
- fname = os.path.join(cons.config.source_dir, f'mmc{mmc_dev}.img')
- utils.run_and_log(cons, f'qemu-img create {fname} 20M')
- utils.run_and_log(cons, f'cgpt create {fname}')
+ fname = os.path.join(ubman.config.source_dir, f'mmc{mmc_dev}.img')
+ utils.run_and_log(ubman, f'qemu-img create {fname} 20M')
+ utils.run_and_log(ubman, f'cgpt create {fname}')
ptr = 40
@@ -467,12 +467,12 @@
else:
size = int(size_str)
utils.run_and_log(
- cons,
+ ubman,
f"cgpt add -i {part['num']} -b {ptr} -s {size} -l {part['label']} -t basicdata {fname}")
ptr += size
- utils.run_and_log(cons, f'cgpt boot -p {fname}')
- out = utils.run_and_log(cons, f'cgpt show -q {fname}')
+ utils.run_and_log(ubman, f'cgpt boot -p {fname}')
+ out = utils.run_and_log(ubman, f'cgpt show -q {fname}')
# Create a dict (indexed by partition number) containing the above info
for line in out.splitlines():
@@ -482,8 +482,8 @@
with open(fname, 'rb') as inf:
disk_data = inf.read()
- test_abootimg.AbootimgTestDiskImage(cons, 'boot.img', test_abootimg.img_hex)
- boot_img = os.path.join(cons.config.result_dir, 'boot.img')
+ test_abootimg.AbootimgTestDiskImage(ubman, 'boot.img', test_abootimg.img_hex)
+ boot_img = os.path.join(ubman.config.result_dir, 'boot.img')
with open(boot_img, 'rb') as inf:
set_part_data(2, inf.read())
@@ -494,16 +494,16 @@
return fname
-def setup_cedit_file(cons):
+def setup_cedit_file(ubman):
"""Set up a .dtb file for use with testing expo and configuration editor"""
- infname = os.path.join(cons.config.source_dir,
+ infname = os.path.join(ubman.config.source_dir,
'test/boot/files/expo_layout.dts')
- inhname = os.path.join(cons.config.source_dir,
+ inhname = os.path.join(ubman.config.source_dir,
'test/boot/files/expo_ids.h')
- expo_tool = os.path.join(cons.config.source_dir, 'tools/expo.py')
+ expo_tool = os.path.join(ubman.config.source_dir, 'tools/expo.py')
outfname = 'cedit.dtb'
utils.run_and_log(
- cons, f'{expo_tool} -e {inhname} -l {infname} -o {outfname}')
+ ubman, f'{expo_tool} -e {inhname} -l {infname} -o {outfname}')
@pytest.mark.buildconfigspec('ut_dm')
def test_ut_dm_init(ubman):
@@ -541,30 +541,30 @@
fh.write(data)
-def setup_efi_image(cons):
+def setup_efi_image(ubman):
"""Create a 20MB disk image with an EFI app on it"""
devnum = 1
basename = 'flash'
- fname, mnt = setup_image(cons, devnum, 0xc, second_part=True,
+ fname, mnt = setup_image(ubman, devnum, 0xc, second_part=True,
basename=basename)
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,
+ efi_src = os.path.join(ubman.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'
- utils.run_and_log(cons, f'fallocate -l 18M {fsfile}')
- utils.run_and_log(cons, f'mkfs.vfat {fsfile}')
- utils.run_and_log(cons, ['sh', '-c', f'mcopy -vs -i {fsfile} {mnt}/* ::/'])
- utils.run_and_log(cons, f'dd if={fsfile} of={fname} bs=1M seek=1')
- utils.run_and_log(cons, f'rm -rf {mnt}')
- utils.run_and_log(cons, f'rm -f {fsfile}')
+ 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')
+ utils.run_and_log(ubman, f'rm -rf {mnt}')
+ utils.run_and_log(ubman, f'rm -f {fsfile}')
@pytest.mark.buildconfigspec('cmd_bootflow')
@pytest.mark.buildconfigspec('sandbox')