diff options
author | Marek Vasut <marex@denx.de> | 2025-03-17 04:12:42 +0100 |
---|---|---|
committer | Tom Rini <trini@konsulko.com> | 2025-04-02 20:00:59 -0600 |
commit | 6592425c6d7e4e010f3de88bc8ced7163e4f12e2 (patch) | |
tree | 1e6245f6a7657633ff60f37e7c6fa4c45318d72b /test/py/tests/test_fs/conftest.py | |
parent | fa4c9826e222136b9257247bbbb64408437d1906 (diff) |
test_fs: Allow testing FS_GENERIC
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 <marex@denx.de>
Diffstat (limited to 'test/py/tests/test_fs/conftest.py')
-rw-r--r-- | test/py/tests/test_fs/conftest.py | 40 |
1 files changed, 32 insertions, 8 deletions
diff --git a/test/py/tests/test_fs/conftest.py b/test/py/tests/test_fs/conftest.py index 47a584ffe7c..691bdf41ede 100644 --- a/test/py/tests/test_fs/conftest.py +++ b/test/py/tests/test_fs/conftest.py @@ -11,11 +11,11 @@ from fstest_defs import * # pylint: disable=E0611 from tests import fs_helper -supported_fs_basic = ['fat16', 'fat32', 'ext4'] -supported_fs_ext = ['fat12', 'fat16', 'fat32'] +supported_fs_basic = ['fat16', 'fat32', 'ext4', 'fs_generic'] +supported_fs_ext = ['fat12', 'fat16', 'fat32', 'fs_generic'] supported_fs_fat = ['fat12', 'fat16'] -supported_fs_mkdir = ['fat12', 'fat16', 'fat32'] -supported_fs_unlink = ['fat12', 'fat16', 'fat32'] +supported_fs_mkdir = ['fat12', 'fat16', 'fat32', 'fs_generic'] +supported_fs_unlink = ['fat12', 'fat16', 'fat32', 'fs_generic'] supported_fs_symlink = ['ext4'] supported_fs_rename = ['fat12', 'fat16', 'fat32'] @@ -108,6 +108,22 @@ def pytest_generate_tests(metafunc): # # Helper functions # +def fstype_to_prefix(fs_type): + """Convert a file system type to an U-Boot command prefix + + Args: + fs_type: File system type. + + Return: + A corresponding command prefix for file system type. + """ + if fs_type == 'fs_generic': + return '' + elif re.match('fat', fs_type): + return 'fat' + else: + return fs_type + def fstype_to_ubname(fs_type): """Convert a file system type to an U-Boot specific string @@ -141,6 +157,8 @@ def check_ubconfig(config, fs_type): """ if not config.buildconfig.get('config_cmd_%s' % fs_type, None): pytest.skip('.config feature "CMD_%s" not enabled' % fs_type.upper()) + if fs_type == 'fs_generic': + return if not config.buildconfig.get('config_%s_write' % fs_type, None): pytest.skip('.config feature "%s_WRITE" not enabled' % fs_type.upper()) @@ -178,6 +196,8 @@ def fs_obj_basic(request, u_boot_config): volume file name and a list of MD5 hashes. """ fs_type = request.param + fs_cmd_prefix = fstype_to_prefix(fs_type) + fs_cmd_write = 'save' if fs_type == 'fs_generic' else 'write' fs_img = '' fs_ubtype = fstype_to_ubname(fs_type) @@ -267,7 +287,7 @@ def fs_obj_basic(request, u_boot_config): pytest.skip('Setup failed for filesystem: ' + fs_type + '. {}'.format(err)) return else: - yield [fs_ubtype, fs_img, md5val] + yield [fs_ubtype, fs_cmd_prefix, fs_cmd_write, fs_img, md5val] finally: call('rm -rf %s' % scratch_dir, shell=True) call('rm -f %s' % fs_img, shell=True) @@ -288,6 +308,8 @@ def fs_obj_ext(request, u_boot_config): volume file name and a list of MD5 hashes. """ fs_type = request.param + fs_cmd_prefix = fstype_to_prefix(fs_type) + fs_cmd_write = 'save' if fs_type == 'fs_generic' else 'write' fs_img = '' fs_ubtype = fstype_to_ubname(fs_type) @@ -357,7 +379,7 @@ def fs_obj_ext(request, u_boot_config): pytest.skip('Setup failed for filesystem: ' + fs_type) return else: - yield [fs_ubtype, fs_img, md5val] + yield [fs_ubtype, fs_cmd_prefix, fs_cmd_write, fs_img, md5val] finally: call('rm -rf %s' % scratch_dir, shell=True) call('rm -f %s' % fs_img, shell=True) @@ -378,6 +400,7 @@ def fs_obj_mkdir(request, u_boot_config): volume file name. """ fs_type = request.param + fs_cmd_prefix = fstype_to_prefix(fs_type) fs_img = '' fs_ubtype = fstype_to_ubname(fs_type) @@ -390,7 +413,7 @@ def fs_obj_mkdir(request, u_boot_config): pytest.skip('Setup failed for filesystem: ' + fs_type) return else: - yield [fs_ubtype, fs_img] + yield [fs_ubtype, fs_cmd_prefix, fs_img] call('rm -f %s' % fs_img, shell=True) # @@ -409,6 +432,7 @@ def fs_obj_unlink(request, u_boot_config): volume file name. """ fs_type = request.param + fs_cmd_prefix = fstype_to_prefix(fs_type) fs_img = '' fs_ubtype = fstype_to_ubname(fs_type) @@ -456,7 +480,7 @@ def fs_obj_unlink(request, u_boot_config): pytest.skip('Setup failed for filesystem: ' + fs_type) return else: - yield [fs_ubtype, fs_img] + yield [fs_ubtype, fs_cmd_prefix, fs_img] finally: call('rm -rf %s' % scratch_dir, shell=True) call('rm -f %s' % fs_img, shell=True) |