From patchwork Mon Dec 29 16:05:59 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1099 Return-Path: X-Original-To: u-boot-concept@u-boot.org Delivered-To: u-boot-concept@u-boot.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1767024391; bh=GWobDRP2atI2tNU1VyJjIa8mvc5Kzc3enR5wWD3cO/A=; h=From:To:Date:In-Reply-To:References:CC:Subject:List-Id: List-Archive:List-Help:List-Owner:List-Post:List-Subscribe: List-Unsubscribe:From; b=V89u9byqpGCZM/vlqRH6lv0oQf7EeqOWrDMlJM+mZ7mrGBWkE7qP749m5pUcDbvCb OBuMa/K83LfIPIAS2LZMxmdhHC4C6u495phlokSwUeKEtrQdHrJhjKxLt01gdepVwJ U4rVtJYSFL8gqWXKDUA/f2KPEFXKReEptZUiB0DB6KOISwM2F/rTo91IwTNNJNIhPx U7LlB+2M0C3sAMDnc08/t4aIJGAaWtPY7kLcjT8aY9tqQUzBVvY45qWktRek/CZRJN tO8pSqcutweuozVewIZ5xGJlonUDYvKTWF0zmw748Rz3Bfk49LZDXu0jkvQdJXJKTy PMd9borQnTUfQ== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 9FD2768F3B for ; Mon, 29 Dec 2025 09:06:31 -0700 (MST) X-Virus-Scanned: Debian amavis at Received: from mail.u-boot.org ([127.0.0.1]) by localhost (mail.u-boot.org [127.0.0.1]) (amavis, port 10024) with ESMTP id lwAyGqtpldja for ; Mon, 29 Dec 2025 09:06:31 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1767024391; bh=GWobDRP2atI2tNU1VyJjIa8mvc5Kzc3enR5wWD3cO/A=; h=From:To:Date:In-Reply-To:References:CC:Subject:List-Id: List-Archive:List-Help:List-Owner:List-Post:List-Subscribe: List-Unsubscribe:From; b=V89u9byqpGCZM/vlqRH6lv0oQf7EeqOWrDMlJM+mZ7mrGBWkE7qP749m5pUcDbvCb OBuMa/K83LfIPIAS2LZMxmdhHC4C6u495phlokSwUeKEtrQdHrJhjKxLt01gdepVwJ U4rVtJYSFL8gqWXKDUA/f2KPEFXKReEptZUiB0DB6KOISwM2F/rTo91IwTNNJNIhPx U7LlB+2M0C3sAMDnc08/t4aIJGAaWtPY7kLcjT8aY9tqQUzBVvY45qWktRek/CZRJN tO8pSqcutweuozVewIZ5xGJlonUDYvKTWF0zmw748Rz3Bfk49LZDXu0jkvQdJXJKTy PMd9borQnTUfQ== Received: from mail.u-boot.org (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 8E36168F2D for ; Mon, 29 Dec 2025 09:06:31 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1767024390; bh=Nj7M7RnPksUX2q0Hyz4i0Dsg4bBRlu6De0HYvjhpNwo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=IjnFNd3ZVIJz7EUjnHlvWuXkbmEPDSEKClmoekTTnou039WE3J+hRUKsrXOnBPbjW nAv4vzi6AJSYlWaoywn5OmTptaqTf8VHqEO2b/Ge8tEWY0j2M1jAZkKdNHXV7kA/vK mWcf0lg+8S90Xcvx3SHhLlkrZ1dWpdiaHrEit6Nu9/dLjXulR9QHN7Wjmctf//6RTC 5dJjVZwb6K73F8HAEKGeqG3rXHu0AlgX4qdOYh80VJwZuuDbzEHxxyPimyR694hA1S nY2aNDK3dIpBuEQKg6/rFa6uUikPemnsT1vCDk4dpmvh6ZvbIqrWDT2oyCuVm7L5GK hlwsSuSzn7gtw== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 19DB368B78; Mon, 29 Dec 2025 09:06:30 -0700 (MST) X-Virus-Scanned: Debian amavis at Received: from mail.u-boot.org ([127.0.0.1]) by localhost (mail.u-boot.org [127.0.0.1]) (amavis, port 10026) with ESMTP id nD_N6DaUVqu5; Mon, 29 Dec 2025 09:06:30 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1767024385; bh=QQknSc698mkdtQpgng18qaxi4LDMmzG5gcssvvMuBxY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Vn/P/okRe32xZyXUkdP7+2k/RLzcWMnnwpmOjmNFNMBcHLyNWfKEJacgXj+BLhm8R /+Q3Nh/DJyyiGtR6fdHXbiccO20kWM7JxeprKBc7Lp3EBY15qe1vezjgwPzHT415zk eLyC8Lnqa0mCetLg8FkFZiUM9ZrmKTUPVqfbbK6ZhjT0+8msDwINTrrFuDN2X8ESLO qP5bikORXAXvTealhhHQYgbA5Wr9DPkccFHv0WXiTLeRKYlEH+8lbgUsvCIYTxkRKa gSwMrQLHEA+v4Ty3UaE1t56XxOcb11/VkEHUraWSLl+haOyVmssMjHUjOuDBaV4qfi OiDdz93vggutQ== Received: from u-boot.org (unknown [73.34.74.121]) by mail.u-boot.org (Postfix) with ESMTPSA id 79D6564E2A; Mon, 29 Dec 2025 09:06:25 -0700 (MST) From: Simon Glass To: U-Boot Concept Date: Mon, 29 Dec 2025 09:05:59 -0700 Message-ID: <20251229160611.3899708-2-sjg@u-boot.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20251229160611.3899708-1-sjg@u-boot.org> References: <20251229160611.3899708-1-sjg@u-boot.org> MIME-Version: 1.0 Message-ID-Hash: T5MD3OHQ5LXQ36UXL3HJFZESDPFY4GL5 X-Message-ID-Hash: T5MD3OHQ5LXQ36UXL3HJFZESDPFY4GL5 X-MailFrom: sjg@u-boot.org X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; loop; banned-address; emergency; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header CC: Heinrich Schuchardt , Simon Glass , "Claude Opus 4 . 5" X-Mailman-Version: 3.3.10 Precedence: list Subject: [Concept] [PATCH 1/9] test: Move disk images to persistent-data directory List-Id: Discussion and patches related to U-Boot Concept Archived-At: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: From: Simon Glass 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 Signed-off-by: Simon Glass --- drivers/mmc/sandbox_mmc.c | 13 +++++++++++-- drivers/scsi/sandbox_scsi.c | 13 +++++++++++-- drivers/usb/emul/sandbox_flash.c | 12 ++++++++++-- test/py/img/armbian.py | 2 +- test/py/img/common.py | 2 +- test/py/img/efi.py | 2 +- test/py/tests/test_ut.py | 11 +++++++---- 7 files changed, 42 insertions(+), 13 deletions(-) diff --git a/drivers/mmc/sandbox_mmc.c b/drivers/mmc/sandbox_mmc.c index f49cb4b146a..74427db7e06 100644 --- a/drivers/mmc/sandbox_mmc.c +++ b/drivers/mmc/sandbox_mmc.c @@ -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; diff --git a/drivers/scsi/sandbox_scsi.c b/drivers/scsi/sandbox_scsi.c index 3c451313109..97afeddc2e9 100644 --- a/drivers/scsi/sandbox_scsi.c +++ b/drivers/scsi/sandbox_scsi.c @@ -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); } diff --git a/drivers/usb/emul/sandbox_flash.c b/drivers/usb/emul/sandbox_flash.c index 25d968e91c7..82aa7062865 100644 --- a/drivers/usb/emul/sandbox_flash.c +++ b/drivers/usb/emul/sandbox_flash.c @@ -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); } diff --git a/test/py/img/armbian.py b/test/py/img/armbian.py index e1ae9b0aae9..db7fb43ddf6 100644 --- a/test/py/img/armbian.py +++ b/test/py/img/armbian.py @@ -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() diff --git a/test/py/img/common.py b/test/py/img/common.py index 547066b24a5..25edc84944e 100644 --- a/test/py/img/common.py +++ b/test/py/img/common.py @@ -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, diff --git a/test/py/img/efi.py b/test/py/img/efi.py index 8239b4c247f..4cb55c957ec 100644 --- a/test/py/img/efi.py +++ b/test/py/img/efi.py @@ -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() diff --git a/test/py/tests/test_ut.py b/test/py/tests/test_ut.py index b9ba240c848..70a748a31f9 100644 --- a/test/py/tests/test_ut.py +++ b/test/py/tests/test_ut.py @@ -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)