
Nothing uses this argument, so make it a constant for now. Also fix a pylint warning when checking for vfat/exfat. Signed-off-by: Simon Glass <sjg@chromium.org> --- test/py/tests/fs_helper.py | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/test/py/tests/fs_helper.py b/test/py/tests/fs_helper.py index aedf6af0aeb..6649aa7bc47 100644 --- a/test/py/tests/fs_helper.py +++ b/test/py/tests/fs_helper.py @@ -10,8 +10,11 @@ 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, quiet=False): +# size_gran (int): Size granularity of file system image in bytes +SIZE_GRAN = 1 << 20 + + +def mk_fs(config, fs_type, size, prefix, src_dir=None, fs_img=None, quiet=False): """Create a file system volume Args: @@ -20,7 +23,6 @@ def mk_fs(config, fs_type, size, prefix, src_dir=None, size_gran = 0x100000, size (int): Size of file system in bytes prefix (str): Prefix string of volume's file name src_dir (str): Root directory to use, or None for none - size_gran (int): Size granularity of file system image in bytes fs_img (str or None): Filename for image, or None to invent one quiet (bool): Suppress non-error output @@ -50,10 +52,10 @@ def mk_fs(config, fs_type, size, prefix, src_dir=None, size_gran = 0x100000, if src_dir: if fs_lnxtype == 'ext4': mkfs_opt = mkfs_opt + ' -d ' + src_dir - elif fs_lnxtype != 'vfat' and fs_lnxtype != 'exfat': + elif fs_lnxtype not in ('vfat', 'exfat'): raise ValueError(f'src_dir not implemented for fs {fs_lnxtype}') - count = (size + size_gran - 1) // size_gran + count = (size + SIZE_GRAN - 1) // SIZE_GRAN # Some distributions do not add /sbin to the default PATH, where mkfs lives if '/sbin' not in os.environ["PATH"].split(os.pathsep): @@ -61,7 +63,7 @@ def mk_fs(config, fs_type, size, prefix, src_dir=None, size_gran = 0x100000, try: check_call(f'rm -f {fs_img}', shell=True) - check_call(f'truncate -s $(( {size_gran} * {count} )) {fs_img}', + check_call(f'truncate -s $(( {SIZE_GRAN} * {count} )) {fs_img}', shell=True) check_call(f'mkfs.{fs_lnxtype} {mkfs_opt} {fs_img}', shell=True, stdout=DEVNULL if quiet else None) -- 2.43.0