mirror of
https://github.com/u-boot/u-boot.git
synced 2025-04-30 08:07:59 +00:00
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 <sjg@chromium.org> Signed-off-by: Richard Weinberger <richard@nod.at>
This commit is contained in:
parent
c6504372c6
commit
0a4c69b1f0
1 changed files with 6 additions and 4 deletions
|
@ -28,13 +28,15 @@ def mkdir_cond(dirname):
|
||||||
if not os.path.exists(dirname):
|
if not os.path.exists(dirname):
|
||||||
os.mkdir(dirname)
|
os.mkdir(dirname)
|
||||||
|
|
||||||
def setup_image(cons, devnum, part_type, second_part=False, basename='mmc'):
|
def setup_image(cons, devnum, part_type, img_size=20, second_part=False,
|
||||||
"""Create a 20MB disk image with a single partition
|
basename='mmc'):
|
||||||
|
"""Create a disk image with a single partition
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
cons (ConsoleBase): Console to use
|
cons (ConsoleBase): Console to use
|
||||||
devnum (int): Device number to use, e.g. 1
|
devnum (int): Device number to use, e.g. 1
|
||||||
part_type (int): Partition type, e.g. 0xc for FAT32
|
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
|
second_part (bool): True to contain a small second partition
|
||||||
basename (str): Base name to use in the filename, e.g. 'mmc'
|
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')
|
mnt = os.path.join(cons.config.persistent_data_dir, 'mnt')
|
||||||
mkdir_cond(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:
|
if second_part:
|
||||||
spec += '\ntype=c'
|
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}',
|
u_boot_utils.run_and_log(cons, f'sudo sfdisk {fname}',
|
||||||
stdin=spec.encode('utf-8'))
|
stdin=spec.encode('utf-8'))
|
||||||
return fname, mnt
|
return fname, mnt
|
||||||
|
|
Loading…
Add table
Reference in a new issue