[LTP] [PATCH 1/2] lib: Add is_fuse flag to SAFE_MOUNT() and tst_device
Wei Gao
wegao@suse.com
Wed Jul 2 15:18:19 CEST 2025
On Mon, Jun 30, 2025 at 05:32:04PM +0200, Cyril Hrubis wrote:
> This allows us to adjust tests that need different expectations on FUSE
> based filesystems.
>
> Signed-off-by: Cyril Hrubis <chrubis@suse.cz>
Very nit: Reported-by: Jan Polensky <japo@linux.ibm.com>
Is there any issue link can be provide?
> ---
> include/old/safe_macros.h | 2 +-
> include/safe_macros_fn.h | 2 +-
> include/tst_device.h | 2 ++
> include/tst_safe_macros.h | 7 ++++++-
> lib/safe_macros.c | 10 ++++++++--
> lib/tst_test.c | 4 ++--
> 6 files changed, 20 insertions(+), 7 deletions(-)
>
> diff --git a/include/old/safe_macros.h b/include/old/safe_macros.h
> index fb1d7a110..307843ab0 100644
> --- a/include/old/safe_macros.h
> +++ b/include/old/safe_macros.h
> @@ -150,7 +150,7 @@
> #define SAFE_MOUNT(cleanup_fn, source, target, filesystemtype, \
> mountflags, data) \
> safe_mount(__FILE__, __LINE__, (cleanup_fn), (source), (target), \
> - (filesystemtype), (mountflags), (data))
> + (filesystemtype), (mountflags), (data), NULL)
>
> #define SAFE_UMOUNT(cleanup_fn, target) \
> safe_umount(__FILE__, __LINE__, (cleanup_fn), (target))
> diff --git a/include/safe_macros_fn.h b/include/safe_macros_fn.h
> index d256091b7..b4be482c1 100644
> --- a/include/safe_macros_fn.h
> +++ b/include/safe_macros_fn.h
> @@ -172,7 +172,7 @@ int safe_rename(const char *file, const int lineno, void (*cleanup_fn)(void),
> int safe_mount(const char *file, const int lineno, void (*cleanup_fn)(void),
> const char *source, const char *target,
> const char *filesystemtype, unsigned long mountflags,
> - const void *data);
> + const void *data, int *is_fuse);
>
> int safe_umount(const char *file, const int lineno, void (*cleanup_fn)(void),
> const char *target);
> diff --git a/include/tst_device.h b/include/tst_device.h
> index 2597fb4e2..9ca802735 100644
> --- a/include/tst_device.h
> +++ b/include/tst_device.h
> @@ -15,6 +15,8 @@ struct tst_device {
> const char *dev;
> const char *fs_type;
> uint64_t size;
> + /* If device was mounted by the test library this flag is set for fuse fileystems. */
> + int is_fuse;
> };
>
> /*
> diff --git a/include/tst_safe_macros.h b/include/tst_safe_macros.h
> index 19504beb5..6d53c0bbc 100644
> --- a/include/tst_safe_macros.h
> +++ b/include/tst_safe_macros.h
> @@ -241,7 +241,12 @@ int safe_getgroups(const char *file, const int lineno, int size, gid_t list[]);
> #define SAFE_MOUNT(source, target, filesystemtype, \
> mountflags, data) \
> safe_mount(__FILE__, __LINE__, NULL, (source), (target), \
> - (filesystemtype), (mountflags), (data))
> + (filesystemtype), (mountflags), (data), NULL)
> +
> +#define SAFE_MOUNT2(source, target, filesystemtype, \
> + mountflags, data, is_fuse) \
> + safe_mount(__FILE__, __LINE__, NULL, (source), (target), \
> + (filesystemtype), (mountflags), (data), (is_fuse))
>
> #define SAFE_UMOUNT(target) \
> safe_umount(__FILE__, __LINE__, NULL, (target))
> diff --git a/lib/safe_macros.c b/lib/safe_macros.c
> index 726c9ae8e..6d267522f 100644
> --- a/lib/safe_macros.c
> +++ b/lib/safe_macros.c
> @@ -907,11 +907,14 @@ static int possibly_fuse(const char *fs_type)
> int safe_mount(const char *file, const int lineno, void (*cleanup_fn)(void),
> const char *source, const char *target,
> const char *filesystemtype, unsigned long mountflags,
> - const void *data)
> + const void *data, int *is_fuse)
> {
> int rval = -1;
> char mpath[PATH_MAX];
>
> + if (is_fuse)
> + *is_fuse = 0;
> +
> if (realpath(target, mpath)) {
> tst_resm_(file, lineno, TINFO,
> "Mounting %s to %s fstyp=%s flags=%lx",
> @@ -957,8 +960,11 @@ int safe_mount(const char *file, const int lineno, void (*cleanup_fn)(void),
> filesystemtype, mount_ro, source, target);
>
> rval = tst_system(buf);
> - if (WIFEXITED(rval) && WEXITSTATUS(rval) == 0)
> + if (WIFEXITED(rval) && WEXITSTATUS(rval) == 0) {
> + if (is_fuse)
> + *is_fuse = 1;
> return 0;
> + }
>
> tst_brkm_(file, lineno, TBROK, cleanup_fn,
> "mount.%s failed with %i", filesystemtype, rval);
> diff --git a/lib/tst_test.c b/lib/tst_test.c
> index 17ce91932..2130e4be8 100644
> --- a/lib/tst_test.c
> +++ b/lib/tst_test.c
> @@ -1273,8 +1273,8 @@ static void prepare_device(struct tst_fs *fs)
> mnt_data = limit_tmpfs_mount_size(fs->mnt_data,
> buf, sizeof(buf), tdev.fs_type);
>
> - SAFE_MOUNT(get_device_name(tdev.fs_type), tst_test->mntpoint,
> - tdev.fs_type, fs->mnt_flags, mnt_data);
> + SAFE_MOUNT2(get_device_name(tdev.fs_type), tst_test->mntpoint,
> + tdev.fs_type, fs->mnt_flags, mnt_data, &tdev.is_fuse);
> context->mntpoint_mounted = 1;
> }
> }
> --
> 2.49.0
>
>
> --
> Mailing list info: https://lists.linux.it/listinfo/ltp
More information about the ltp
mailing list