[U-Boot] [PATCH v2 3/7] test: fs: run fsck after on fs image after the tests are run

Jean-Jacques Hiblot jjhiblot at ti.com
Fri Feb 1 14:33:36 UTC 2019


This is to check the integrity of the FS after the test operations.
This is useful to make sure that the operations are implemented properly,
and are not going to create silent corruptions.
Currently only the integrity of EXT4 filesystems is checked.

Signed-off-by: Jean-Jacques Hiblot <jjhiblot at ti.com>

---

Changes in v2:
- Add a FS integrity check at the end of the FS tests

 test/py/tests/test_fs/conftest.py | 13 +++++++++++++
 1 file changed, 13 insertions(+)

diff --git a/test/py/tests/test_fs/conftest.py b/test/py/tests/test_fs/conftest.py
index 745ed0ed38..e742cda662 100644
--- a/test/py/tests/test_fs/conftest.py
+++ b/test/py/tests/test_fs/conftest.py
@@ -216,6 +216,15 @@ def mount_fs(fs_type, device, mount_point):
     except CalledProcessError:
         raise
 
+
+def fsck(img, fs_type):
+    try:
+        if fs_type == 'ext4':
+            check_call('fsck.ext4 -n -f %s' % img, shell=True)
+    except CalledProcessError:
+        raise
+
+
 def umount_fs(mount_point):
     """Unmount a volume.
 
@@ -336,6 +345,7 @@ def fs_obj_basic(request, u_boot_config):
         yield [fs_ubtype, fs_img, md5val]
     finally:
         umount_fs(mount_dir)
+        fsck(fs_img, fs_type)
         call('rmdir %s' % mount_dir, shell=True)
         if fs_img:
             call('rm -f %s' % fs_img, shell=True)
@@ -423,6 +433,7 @@ def fs_obj_ext(request, u_boot_config):
         yield [fs_ubtype, fs_img, md5val]
     finally:
         umount_fs(mount_dir)
+        fsck(fs_img, fs_type)
         call('rmdir %s' % mount_dir, shell=True)
         if fs_img:
             call('rm -f %s' % fs_img, shell=True)
@@ -457,6 +468,7 @@ def fs_obj_mkdir(request, u_boot_config):
     else:
         yield [fs_ubtype, fs_img]
     finally:
+        fsck(fs_img, fs_type)
         if fs_img:
             call('rm -f %s' % fs_img, shell=True)
 
@@ -522,6 +534,7 @@ def fs_obj_unlink(request, u_boot_config):
         yield [fs_ubtype, fs_img]
     finally:
         umount_fs(mount_dir)
+        fsck(fs_img, fs_type)
         call('rmdir %s' % mount_dir, shell=True)
         if fs_img:
             call('rm -f %s' % fs_img, shell=True)
-- 
2.17.1



More information about the U-Boot mailing list