test: py: Use run_ut() helper for ext4l tests

Convert test_ext4l.py to use the run_ut() helper instead of manually
building the ut command and checking for failures. This reduces
duplication and makes the tests more concise.

Co-developed-by: Claude Opus 4.5 <noreply@anthropic.com>
Signed-off-by: Simon Glass <simon.glass@canonical.com>
This commit is contained in:
Simon Glass
2025-12-29 11:07:02 -07:00
parent 2f3c92a4a9
commit 680dfeb7ab

View File

@@ -72,69 +72,49 @@ class TestExt4l:
def test_probe(self, ubman, ext4_image): def test_probe(self, ubman, ext4_image):
"""Test that ext4l can probe an ext4 filesystem.""" """Test that ext4l can probe an ext4 filesystem."""
with ubman.log.section('Test ext4l probe'): with ubman.log.section('Test ext4l probe'):
output = ubman.run_command( ubman.run_ut('fs', 'fs_test_ext4l_probe', fs_image=ext4_image)
f'ut -f fs fs_test_ext4l_probe_norun fs_image={ext4_image}')
assert 'failures: 0' in output
def test_msgs(self, ubman, ext4_image): def test_msgs(self, ubman, ext4_image):
"""Test that ext4l_msgs env var produces mount messages.""" """Test that ext4l_msgs env var produces mount messages."""
with ubman.log.section('Test ext4l msgs'): with ubman.log.section('Test ext4l msgs'):
output = ubman.run_command( ubman.run_ut('fs', 'fs_test_ext4l_msgs', fs_image=ext4_image)
f'ut -f fs fs_test_ext4l_msgs_norun fs_image={ext4_image}')
assert 'failures: 0' in output
def test_ls(self, ubman, ext4_image): def test_ls(self, ubman, ext4_image):
"""Test that ext4l can list directory contents.""" """Test that ext4l can list directory contents."""
with ubman.log.section('Test ext4l ls'): with ubman.log.section('Test ext4l ls'):
output = ubman.run_command( ubman.run_ut('fs', 'fs_test_ext4l_ls', fs_image=ext4_image)
f'ut -f fs fs_test_ext4l_ls_norun fs_image={ext4_image}')
assert 'failures: 0' in output
def test_opendir(self, ubman, ext4_image): def test_opendir(self, ubman, ext4_image):
"""Test that ext4l can iterate directory entries.""" """Test that ext4l can iterate directory entries."""
with ubman.log.section('Test ext4l opendir'): with ubman.log.section('Test ext4l opendir'):
output = ubman.run_command( ubman.run_ut('fs', 'fs_test_ext4l_opendir', fs_image=ext4_image)
f'ut -f fs fs_test_ext4l_opendir_norun fs_image={ext4_image}')
assert 'failures: 0' in output
def test_exists(self, ubman, ext4_image): def test_exists(self, ubman, ext4_image):
"""Test that ext4l_exists reports file existence correctly.""" """Test that ext4l_exists reports file existence correctly."""
with ubman.log.section('Test ext4l exists'): with ubman.log.section('Test ext4l exists'):
output = ubman.run_command( ubman.run_ut('fs', 'fs_test_ext4l_exists', fs_image=ext4_image)
f'ut -f fs fs_test_ext4l_exists_norun fs_image={ext4_image}')
assert 'failures: 0' in output
def test_size(self, ubman, ext4_image): def test_size(self, ubman, ext4_image):
"""Test that ext4l_size reports file size correctly.""" """Test that ext4l_size reports file size correctly."""
with ubman.log.section('Test ext4l size'): with ubman.log.section('Test ext4l size'):
output = ubman.run_command( ubman.run_ut('fs', 'fs_test_ext4l_size', fs_image=ext4_image)
f'ut -f fs fs_test_ext4l_size_norun fs_image={ext4_image}')
assert 'failures: 0' in output
def test_read(self, ubman, ext4_image): def test_read(self, ubman, ext4_image):
"""Test that ext4l can read file contents.""" """Test that ext4l can read file contents."""
with ubman.log.section('Test ext4l read'): with ubman.log.section('Test ext4l read'):
output = ubman.run_command( ubman.run_ut('fs', 'fs_test_ext4l_read', fs_image=ext4_image)
f'ut -f fs fs_test_ext4l_read_norun fs_image={ext4_image}')
assert 'failures: 0' in output
def test_uuid(self, ubman, ext4_image): def test_uuid(self, ubman, ext4_image):
"""Test that ext4l can return the filesystem UUID.""" """Test that ext4l can return the filesystem UUID."""
with ubman.log.section('Test ext4l uuid'): with ubman.log.section('Test ext4l uuid'):
output = ubman.run_command( ubman.run_ut('fs', 'fs_test_ext4l_uuid', fs_image=ext4_image)
f'ut -f fs fs_test_ext4l_uuid_norun fs_image={ext4_image}')
assert 'failures: 0' in output
def test_statfs(self, ubman, ext4_image): def test_statfs(self, ubman, ext4_image):
"""Test that ext4l can return filesystem statistics.""" """Test that ext4l can return filesystem statistics."""
with ubman.log.section('Test ext4l statfs'): with ubman.log.section('Test ext4l statfs'):
output = ubman.run_command( ubman.run_ut('fs', 'fs_test_ext4l_statfs', fs_image=ext4_image)
f'ut -f fs fs_test_ext4l_statfs_norun fs_image={ext4_image}')
assert 'failures: 0' in output
def test_fsinfo(self, ubman, ext4_image): def test_fsinfo(self, ubman, ext4_image):
"""Test that fsinfo command displays filesystem statistics.""" """Test that fsinfo command displays filesystem statistics."""
with ubman.log.section('Test ext4l fsinfo'): with ubman.log.section('Test ext4l fsinfo'):
output = ubman.run_command( ubman.run_ut('fs', 'fs_test_ext4l_fsinfo', fs_image=ext4_image)
f'ut -f fs fs_test_ext4l_fsinfo_norun fs_image={ext4_image}')
assert 'failures: 0' in output