Message ID | 20240516-listmount_statmount-v3-11-2ff4ba29bba7@suse.com |
---|---|
State | Accepted |
Headers | show |
Series | statmount/listmount testing suites | expand |
Hi! > +// SPDX-License-Identifier: GPL-2.0-or-later > +/* > + * Copyright (C) 2024 SUSE LLC Andrea Cervesato <andrea.cervesato@suse.com> > + */ > + > +/*\ > + * [Description] > + * > + * This test verifies that statmount() is correctly reading name of the > + * filesystem type using STATMOUNT_FS_TYPE. > + * > + * [Algorithm] > + * > + * * create a mount point > + * * run statmount() on the mount point using STATMOUNT_FS_TYPE > + * * read results and check if contain the name of the filesystem > + */ > + > +#include "statmount.h" > +#include "lapi/stat.h" > +#include "lapi/sched.h" > + > +#define MNTPOINT "mntpoint" > +#define SM_SIZE (1 << 10) > + > +static uint64_t root_id; > +static struct statmount *st_mount; > + > +static void run(void) > +{ > + memset(st_mount, 0, SM_SIZE); > + > + TST_EXP_PASS(statmount( > + root_id, > + STATMOUNT_FS_TYPE, > + st_mount, > + SM_SIZE, > + 0)); > + > + if (TST_RET == -1) > + return; > + > + TST_EXP_EQ_LI(st_mount->mask, STATMOUNT_FS_TYPE); > + TST_EXP_EXPR(strcmp(st_mount->str + st_mount->fs_type, tst_device->fs_type) == 0, > + "statmount() read '%s', expected '%s'", > + st_mount->str + st_mount->fs_type, tst_device->fs_type); This starts to be a common pattern, I guess that we need TST_EXP_STR_EQ()... > +} > + > +static void setup(void) > +{ > + struct statx sx; > + > + SAFE_STATX(AT_FDCWD, MNTPOINT, 0, STATX_MNT_ID_UNIQUE, &sx); > + root_id = sx.stx_mnt_id; > +} > + > +static struct tst_test test = { > + .test_all = run, > + .setup = setup, > + .min_kver = "6.8", > + .mount_device = 1, > + .mntpoint = MNTPOINT, > + .all_filesystems = 1, > + .skip_filesystems = (const char *const []) { > + "fuse", > + NULL > + }, > + .bufs = (struct tst_buffers []) { > + {&st_mount, .size = SM_SIZE}, > + {} > + } > +}; > > -- > 2.35.3 > > > -- > Mailing list info: https://lists.linux.it/listinfo/ltp
diff --git a/runtest/syscalls b/runtest/syscalls index b04aabc6f..a3546b155 100644 --- a/runtest/syscalls +++ b/runtest/syscalls @@ -1543,6 +1543,7 @@ statmount02 statmount02 statmount03 statmount03 statmount04 statmount04 statmount05 statmount05 +statmount06 statmount06 statfs01 statfs01 statfs01_64 statfs01_64 diff --git a/testcases/kernel/syscalls/statmount/.gitignore b/testcases/kernel/syscalls/statmount/.gitignore index f64763242..03a75bd40 100644 --- a/testcases/kernel/syscalls/statmount/.gitignore +++ b/testcases/kernel/syscalls/statmount/.gitignore @@ -3,3 +3,4 @@ statmount02 statmount03 statmount04 statmount05 +statmount06 diff --git a/testcases/kernel/syscalls/statmount/statmount06.c b/testcases/kernel/syscalls/statmount/statmount06.c new file mode 100644 index 000000000..2f5fc870f --- /dev/null +++ b/testcases/kernel/syscalls/statmount/statmount06.c @@ -0,0 +1,72 @@ +// SPDX-License-Identifier: GPL-2.0-or-later +/* + * Copyright (C) 2024 SUSE LLC Andrea Cervesato <andrea.cervesato@suse.com> + */ + +/*\ + * [Description] + * + * This test verifies that statmount() is correctly reading name of the + * filesystem type using STATMOUNT_FS_TYPE. + * + * [Algorithm] + * + * * create a mount point + * * run statmount() on the mount point using STATMOUNT_FS_TYPE + * * read results and check if contain the name of the filesystem + */ + +#include "statmount.h" +#include "lapi/stat.h" +#include "lapi/sched.h" + +#define MNTPOINT "mntpoint" +#define SM_SIZE (1 << 10) + +static uint64_t root_id; +static struct statmount *st_mount; + +static void run(void) +{ + memset(st_mount, 0, SM_SIZE); + + TST_EXP_PASS(statmount( + root_id, + STATMOUNT_FS_TYPE, + st_mount, + SM_SIZE, + 0)); + + if (TST_RET == -1) + return; + + TST_EXP_EQ_LI(st_mount->mask, STATMOUNT_FS_TYPE); + TST_EXP_EXPR(strcmp(st_mount->str + st_mount->fs_type, tst_device->fs_type) == 0, + "statmount() read '%s', expected '%s'", + st_mount->str + st_mount->fs_type, tst_device->fs_type); +} + +static void setup(void) +{ + struct statx sx; + + SAFE_STATX(AT_FDCWD, MNTPOINT, 0, STATX_MNT_ID_UNIQUE, &sx); + root_id = sx.stx_mnt_id; +} + +static struct tst_test test = { + .test_all = run, + .setup = setup, + .min_kver = "6.8", + .mount_device = 1, + .mntpoint = MNTPOINT, + .all_filesystems = 1, + .skip_filesystems = (const char *const []) { + "fuse", + NULL + }, + .bufs = (struct tst_buffers []) { + {&st_mount, .size = SM_SIZE}, + {} + } +};
From: Andrea Cervesato <andrea.cervesato@suse.com> This test verifies that statmount() is correctly reading name of the filesystem type using STATMOUNT_FS_TYPE. --- runtest/syscalls | 1 + testcases/kernel/syscalls/statmount/.gitignore | 1 + testcases/kernel/syscalls/statmount/statmount06.c | 72 +++++++++++++++++++++++ 3 files changed, 74 insertions(+)