
On Fri, Aug 02, 2024 at 11:33:20AM +0200, Richard Weinberger wrote:
There is no need to mount the filesystem on the host side. All filesystem tools offer some way to fill the fs without mounting.
So, create the content on the host side, create and fill the fs without mounting. No more sudo or guestmount needed.
This new approach works because the tests don't care about user IDs and no device files are needed. If user IDs start to matter it's still possible to use wrapper tools like fakeroot in future while filling the fs.
Signed-off-by: Richard Weinberger richard@nod.at Tested-by: Mattijs Korpershoek mkorpershoek@baylibre.com
test/py/tests/fs_helper.py | 11 +- test/py/tests/test_fs/conftest.py | 175 ++++++------------------------ test/py/tests/test_ut.py | 4 +- 3 files changed, 47 insertions(+), 143 deletions(-)
diff --git a/test/py/tests/fs_helper.py b/test/py/tests/fs_helper.py index 380f4c4dca..154e01264c 100644 --- a/test/py/tests/fs_helper.py +++ b/test/py/tests/fs_helper.py @@ -9,7 +9,7 @@ import re import os from subprocess import call, check_call, check_output, CalledProcessError
-def mk_fs(config, fs_type, size, prefix, size_gran = 0x100000): +def mk_fs(config, fs_type, size, prefix, src_dir, size_gran = 0x100000): """Create a file system volume
Args:
@@ -39,6 +39,13 @@ def mk_fs(config, fs_type, size, prefix, size_gran = 0x100000): else: fs_lnxtype = fs_type
if src_dir:
if fs_lnxtype == 'ext4':
mkfs_opt = mkfs_opt + ' -d ' + src_dir
elif fs_lnxtype != 'vfat':
# Implement src_dir for this fs!
raise
count = (size + size_gran - 1) // size_gran
# Some distributions do not add /sbin to the default PATH, where mkfs lives
This brings two new pylint errors: test/py/tests/fs_helper.py:47:12: E0704: The raise statement is not inside an except clause (misplaced-bare-raise) test/py/tests/fs_helper.py:78:4: E1120: No value for argument 'src_dir' in function call (no-value-for-parameter)