diff options
| author | Simon Glass <[email protected]> | 2026-03-09 09:13:01 -0600 |
|---|---|---|
| committer | Tom Rini <[email protected]> | 2026-03-23 09:18:29 -0600 |
| commit | 23e9906192b86f3a0bddf02ef4ef6bfd2e6fa104 (patch) | |
| tree | 3d12b8f26f40b0887d376b6beedb0f7379b84fab | |
| parent | fade4112dad0fcb4c4c5610582ef1edec8d70ddc (diff) | |
test: fs_helper: Add a quiet flag to mk_fs()
In many cases callers only want to see warnings and errors from the
filesystem-creation tools, not their normal output.
Add a quiet parameter to mk_fs() that suppresses the output of mkfs
and switches mcopy from verbose to quiet mode.
Signed-off-by: Simon Glass <[email protected]>
Reviewed-by: Tom Rini <[email protected]>
| -rw-r--r-- | test/py/tests/fs_helper.py | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/test/py/tests/fs_helper.py b/test/py/tests/fs_helper.py index bd9169b2a4d..4b123ab0afd 100644 --- a/test/py/tests/fs_helper.py +++ b/test/py/tests/fs_helper.py @@ -8,9 +8,10 @@ import re import os from subprocess import call, check_call, check_output, CalledProcessError +from subprocess import DEVNULL def mk_fs(config, fs_type, size, prefix, src_dir=None, size_gran = 0x100000, - fs_img=None): + fs_img=None, quiet=False): """Create a file system volume Args: @@ -23,6 +24,7 @@ def mk_fs(config, fs_type, size, prefix, src_dir=None, size_gran = 0x100000, fs_img (str or None): Leaf filename for image, or None to use a default name. The image is always placed under persistent_data_dir. + quiet (bool): Suppress non-error output Raises: CalledProcessError: if any error occurs when creating the filesystem @@ -63,14 +65,17 @@ def mk_fs(config, fs_type, size, prefix, src_dir=None, size_gran = 0x100000, check_call(f'rm -f {fs_img}', shell=True) check_call(f'truncate -s $(( {size_gran} * {count} )) {fs_img}', shell=True) - check_call(f'mkfs.{fs_lnxtype} {mkfs_opt} {fs_img}', shell=True) + check_call(f'mkfs.{fs_lnxtype} {mkfs_opt} {fs_img}', shell=True, + stdout=DEVNULL if quiet else None) if fs_type == 'ext4': sb_content = check_output(f'tune2fs -l {fs_img}', shell=True).decode() if 'metadata_csum' in sb_content: check_call(f'tune2fs -O ^metadata_csum {fs_img}', shell=True) elif fs_lnxtype == 'vfat' and src_dir: - check_call(f'mcopy -i {fs_img} -vsmpQ {src_dir}/* ::/', shell=True) + flags = f"-smpQ{'' if quiet else 'v'}" + check_call(f'mcopy -i {fs_img} {flags} {src_dir}/* ::/', + shell=True) elif fs_lnxtype == 'exfat' and src_dir: check_call(f'fattools cp {src_dir}/* {fs_img}', shell=True) return fs_img |
