[PATCH 0/2] test: py: Convert more tests to use run_ut() helper
From: Simon Glass <simon.glass@canonical.com> This series converts additional Python tests to use the run_ut() helper. This reduces duplication and makes the tests more concise and consistent. The ext4l tests are straightforward conversions, while test_vbe.py requires splitting the U-Boot command script to separate the ut command. Simon Glass (2): test: py: Use run_ut() helper for ext4l tests test: py: Use run_ut() helper for vbe_test_fixup test/py/tests/test_fs/test_ext4l.py | 40 ++++++++--------------------- test/py/tests/test_vbe.py | 5 ++-- 2 files changed, 12 insertions(+), 33 deletions(-) -- 2.43.0 base-commit: 2f3c92a4a90abb72019046fbb568af2e7c0f929c branch: tesh
From: Simon Glass <simon.glass@canonical.com> 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> --- test/py/tests/test_fs/test_ext4l.py | 40 ++++++++--------------------- 1 file changed, 10 insertions(+), 30 deletions(-) diff --git a/test/py/tests/test_fs/test_ext4l.py b/test/py/tests/test_fs/test_ext4l.py index 3287f59fbe5..25d09dca889 100644 --- a/test/py/tests/test_fs/test_ext4l.py +++ b/test/py/tests/test_fs/test_ext4l.py @@ -72,69 +72,49 @@ class TestExt4l: def test_probe(self, ubman, ext4_image): """Test that ext4l can probe an ext4 filesystem.""" with ubman.log.section('Test ext4l probe'): - output = ubman.run_command( - f'ut -f fs fs_test_ext4l_probe_norun fs_image={ext4_image}') - assert 'failures: 0' in output + ubman.run_ut('fs', 'fs_test_ext4l_probe', fs_image=ext4_image) def test_msgs(self, ubman, ext4_image): """Test that ext4l_msgs env var produces mount messages.""" with ubman.log.section('Test ext4l msgs'): - output = ubman.run_command( - f'ut -f fs fs_test_ext4l_msgs_norun fs_image={ext4_image}') - assert 'failures: 0' in output + ubman.run_ut('fs', 'fs_test_ext4l_msgs', fs_image=ext4_image) def test_ls(self, ubman, ext4_image): """Test that ext4l can list directory contents.""" with ubman.log.section('Test ext4l ls'): - output = ubman.run_command( - f'ut -f fs fs_test_ext4l_ls_norun fs_image={ext4_image}') - assert 'failures: 0' in output + ubman.run_ut('fs', 'fs_test_ext4l_ls', fs_image=ext4_image) def test_opendir(self, ubman, ext4_image): """Test that ext4l can iterate directory entries.""" with ubman.log.section('Test ext4l opendir'): - output = ubman.run_command( - f'ut -f fs fs_test_ext4l_opendir_norun fs_image={ext4_image}') - assert 'failures: 0' in output + ubman.run_ut('fs', 'fs_test_ext4l_opendir', fs_image=ext4_image) def test_exists(self, ubman, ext4_image): """Test that ext4l_exists reports file existence correctly.""" with ubman.log.section('Test ext4l exists'): - output = ubman.run_command( - f'ut -f fs fs_test_ext4l_exists_norun fs_image={ext4_image}') - assert 'failures: 0' in output + ubman.run_ut('fs', 'fs_test_ext4l_exists', fs_image=ext4_image) def test_size(self, ubman, ext4_image): """Test that ext4l_size reports file size correctly.""" with ubman.log.section('Test ext4l size'): - output = ubman.run_command( - f'ut -f fs fs_test_ext4l_size_norun fs_image={ext4_image}') - assert 'failures: 0' in output + ubman.run_ut('fs', 'fs_test_ext4l_size', fs_image=ext4_image) def test_read(self, ubman, ext4_image): """Test that ext4l can read file contents.""" with ubman.log.section('Test ext4l read'): - output = ubman.run_command( - f'ut -f fs fs_test_ext4l_read_norun fs_image={ext4_image}') - assert 'failures: 0' in output + ubman.run_ut('fs', 'fs_test_ext4l_read', fs_image=ext4_image) def test_uuid(self, ubman, ext4_image): """Test that ext4l can return the filesystem UUID.""" with ubman.log.section('Test ext4l uuid'): - output = ubman.run_command( - f'ut -f fs fs_test_ext4l_uuid_norun fs_image={ext4_image}') - assert 'failures: 0' in output + ubman.run_ut('fs', 'fs_test_ext4l_uuid', fs_image=ext4_image) def test_statfs(self, ubman, ext4_image): """Test that ext4l can return filesystem statistics.""" with ubman.log.section('Test ext4l statfs'): - output = ubman.run_command( - f'ut -f fs fs_test_ext4l_statfs_norun fs_image={ext4_image}') - assert 'failures: 0' in output + ubman.run_ut('fs', 'fs_test_ext4l_statfs', fs_image=ext4_image) def test_fsinfo(self, ubman, ext4_image): """Test that fsinfo command displays filesystem statistics.""" with ubman.log.section('Test ext4l fsinfo'): - output = ubman.run_command( - f'ut -f fs fs_test_ext4l_fsinfo_norun fs_image={ext4_image}') - assert 'failures: 0' in output + ubman.run_ut('fs', 'fs_test_ext4l_fsinfo', fs_image=ext4_image) -- 2.43.0
From: Simon Glass <simon.glass@canonical.com> Split the base_script to separate the ut command from the U-Boot command sequence. This allows using run_ut() for the vbe_test_fixup test, reducing duplication and improving consistency. Co-developed-by: Claude Opus 4.5 <noreply@anthropic.com> Signed-off-by: Simon Glass <simon.glass@canonical.com> --- test/py/tests/test_vbe.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/test/py/tests/test_vbe.py b/test/py/tests/test_vbe.py index 411ed429605..5b1fb52d824 100644 --- a/test/py/tests/test_vbe.py +++ b/test/py/tests/test_vbe.py @@ -87,7 +87,6 @@ bootm loados bootm prep fdt addr fdt print -ut -f bootstd vbe_test_fixup_norun ''' @pytest.mark.boardspec('sandbox') @@ -117,9 +116,9 @@ def test_vbe_os_request(ubman): cmd = base_script % params with ubman.log.section('Kernel load'): - output = ubman.run_command_list(cmd.splitlines()) + ubman.run_command_list(cmd.splitlines()) - assert 'failures: 0' in output[-1] + ubman.run_ut('bootstd', 'vbe_test_fixup') @pytest.mark.boardspec('sandbox') def test_vbe_extlinux_fit_no_oem(ubman): -- 2.43.0
participants (1)
-
Simon Glass