summaryrefslogtreecommitdiff
path: root/test/py/tests/fs_helper.py
AgeCommit message (Collapse)Author
2026-03-23test: Convert fs_helper to use a classSimon Glass
Create a class around mk_fs() (and later setup_image()) to handle the common tasks of image creation. Many callers of fs_helper.mk_fs() create their own scratch directories while users of fs_helper.setup_image() rely on one being returned. Unify this by adding 'srcdir' as a field while converting to a class. The class delegates to the existing mk_fs() function for the actual filesystem creation, adding lifecycle management for scratch directories and the image file. Signed-off-by: Simon Glass <[email protected]> Reviewed-by: Tom Rini <[email protected]>
2026-03-23test: fs_helper: Drop the size_gran argumentSimon Glass
Nothing uses this argument, so make it a constant for now. Signed-off-by: Simon Glass <[email protected]> Reviewed-by: Christian Taedcke <[email protected]>
2026-03-23test: Update comment for fs_helper.setup_image()Simon Glass
This function actually allows creating two partitions now, so update its comment to match that. Signed-off-by: Simon Glass <[email protected]> Reviewed-by: Tom Rini <[email protected]>
2026-03-23test: fs_helper: Add a quiet flag to mk_fs()Simon Glass
In many cases callers only want to see warnings and errors from the filesystem-creation tools, not their normal output. Add a quiet parameter to mk_fs() that suppresses the output of mkfs and switches mcopy from verbose to quiet mode. Signed-off-by: Simon Glass <[email protected]> Reviewed-by: Tom Rini <[email protected]>
2026-03-23test: fs_helper: Allow passing the image filenameSimon Glass
The mk_fs() function always generates its own image filename from the prefix and fs_type. Some callers need to specify a custom leaf name while still keeping the image under the persistent-data directory. Add an fs_img parameter that accepts a leaf filename. When provided, it is joined with persistent_data_dir instead of the default name. Signed-off-by: Simon Glass <[email protected]> Reviewed-by: Tom Rini <[email protected]>
2025-04-08Merge patch series "Improve pytest runtime"Tom Rini
Tom Rini <[email protected]> says: One thing that Simon Glass has noted is that our pytest run time keeps getting longer. Looking at: https://source.denx.de/u-boot/u-boot/-/pipelines/25011/test_report?job_name=sandbox%20test.py%3A%20%5Bfast%20amd64%5D we can see that some of the longest running tests are a little puzzling. It turns out that we have two ways of making filesystem images without requiring root access and one of them is significantly slower than the other. This series changes us from using virt-make-fs to only using the mk_fs helper that currently resides in test_ut.py which uses standard userspace tools. The final result can be seen at: https://source.denx.de/u-boot/u-boot/-/pipelines/25015/test_report?job_name=sandbox%20test.py%3A%20%5Bfast%20amd64%5D and the tests changed here now run much quicker. Link: https://lore.kernel.org/r/[email protected]
2025-04-08test/py: Fix a problem with setup_imageTom Rini
While we can be passed an image size to use, we always called qemu-img with 20M as the size. Fix this by using the size parameter. Signed-off-by: Tom Rini <[email protected]>
2025-04-08test/py/tests: Move "setup_image" from test_ut.py to fs_helper.pyTom Rini
The generic function in test_ut.py to create a disk image with partition table can be useful outside of test_ut.py so move it to be available more clearly. To make this a bit more easily used library function, make use of check_call directly rather than calling things though u_boot_utils. In turn, to more easily handle stdin here, use the shell "printf" utility to pass sfdisk the specification to create as we do not have an actual file descriptor to use here. Signed-off-by: Tom Rini <[email protected]>
2025-04-02Merge patch series "fs: exfat: Add exfat port based on exfat-fuse"Tom Rini
Marek Vasut <[email protected]> says: Import exfat-fuse libexfat, add U-Boot filesystem layer porting glue code and wire exfat support into generic filesystem support code. This adds exfat support to U-Boot. Fill in generic filesystem interface for mkdir and rm commands. Make filesystem tests test the generic interface as well as exfat, to make sure this code does not fall apart. Link: https://github.com/relan/exfat/commits/0b41c6d3560d ("CI: bump FreeBSD to 13.1.") Link: https://lore.kernel.org/r/[email protected]
2025-04-02test_fs: Add exfat testsMarek Vasut
Add tests for the exfat filesystem. These tests are largely an extension of the FS_GENERIC tests with the following notable exceptions. The filesystem image for exfat tests is generated using combination of exfatprogs mkfs.exfat and python fattools. The fattols are capable of generating exfat filesystem images too, but this is not used, the fattools are only used as a replacement for dosfstools 'mcopy' and 'mdir', which are used to insert files and directories into existing fatfs images and list existing fatfs images respectively, without the need for superuser access to mount such images. The exfat filesystem has no filesystem specific command, there is only the generic filesystem command interface, therefore check_ubconfig() has to special case exfat and skip check for CONFIG_CMD_EXFAT and instead check for CONFIG_FS_EXFAT. Signed-off-by: Marek Vasut <[email protected]>
2025-04-02test_fs: Allow testing FS_GENERICMarek Vasut
The generic filesystem interface was so far untested. The interface is similar to the FS specific interfaces with FS specific prefixes, like ext4ls, fatmkdir, ... but it does not have any prefixes, i.e. it provides plain ls, mkdir, ... commands. Extend the test parameters to include 'fs_cmd_prefix' and optionally 'fs_cmd_write' parameters. The 'fs_cmd_prefix' allow specifying the filesystem specific command prefix, like 'ext4' in 'ext4ls'. The 'fs_cmd_write' allows selecting between 'write'/'save' command name for storing files into the filesystem, see last paragraph. Introduce new 'fs_generic' fs_type which is used to parametrize existing tests and run them without any prefixes if detected, thus testing the generic filesystem interface. Use the fatfs as the backing store for the generic FS tests. The check_ubconfig needs to be slightly adjusted to avoid test for CMD_FS_GENERIC_WRITE which does not exist separately from CMD_FS_GENERIC. The CMD_FS_GENERIC does not provide generic 'write' command, instead the generic equivalent command is called 'save' . Add simple ternary oeprator to use 'save' command for CMD_FS_GENERIC tests and '..write' commands for filesystem specific tests. Enable generic filesystem tests for basic/extended/mkdir/unlink tests. Signed-off-by: Marek Vasut <[email protected]>
2025-03-30test: use truncate in mk_fs()Heinrich Schuchardt
While the dd command actually writes to the block device the truncate command only updates the metadata (at least on ext4). This is faster and reduces wear on the block device. Signed-off-by: Heinrich Schuchardt <[email protected]>
2024-11-29test_fs: Allow running unprivilegedRichard Weinberger
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 <[email protected]> Signed-off-by: Simon Glass <[email protected]> Tested-by: Mattijs Korpershoek <[email protected]>
2023-11-28test: Add size granularity parameter to mk_fsChristian Taedcke
Without this commit it is only possible to create filesystem images with a size granularity of 1MB. This commit adds the option to create file systems with different sizes, e.g 8.5MB. Signed-off-by: Christian Taedcke <[email protected]>
2023-11-28test: Add support to create a fat12 fsChristian Taedcke
This enables to implement tests for fat12 filesystem. Signed-off-by: Christian Taedcke <[email protected]>
2023-08-25test: Move 1MB.fat32.img and 2MB.ext2.imgSimon Glass
These are currently created in the source directory, which is not ideal. Move them to the persistent-data directory instead. Update the test so skip validating the filename, since it now includes a full path. Signed-off-by: Simon Glass <[email protected]>
2022-11-07dm: Add tests for the sandbox host driverSimon Glass
Add some unit tests for this. Signed-off-by: Simon Glass <[email protected]>
2022-11-07test: Correct pylint warnings in fs_helperSimon Glass
Tidy this up so that pylint is happy. Use hex for the 1MB size and make sure it is not a floating-point value. Add a little main program to allow the code to be tried out, since at present is only called from a long-running test. Signed-off-by: Simon Glass <[email protected]>
2022-11-07test: Split out mk_fs function into a helperSimon Glass
This function is useful for other tests. Move it into common code. Signed-off-by: Simon Glass <[email protected]>