[PATCH 5/7] test_fs: Add test -e test

Marek Vasut marex at denx.de
Sun Apr 13 10:55:03 CEST 2025


Add test for the 'test -e' command to check for existence of files.
This exercises struct fstype_info .exists callback.

Signed-off-by: Marek Vasut <marex at denx.de>
---
Cc: Heinrich Schuchardt <xypron.glpk at gmx.de>
Cc: Ilias Apalodimas <ilias.apalodimas at linaro.org>
Cc: Mattijs Korpershoek <mkorpershoek at baylibre.com>
Cc: Simon Glass <sjg at chromium.org>
Cc: Tom Rini <trini at konsulko.com>
Cc: u-boot at lists.denx.de
---
 test/py/tests/test_fs/test_basic.py | 13 +++++++++++++
 1 file changed, 13 insertions(+)

diff --git a/test/py/tests/test_fs/test_basic.py b/test/py/tests/test_fs/test_basic.py
index 64a3b50f52a..88b163ce305 100644
--- a/test/py/tests/test_fs/test_basic.py
+++ b/test/py/tests/test_fs/test_basic.py
@@ -35,6 +35,19 @@ class TestFsBasic(object):
                 '%sls host 0:0 invalid_d' % fs_cmd_prefix)
             assert('' == output)
 
+        with ubman.log.section('Test Case 1c - test -e'):
+            # Test Case 1 - test -e
+            output = ubman.run_command_list([
+                'host bind 0 %s' % fs_img,
+                'test -e host 0:0 1MB.file && echo PASS'])
+            assert('PASS' in ''.join(output))
+
+        with ubman.log.section('Test Case 1d - test -e (invalid file)'):
+            # In addition, test with a nonexistent file to see if we crash.
+            output = ubman.run_command(
+                'test -e host 0:0 2MB.file || echo PASS')
+            assert('PASS' in ''.join(output))
+
     def test_fs2(self, ubman, fs_obj_basic):
         """
         Test Case 2 - size command for a small file
-- 
2.47.2



More information about the U-Boot mailing list