[PATCH 09/10] test: Use Python truncate() for image file

Simon Glass sjg at chromium.org
Wed May 6 17:56:23 CEST 2026


Replace the shell 'truncate -s <size>M' invocation with Python's
file.truncate(), avoiding a subshell for what is just a sized empty
file.

Signed-off-by: Simon Glass <sjg at chromium.org>
---

 test/py/tests/fs_helper.py | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/test/py/tests/fs_helper.py b/test/py/tests/fs_helper.py
index f81b9c274dc..7659f9e2650 100644
--- a/test/py/tests/fs_helper.py
+++ b/test/py/tests/fs_helper.py
@@ -108,7 +108,8 @@ class FsHelper:
         mkfs_opt, fs_lnxtype = self._get_fs_args()
 
         check_call(f'rm -f {fs_img}', shell=True)
-        check_call(f'truncate -s {self.size_mb}M {fs_img}', shell=True)
+        with open(fs_img, 'wb') as fsi:
+            fsi.truncate(self.size_mb << 20)
         check_call(f'mkfs.{fs_lnxtype} {mkfs_opt} {fs_img}', shell=True,
                    stdout=DEVNULL if self.quiet else None)
         if self.fs_type == 'ext4':
-- 
2.43.0



More information about the U-Boot mailing list