From e9848e30bd88bf889ef74799dab6c2a2a0628890 Mon Sep 17 00:00:00 2001 From: Aristo Chen Date: Mon, 11 May 2026 08:58:50 +0000 Subject: test: fs: Use shared generate_file from utils test_fs/test_erofs.py and test_fs/test_squashfs/sqfs_common.py both defined a generate_file() helper that writes a file of a given size filled with 'x'. The two functions were functionally identical and differed only in parameter names and docstrings. Move the helper into the existing test/py/utils.py module, which is the established home for generic test utilities (md5sum_file, PersistentRandomFile, attempt_to_open_file). Update both call sites to use it. Signed-off-by: Aristo Chen Reviewed-by: joaomarcos.costa@bootlin.com Reviewed-by: Simon Glass --- test/py/utils.py | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'test/py/utils.py') diff --git a/test/py/utils.py b/test/py/utils.py index ca80e4b0b0a..e8971502509 100644 --- a/test/py/utils.py +++ b/test/py/utils.py @@ -51,6 +51,19 @@ def md5sum_file(fn, max_length=None): data = fh.read(*params) return md5sum_data(data) +def generate_file(file_name, file_size): + """ Generates a file filled with 'x'. + + Args: + file_name: the file's name. + file_size: the content's length and therefore the file size. + """ + content = 'x' * file_size + + file = open(file_name, 'w') + file.write(content) + file.close() + class PersistentRandomFile: """Generate and store information about a persistent file containing random data.""" -- cgit v1.3.1