[PATCH v2 4/5] test: let fs_obj_mkdir() provide full file system type

Heinrich Schuchardt
2022-07-31T11:59:58Z

The fixuture fs_obj_mkdir() up to now only supplies an abbreviated file
system type (e.g. fat). Provide the full file system type too (e.g. fat32).

Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>
---
v2:
new patch
---
test/py/tests/test_fs/conftest.py | 6 ++--
test/py/tests/test_fs/test_mkdir.py | 54 ++++++++++++++---------------
2 files changed, 30 insertions(+), 30 deletions(-)

diff --git a/test/py/tests/test_fs/conftest.py b/test/py/tests/test_fs/conftest.py
index b638284e07..efe8be06eb 100644
--- a/test/py/tests/test_fs/conftest.py
+++ b/test/py/tests/test_fs/conftest.py
@@ -489,8 +489,8 @@ def fs_obj_mkdir(request, u_boot_config):
u_boot_config: U-boot configuration.

Return:
- A fixture for mkdir test, i.e. a duplet of file system type and
- volume file name.
+ A fixture for mkdir test, i.e. a triplet of file system type (e.g. fat),
+ volume file name and full file system type (e.g. fat32).
"""
fs_type = request.param
fs_img = ''
@@ -505,7 +505,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_img, fs_type]
call('rm -f %s' % fs_img, shell=True)

#
diff --git a/test/py/tests/test_fs/test_mkdir.py b/test/py/tests/test_fs/test_mkdir.py
index fa9561ec35..f5cc308362 100644
--- a/test/py/tests/test_fs/test_mkdir.py
+++ b/test/py/tests/test_fs/test_mkdir.py
@@ -18,104 +18,104 @@ class TestMkdir(object):
"""
Test Case 1 - create a directory under a root
"""
- fs_type,fs_img = fs_obj_mkdir
+ fs_ubtype, fs_img, _ = fs_obj_mkdir
with u_boot_console.log.section('Test Case 1 - mkdir'):
output = u_boot_console.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_ubtype,
+ '%sls host 0:0 /' % fs_ubtype])
assert('dir1/' in ''.join(output))

output = u_boot_console.run_command(
- '%sls host 0:0 dir1' % fs_type)
+ '%sls host 0:0 dir1' % fs_ubtype)
assert('./' in output)
assert('../' in output)
- assert_fs_integrity(fs_type, fs_img)
+ assert_fs_integrity(fs_ubtype, fs_img)

def test_mkdir2(self, u_boot_console, fs_obj_mkdir):
"""
Test Case 2 - create a directory under a sub-directory
"""
- fs_type,fs_img = fs_obj_mkdir
+ fs_ubtype, fs_img, _ = fs_obj_mkdir
with u_boot_console.log.section('Test Case 2 - mkdir (sub-sub directory)'):
output = u_boot_console.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_ubtype,
+ '%sls host 0:0 dir1' % fs_ubtype])
assert('dir2/' in ''.join(output))

output = u_boot_console.run_command(
- '%sls host 0:0 dir1/dir2' % fs_type)
+ '%sls host 0:0 dir1/dir2' % fs_ubtype)
assert('./' in output)
assert('../' in output)
- assert_fs_integrity(fs_type, fs_img)
+ assert_fs_integrity(fs_ubtype, fs_img)

def test_mkdir3(self, u_boot_console, fs_obj_mkdir):
"""
Test Case 3 - trying to create a directory with a non-existing
path should fail
"""
- fs_type,fs_img = fs_obj_mkdir
+ fs_ubtype, fs_img, _ = fs_obj_mkdir
with u_boot_console.log.section('Test Case 3 - mkdir (non-existing path)'):
output = u_boot_console.run_command_list([
'host bind 0 %s' % fs_img,
- '%smkdir host 0:0 none/dir3' % fs_type])
+ '%smkdir host 0:0 none/dir3' % fs_ubtype])
assert('Unable to create a directory' in ''.join(output))
- assert_fs_integrity(fs_type, fs_img)
+ assert_fs_integrity(fs_ubtype, fs_img)

def test_mkdir4(self, u_boot_console, fs_obj_mkdir):
"""
Test Case 4 - trying to create "." should fail
"""
- fs_type,fs_img = fs_obj_mkdir
+ fs_ubtype, fs_img, _ = fs_obj_mkdir
with u_boot_console.log.section('Test Case 4 - mkdir (".")'):
output = u_boot_console.run_command_list([
'host bind 0 %s' % fs_img,
- '%smkdir host 0:0 .' % fs_type])
+ '%smkdir host 0:0 .' % fs_ubtype])
assert('Unable to create a directory' in ''.join(output))
- assert_fs_integrity(fs_type, fs_img)
+ assert_fs_integrity(fs_ubtype, fs_img)

def test_mkdir5(self, u_boot_console, fs_obj_mkdir):
"""
Test Case 5 - trying to create ".." should fail
"""
- fs_type,fs_img = fs_obj_mkdir
+ fs_ubtype, fs_img, _ = fs_obj_mkdir
with u_boot_console.log.section('Test Case 5 - mkdir ("..")'):
output = u_boot_console.run_command_list([
'host bind 0 %s' % fs_img,
- '%smkdir host 0:0 ..' % fs_type])
+ '%smkdir host 0:0 ..' % fs_ubtype])
assert('Unable to create a directory' in ''.join(output))
- assert_fs_integrity(fs_type, fs_img)
+ assert_fs_integrity(fs_ubtype, fs_img)

def test_mkdir6(self, u_boot_console, fs_obj_mkdir):
"""
'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_ubtype, fs_img, _ = fs_obj_mkdir
with u_boot_console.log.section('Test Case 6 - mkdir (create many)'):
output = u_boot_console.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_ubtype,
+ '%sls host 0:0 /' % fs_ubtype])
assert('dir6/' in ''.join(output))

for i in range(0, 20):
output = u_boot_console.run_command(
'%smkdir host 0:0 dir6/0123456789abcdef%02x'
- % (fs_type, i))
- output = u_boot_console.run_command('%sls host 0:0 dir6' % fs_type)
+ % (fs_ubtype, i))
+ output = u_boot_console.run_command('%sls host 0:0 dir6' % fs_ubtype)
assert('0123456789abcdef00/' in output)
assert('0123456789abcdef13/' in output)

output = u_boot_console.run_command(
- '%sls host 0:0 dir6/0123456789abcdef13/.' % fs_type)
+ '%sls host 0:0 dir6/0123456789abcdef13/.' % fs_ubtype)
assert('./' in output)
assert('../' in output)

output = u_boot_console.run_command(
- '%sls host 0:0 dir6/0123456789abcdef13/..' % fs_type)
+ '%sls host 0:0 dir6/0123456789abcdef13/..' % fs_ubtype)
assert('0123456789abcdef00/' in output)
assert('0123456789abcdef13/' in output)
- assert_fs_integrity(fs_type, fs_img)
+ assert_fs_integrity(fs_ubtype, fs_img)
--
2.36.1