test: Move disk images to persistent-data directory
It is annoying to have disk images in the source directory since it clutters up the working space. Remove cur_dir=True from DiskHelper calls so disk images are written to the persistent-data directory instead. Move scsi.img too (used by the bootstd tests) and mmc6.img (used by the MBR tests. Add a few comments as to where the images are used. This keeps the source tree clean and puts disk images in the same place as other test data. Co-developed-by: Claude Opus 4.5 <noreply@anthropic.com> Signed-off-by: Simon Glass <simon.glass@canonical.com>
This commit is contained in:
@@ -170,11 +170,20 @@ static int sandbox_mmc_probe(struct udevice *dev)
|
||||
int ret;
|
||||
|
||||
if (plat->fname) {
|
||||
ret = os_map_file(plat->fname, OS_O_RDWR | OS_O_CREAT,
|
||||
const char *fname = plat->fname;
|
||||
char buf[256];
|
||||
|
||||
/*
|
||||
* Try persistent data directory first, then fall back to the
|
||||
* filename as given (for absolute paths or current directory)
|
||||
*/
|
||||
if (!os_persistent_file(buf, sizeof(buf), plat->fname))
|
||||
fname = buf;
|
||||
ret = os_map_file(fname, OS_O_RDWR | OS_O_CREAT,
|
||||
(void **)&priv->buf, &priv->size);
|
||||
if (ret) {
|
||||
log_err("%s: Unable to map file '%s'\n", dev->name,
|
||||
plat->fname);
|
||||
fname);
|
||||
return ret;
|
||||
}
|
||||
priv->csize = priv->size / SIZE_MULTIPLE - 1;
|
||||
|
||||
@@ -104,9 +104,18 @@ static int sandbox_scsi_probe(struct udevice *dev)
|
||||
info->block_size = SANDBOX_SCSI_BLOCK_LEN;
|
||||
|
||||
if (priv->pathname) {
|
||||
priv->fd = os_open(priv->pathname, OS_O_RDONLY);
|
||||
const char *pathname = priv->pathname;
|
||||
char buf[256];
|
||||
|
||||
/*
|
||||
* Try persistent data directory first, then fall back to the
|
||||
* pathname as given (for absolute paths or current directory)
|
||||
*/
|
||||
if (!os_persistent_file(buf, sizeof(buf), priv->pathname))
|
||||
pathname = buf;
|
||||
priv->fd = os_open(pathname, OS_O_RDONLY);
|
||||
if (priv->fd >= 0) {
|
||||
ret = os_get_filesize(priv->pathname, &info->file_size);
|
||||
ret = os_get_filesize(pathname, &info->file_size);
|
||||
if (ret)
|
||||
return log_msg_ret("sz", ret);
|
||||
}
|
||||
|
||||
@@ -339,11 +339,19 @@ static int sandbox_flash_probe(struct udevice *dev)
|
||||
struct sandbox_flash_plat *plat = dev_get_plat(dev);
|
||||
struct sandbox_flash_priv *priv = dev_get_priv(dev);
|
||||
struct scsi_emul_info *info = &priv->eminfo;
|
||||
const char *pathname = plat->pathname;
|
||||
char buf[256];
|
||||
int ret;
|
||||
|
||||
priv->fd = os_open(plat->pathname, OS_O_RDWR);
|
||||
/*
|
||||
* Try persistent data directory first, then fall back to the
|
||||
* pathname as given (for absolute paths or current directory)
|
||||
*/
|
||||
if (!os_persistent_file(buf, sizeof(buf), plat->pathname))
|
||||
pathname = buf;
|
||||
priv->fd = os_open(pathname, OS_O_RDWR);
|
||||
if (priv->fd >= 0) {
|
||||
ret = os_get_filesize(plat->pathname, &info->file_size);
|
||||
ret = os_get_filesize(pathname, &info->file_size);
|
||||
if (ret)
|
||||
return log_msg_ret("sz", ret);
|
||||
}
|
||||
|
||||
@@ -126,7 +126,7 @@ booti ${kernel_addr_r} ${ramdisk_addr_r} ${fdt_addr_r}
|
||||
utils.run_and_log_no_ubman(log, f'echo here {kernel} {symlink}')
|
||||
os.symlink(kernel, symlink)
|
||||
fsh.mk_fs()
|
||||
img = DiskHelper(config, mmc_dev, 'mmc', True)
|
||||
img = DiskHelper(config, mmc_dev, 'mmc')
|
||||
img.add_fs(fsh, DiskHelper.EXT4)
|
||||
img.create()
|
||||
fsh.cleanup()
|
||||
|
||||
@@ -84,7 +84,7 @@ def setup_extlinux_image(config, log, devnum, basename, vmlinux, initrd, dtbdir,
|
||||
|
||||
fsh.mk_fs()
|
||||
|
||||
img = DiskHelper(config, devnum, basename, True)
|
||||
img = DiskHelper(config, devnum, basename)
|
||||
img.add_fs(fsh, DiskHelper.VFAT, bootable=True)
|
||||
|
||||
ext4 = FsHelper(config, 'ext4', max(1, part2_size - 30), prefix=basename,
|
||||
|
||||
@@ -31,7 +31,7 @@ def setup_efi_image(config):
|
||||
|
||||
fsh.mk_fs()
|
||||
|
||||
img = DiskHelper(config, devnum, 'flash', True)
|
||||
img = DiskHelper(config, devnum, 'flash')
|
||||
img.add_fs(fsh, DiskHelper.VFAT)
|
||||
img.create()
|
||||
fsh.cleanup()
|
||||
|
||||
@@ -34,7 +34,8 @@ from img.localboot import setup_localboot_image
|
||||
def test_ut_dm_init(ubman):
|
||||
"""Initialize data for ut dm tests."""
|
||||
|
||||
fn = ubman.config.source_dir + '/testflash.bin'
|
||||
# This is used by flash-stick@0 in test.py
|
||||
fn = ubman.config.persistent_data_dir + '/testflash.bin'
|
||||
if not os.path.exists(fn):
|
||||
data = b'this is a test'
|
||||
data += b'\x00' * ((4 * 1024 * 1024) - len(data))
|
||||
@@ -47,8 +48,8 @@ def test_ut_dm_init(ubman):
|
||||
with open(fn, 'wb') as fh:
|
||||
fh.write(data)
|
||||
|
||||
# Create a file with a single partition
|
||||
fn = ubman.config.source_dir + '/scsi.img'
|
||||
# Create a file with a single partition (used by /scsi in test.dts) */
|
||||
fn = ubman.config.persistent_data_dir + '/scsi.img'
|
||||
if not os.path.exists(fn):
|
||||
data = b'\x00' * (2 * 1024 * 1024)
|
||||
with open(fn, 'wb') as fh:
|
||||
@@ -56,11 +57,13 @@ def test_ut_dm_init(ubman):
|
||||
utils.run_and_log(
|
||||
ubman, f'sfdisk {fn}', stdin=b'type=83')
|
||||
|
||||
# These two are used by test/dm/host.c
|
||||
FsHelper(ubman.config, 'ext2', 2, '2MB').mk_fs()
|
||||
FsHelper(ubman.config, 'fat32', 1, '1MB').mk_fs()
|
||||
|
||||
# This is used by test/cmd/mbr.c
|
||||
mmc_dev = 6
|
||||
fn = os.path.join(ubman.config.source_dir, f'mmc{mmc_dev}.img')
|
||||
fn = os.path.join(ubman.config.persistent_data_dir, f'mmc{mmc_dev}.img')
|
||||
data = b'\x00' * (12 * 1024 * 1024)
|
||||
with open(fn, 'wb') as fh:
|
||||
fh.write(data)
|
||||
|
||||
Reference in New Issue
Block a user