summaryrefslogtreecommitdiff
path: root/test/py/tests/test_fs/test_mkdir.py
diff options
context:
space:
mode:
authorMarek Vasut <marex@denx.de>2025-03-17 04:12:42 +0100
committerTom Rini <trini@konsulko.com>2025-04-02 20:00:59 -0600
commit6592425c6d7e4e010f3de88bc8ced7163e4f12e2 (patch)
tree1e6245f6a7657633ff60f37e7c6fa4c45318d72b /test/py/tests/test_fs/test_mkdir.py
parentfa4c9826e222136b9257247bbbb64408437d1906 (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/test_mkdir.py')
-rw-r--r--test/py/tests/test_fs/test_mkdir.py42
1 files changed, 21 insertions, 21 deletions
diff --git a/test/py/tests/test_fs/test_mkdir.py b/test/py/tests/test_fs/test_mkdir.py
index df680a87d57..1578c3cba3a 100644
--- a/test/py/tests/test_fs/test_mkdir.py
+++ b/test/py/tests/test_fs/test_mkdir.py
@@ -18,16 +18,16 @@ class TestMkdir(object):
"""
Test Case 1 - create a directory under a root
"""
- fs_type,fs_img = fs_obj_mkdir
+ fs_type,fs_cmd_prefix,fs_img = fs_obj_mkdir
with ubman.log.section('Test Case 1 - mkdir'):
output = ubman.run_command_list([
'host bind 0 %s' % fs_img,
- '%smkdir host 0:0 dir1' % fs_type,
- '%sls host 0:0 /' % fs_type])
+ '%smkdir host 0:0 dir1' % fs_cmd_prefix,
+ '%sls host 0:0 /' % fs_cmd_prefix])
assert('dir1/' in ''.join(output))
output = ubman.run_command(
- '%sls host 0:0 dir1' % fs_type)
+ '%sls host 0:0 dir1' % fs_cmd_prefix)
assert('./' in output)
assert('../' in output)
assert_fs_integrity(fs_type, fs_img)
@@ -37,16 +37,16 @@ class TestMkdir(object):
"""
Test Case 2 - create a directory under a sub-directory
"""
- fs_type,fs_img = fs_obj_mkdir
+ fs_type,fs_cmd_prefix,fs_img = fs_obj_mkdir
with ubman.log.section('Test Case 2 - mkdir (sub-sub directory)'):
output = ubman.run_command_list([
'host bind 0 %s' % fs_img,
- '%smkdir host 0:0 dir1/dir2' % fs_type,
- '%sls host 0:0 dir1' % fs_type])
+ '%smkdir host 0:0 dir1/dir2' % fs_cmd_prefix,
+ '%sls host 0:0 dir1' % fs_cmd_prefix])
assert('dir2/' in ''.join(output))
output = ubman.run_command(
- '%sls host 0:0 dir1/dir2' % fs_type)
+ '%sls host 0:0 dir1/dir2' % fs_cmd_prefix)
assert('./' in output)
assert('../' in output)
assert_fs_integrity(fs_type, fs_img)
@@ -56,11 +56,11 @@ class TestMkdir(object):
Test Case 3 - trying to create a directory with a non-existing
path should fail
"""
- fs_type,fs_img = fs_obj_mkdir
+ fs_type,fs_cmd_prefix,fs_img = fs_obj_mkdir
with ubman.log.section('Test Case 3 - mkdir (non-existing path)'):
output = ubman.run_command_list([
'host bind 0 %s' % fs_img,
- '%smkdir host 0:0 none/dir3' % fs_type])
+ '%smkdir host 0:0 none/dir3' % fs_cmd_prefix])
assert('Unable to create a directory' in ''.join(output))
assert_fs_integrity(fs_type, fs_img)
@@ -68,11 +68,11 @@ class TestMkdir(object):
"""
Test Case 4 - trying to create "." should fail
"""
- fs_type,fs_img = fs_obj_mkdir
+ fs_type,fs_cmd_prefix,fs_img = fs_obj_mkdir
with ubman.log.section('Test Case 4 - mkdir (".")'):
output = ubman.run_command_list([
'host bind 0 %s' % fs_img,
- '%smkdir host 0:0 .' % fs_type])
+ '%smkdir host 0:0 .' % fs_cmd_prefix])
assert('Unable to create a directory' in ''.join(output))
assert_fs_integrity(fs_type, fs_img)
@@ -80,11 +80,11 @@ class TestMkdir(object):
"""
Test Case 5 - trying to create ".." should fail
"""
- fs_type,fs_img = fs_obj_mkdir
+ fs_type,fs_cmd_prefix,fs_img = fs_obj_mkdir
with ubman.log.section('Test Case 5 - mkdir ("..")'):
output = ubman.run_command_list([
'host bind 0 %s' % fs_img,
- '%smkdir host 0:0 ..' % fs_type])
+ '%smkdir host 0:0 ..' % fs_cmd_prefix])
assert('Unable to create a directory' in ''.join(output))
assert_fs_integrity(fs_type, fs_img)
@@ -93,29 +93,29 @@ class TestMkdir(object):
'Test Case 6 - create as many directories as amount of directory
entries goes beyond a cluster size)'
"""
- fs_type,fs_img = fs_obj_mkdir
+ fs_type,fs_cmd_prefix,fs_img = fs_obj_mkdir
with ubman.log.section('Test Case 6 - mkdir (create many)'):
output = ubman.run_command_list([
'host bind 0 %s' % fs_img,
- '%smkdir host 0:0 dir6' % fs_type,
- '%sls host 0:0 /' % fs_type])
+ '%smkdir host 0:0 dir6' % fs_cmd_prefix,
+ '%sls host 0:0 /' % fs_cmd_prefix])
assert('dir6/' in ''.join(output))
for i in range(0, 20):
output = ubman.run_command(
'%smkdir host 0:0 dir6/0123456789abcdef%02x'
- % (fs_type, i))
- output = ubman.run_command('%sls host 0:0 dir6' % fs_type)
+ % (fs_cmd_prefix, i))
+ output = ubman.run_command('%sls host 0:0 dir6' % fs_cmd_prefix)
assert('0123456789abcdef00/' in output)
assert('0123456789abcdef13/' in output)
output = ubman.run_command(
- '%sls host 0:0 dir6/0123456789abcdef13/.' % fs_type)
+ '%sls host 0:0 dir6/0123456789abcdef13/.' % fs_cmd_prefix)
assert('./' in output)
assert('../' in output)
output = ubman.run_command(
- '%sls host 0:0 dir6/0123456789abcdef13/..' % fs_type)
+ '%sls host 0:0 dir6/0123456789abcdef13/..' % fs_cmd_prefix)
assert('0123456789abcdef00/' in output)
assert('0123456789abcdef13/' in output)
assert_fs_integrity(fs_type, fs_img)